I code in ic stm32f103vet for press button to turn on/off the led
#include "stm32f10x_rcc.h"
#include "stm32f10x.h"
#include "misc.h"
void GPIO_Config(void);
BitAction BitVal;
int main(){
GPIO_Config();
GPIO_SetBits(GPIOA, GPIO_Pin_6);
while(1)
{
if(!GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_10)){
while(!GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_10)){
GPIO_WriteBit(GPIOA, GPIO_Pin_6, BitVal);
BitVal =! BitVal; //error: assigning to 'BitAction' from incompatible type 'bool'
}
}
}
}
void GPIO_Config(void){
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOE, ENABLE);
/*config Led PA6*/
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*config Button E10*/
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOE, &GPIO_InitStructure); //button U6
}
with definition of 'BitVal' is
/**
* @brief Bit_SET and Bit_RESET enumeration
*/
typedef enum
{ Bit_RESET = 0,
Bit_SET
}BitAction;
i try to toggle bit value of BitVal with many way but it still not work how can i do that?