[已解决] ESP32S2 GPIO28 无法驱动LED
Posted: Tue May 18, 2021 5:24 am
绿灯GPIO28无法正常亮灯,电压约2.0V
ESP-IDF版本
ESP-IDF v4.3-beta3-131-ge45be4dd4
demo:
simple_ota
code:
- #define CONFIG_GREEN_LED_GPIO 28
- #define CONFIG_RED_LED_GPIO 37
- #define GREEN_LED_GPIO CONFIG_GREEN_LED_GPIO
- #define RED_LED_GPIO CONFIG_RED_LED_GPIO
- #define Led_Set_Red_On() gpio_set_level(RED_LED_GPIO, 0)
- #define Led_Set_Green_On() gpio_set_level(GREEN_LED_GPIO, 0)
- #define Led_Set_Red_Off() gpio_set_level(RED_LED_GPIO, 1)
- #define Led_Set_Green_Off() gpio_set_level(GREEN_LED_GPIO, 1)
- gpio_config_t cfg = { .pin_bit_mask = BIT64(GREEN_LED_GPIO),
- .mode = GPIO_MODE_OUTPUT,
- //for powersave reasons, the GPIO should not be floating
- .pull_up_en = false,
- .pull_down_en = false,
- .intr_type = GPIO_INTR_DISABLE, };
- Led_Set_Green_On();
- gpio_config(&cfg);
- gpio_set_drive_capability(GREEN_LED_GPIO, GPIO_DRIVE_CAP_3);
- gpio_hold_dis(GREEN_LED_GPIO);
- gpio_hold_en(GREEN_LED_GPIO);
- Led_Set_Red_On();
- cfg.pin_bit_mask = BIT64(RED_LED_GPIO);
- gpio_config(&cfg);
- gpio_set_drive_capability(RED_LED_GPIO, GPIO_DRIVE_CAP_3);
- gpio_hold_dis(RED_LED_GPIO);
- gpio_hold_en(RED_LED_GPIO);