想使用GPIO的input读取光敏电阻传感器的DO输出的高低电平,然后通过灯来观察是否读取到,但是始中无现象。
//control the input void ReadDeviceConfiguration() { unsigned int uiGPIOPort; unsigned char pucGPIOPin; unsigned char ucPinValue; GPIO_IF_LedOff(MCU_ALL_LED_IND); while(1){ //Read PIN1 ucPinValue GPIO_IF_GetPortNPin(GPIOIN,&uiGPIOPort,&pucGPIOPin); ucPinValue = GPIO_IF_Get(GPIOIN,uiGPIOPort,pucGPIOPin); console.log(ucPinValue); //LIGHT slow if(ucPinValue == 1) { GPIO_IF_LedOn(MCU_RED_LED_GPIO); } //light high else { GPIO_IF_LedOff(MCU_RED_LED_GPIO); } //Enable GPIO Interrupt MAP_GPIOIntClear(GPIOA0_BASE,GPIO_PIN_7); MAP_IntPendClear(INT_GPIOA0); MAP_IntEnable(INT_GPIOA0); MAP_GPIOIntEnable(GPIOA0_BASE,GPIO_PIN_7); ucPinValue=0; } } int main() { //set vector table base 设置中断向量表基址,允许中断,初始化MCU BoardInit(); // Power on the corresponding GPIO port B for 9,10,11. // Set up the GPIO lines to mode 0 (GPIO) PinMuxConfig(); GPIO_IF_LedConfigure(LED1|LED2|LED3); GPIO_IF_LedOff(MCU_ALL_LED_IND); ReadDeviceConfiguration(); return 0; }
谢谢老师啦