AnsweredAssumed Answered

What does  (BitAction) do exactly?

Question asked by Carter Lee on Sep 8, 2017

Hi 

I'm analyzing the code as the below and came across that code when I was googling.

 

GPIO_WriteBit(GPIOG, GPIO_Pin_11,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOG, GPIO_Pin_11)));

 

But I can't understand what do 'BitAction' and '1-' do exactly?

 

I've found declaration

typedef enum
{
Bit_RESET = 0,
Bit_SET
}BitAction;

 

then I can guess that code working such as 

GPIO_WriteBit(GPIOG, GPIO_Pin_11,(BitAction)(1-0));

GPIO_WriteBit(GPIOG, GPIO_Pin_11,(BitAction)(1-1));

 

But I can't understand what does exactly BitAction do?

And what is the common purpose of GPIO_WriteBit(GPIOG, GPIO_Pin_11,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOG, GPIO_Pin_11))); code? 

Is this purpose for just toggling?

Outcomes