c - ESP8266 GPIO 16 不能用作按钮

标签 c mongoose-os

我有以下代码,但看不到任何日志消息:

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 :

  1. 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/

相关文章:

c - 将指针传递给函数时出现段错误

C - 对 'sqrt' 的 undefined reference

c++ - 在 "a"(追加)模式下打开文件时 fseek 不起作用

c++ - 运行时检查失败 - 变量在未初始化的情况下被使用

c - libVLC 无法同时叠加和录制视频流

amazon-web-services - 在 AWS CloudFormation 中,使用 aws cli 创建新堆栈时,堆栈状态从 CREATE_IN_PROGRESS 更改为 ROLLBACK_COMPLETE

c - 在 C Mongoose 操作系统中的特定时间打开 2 个 LED