如题~PD5输入,读不到~使用库函数GPIO_ReadInputPin(GPIOD, GPIO_PIN_5);
头次使用STM8很多不知道的地方 ,还请大侠们多指点`~
unsigned char PWR_STA;
void PWR_CHECK(void)
{
static unsigned char i;
static unsigned char count;
unsigned char pwr_sta[SAMP_IO_COUNT];
unsigned char sum;
if(GPIO_ReadInputPin(GPIOD, GPIO_PIN_5) != RESET)
pwr_sta[count] = 1;
else
pwr_sta[count] = 0;
//pwr_sta[count]=GPIO_ReadInputData(GPIOD);
if (++count >= SAMP_IO_COUNT)
{
count = 0;
sum = 0;
for (i = 0; i < SAMP_IO_COUNT; i++)
{
sum += pwr_sta[i];
}
//10次中5次以上为高电平即为有闭门器电源
if(sum>=5)
PWR_STA = 1;
else
PWR_STA = 0;
}
}
让大侠们见效了~
一周热门 更多>