AnsweredAssumed Answered

Bug in GPIO_WriteBit() function in STM8L Library???

Question asked by wang.tong on Jul 29, 2016
Latest reply on Oct 25, 2017 by pavel a
I have been using the GPIO_WriteBit() function to set/reset pins, but found it not working. The same function by register worked fine.

Example:
GPIO_WriteBit(GPIOB, GPIO_Pin_4, RESET); // this does not work!?
GPIOB->ODR &= 0xef;   // this is ok.

I check the source code of GPIO_WriteBit() and suspect there is a bug. Specifically, when RESETing, the function calls
    ClrBit(GPIOx->ODR, GPIO_Pin);
whereas macro ClrBit is defined as
    #define ClrBit(VAR,Place)    ( (VAR) &= (uint8_t)((uint8_t)((uint8_t)1<<(uint8_t)(Place))^(uint8_t)0xFF) )

It seems that it intends to do ChlrBit(GPIOB, 4) but instead does ClrBit(GPIOB, GPIO_Pin_4), which is not working.

Can somebody confirm this?

Outcomes