LED set et reset. toggle fonctionnel

This commit is contained in:
Yohan Boujon 2023-03-20 15:56:26 +01:00
parent 66b6dcad8b
commit 2e86eb6f77
3 changed files with 27 additions and 36 deletions

View file

@ -4,15 +4,12 @@
int main ( void )
{
int returnValue;
MyGPIO_Struct_TypeDef gpioB8_test = {GPIOB,8,In_PullDown};
MyGPIO_Struct_TypeDef gpioB4_test = {GPIOB,4,Out_PullUp};
MyGPIO_Init(&gpioB8_test);
returnValue = MyGPIO_Read(GPIOB,8);
MyGPIO_Init(&gpioB4_test);
MyGPIO_Set(GPIOB,4);
MyGPIO_Toggle(GPIOB,4);
MyGPIO_Toggle(GPIOB,4);
MyGPIO_Reset(GPIOB,4);
MyGPIO_Struct_TypeDef gpioA5_test = {GPIOA,5,Out_PullUp};
MyGPIO_Init(&gpioA5_test);
MyGPIO_Set(GPIOA,5);
MyGPIO_Toggle(GPIOA,5);
MyGPIO_Toggle(GPIOA,5);
MyGPIO_Reset(GPIOA,5);
do{
}while(1) ;

View file

@ -35,14 +35,14 @@ void MyGPIO_Set(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
void MyGPIO_Reset(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
{
GPIO->BSRR = (1 << (GPIO_Pin+0x16)); //BRX = BSX+16 reset register
GPIO->BRR = (1 << GPIO_Pin); //BRX = BSX+16 reset register
}
void MyGPIO_Toggle(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
{
if((GPIO->ODR = GPIO->ODR & (1 << GPIO_Pin)) > 0)
{
GPIO->BSRR = (1 << (GPIO_Pin+0x16)); //reset
GPIO->BRR = (1 << GPIO_Pin); //reset
} else {
GPIO->BSRR = (1 << GPIO_Pin); //set
}

View file

@ -75,7 +75,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
<IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<DebugOpt>
@ -332,7 +332,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>0</IsCurrentTarget>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<DebugOpt>
@ -414,25 +414,9 @@
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>6</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218782</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\Source\Principale.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\cool_reel\Source/Principale.c\6</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>10</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218808</Address>
<Address>134218772</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
@ -443,6 +427,22 @@
<ExecCommand></ExecCommand>
<Expression>\\cool_reel\Source/Principale.c\10</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>6</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\Source\Principale.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
@ -498,12 +498,6 @@
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<SystemViewers>
<Entry>
<Name>System Viewer\GPIOB</Name>
<WinId>35905</WinId>
</Entry>
</SystemViewers>
<DebugDescription>
<Enable>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq>