我有以下代码,但看不到任何日志消息:
void gpio_int_cb(int pin, void *arg) {
LOG(LL_INFO, ("button pushed"));
(void) pin;
(void) arg;
}
extern "C" enum mgos_app_init_result mgos_app_init(void) {
int pin_button = 16;
mgos_gpio_set_pull(pin_button, MGOS_GPIO_PULL_DOWN);
mgos_gpio_set_mode(pin_button, MGOS_GPIO_MODE_INPUT);
mgos_gpio_enable_int(pin_button);
mgos_gpio_set_int_handler(pin_button, MGOS_GPIO_INT_EDGE_POS, gpio_int_cb, NULL);
}
我错过了什么吗?
最佳答案
ESP8266 GPIO16 无法配置中断。来自ESP8266 technical reference :
- GPIO16 Related APIs Different from other IO interfaces, GPIO16(XPD_DCDC) belongs to the RTC module instead of the general GPIO module. It can be used to wake up the chip during deep-sleep; it can be configured to input or output mode; but it cannot trigger the IO interrupt.
关于c - ESP8266 GPIO 16 不能用作按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53508232/