- #include "esp_log.h"
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "esp_spi_flash.h"
- #include "esp_partition.h"
- #include <driver/uart.h>
- #include <driver/gpio.h>
- #define PARTITION_NAME "MCU_OTA"
- #define uart_num UART_NUM_2
- #define stm_boot_pin 13
- #define stm_reset_pin 12
- void app_main()
- {
- // gpio_reset_pin(stm_boot_pin);
- // gpio_reset_pin(stm_reset_pin);
- gpio_config_t app_gpio_config = {
- .mode = GPIO_MODE_OUTPUT, // 输出模式
- .pin_bit_mask = (1ULL << stm_boot_pin), // 配置引脚 st en
- .pull_up_en = GPIO_PULLUP_DISABLE, // 不使能上拉
- .pull_down_en = GPIO_PULLDOWN_DISABLE, // 不使能下拉
- .intr_type = GPIO_INTR_DISABLE // 不使能引脚中断
- };
- esp_err_t errs = gpio_config(&app_gpio_config);
- ESP_LOGI("MCU_OTA", "gpio_config : %d", errs);
- errs = gpio_set_level(stm_boot_pin, 0);
- ESP_LOGI("MCU_OTA", "gpio_set_level : %d", errs);
- // gpio_set_direction(stm_boot_pin, GPIO_MODE_OUTPUT);
- gpio_config_t app_gpio_config2 = {
- .mode = GPIO_MODE_OUTPUT, // 输出模式
- .pin_bit_mask = (1ULL << stm_reset_pin), // 配置引脚
- .pull_up_en = GPIO_PULLUP_DISABLE, // 不使能上拉
- .pull_down_en = GPIO_PULLDOWN_DISABLE, // 不使能下拉
- .intr_type = GPIO_INTR_DISABLE // 不使能引脚中断
- };
- errs = gpio_config(&app_gpio_config2);
- ESP_LOGI("MCU_OTA", "gpio_config : %d", errs);
- errs = gpio_set_level(stm_reset_pin, 1);
- ESP_LOGI("MCU_OTA", "gpio_set_level : %d", errs);
- vTaskDelay(1000 / portTICK_PERIOD_MS);
- ESP_LOGI("MCU_OTA", "stm_boot_pin : %d", gpio_get_level(stm_boot_pin));
- ESP_LOGI("MCU_OTA", "stm_reset_pin : %d", gpio_get_level(stm_reset_pin));
- }
想配置高电平 但是一直没反应 打印的都是0 硬件应该没问题在Arduino环境下是可以拉高的
I (323) main_task: Started on CPU0
I (327) main_task: Calling app_main()
I (331) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (340) MCU_OTA: gpio_config : 0
I (344) MCU_OTA: gpio_set_level : 0
I (348) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (358) MCU_OTA: gpio_config : 0
I (362) MCU_OTA: gpio_set_level : 0
I (1366) MCU_OTA: stm_boot_pin : 0
I (1366) MCU_OTA: stm_reset_pin : 0