diff --git a/main/Kconfig b/main/Kconfig index 1e607c6..c83e55c 100644 --- a/main/Kconfig +++ b/main/Kconfig @@ -12,4 +12,11 @@ menu "espScope Configuration" GPIO pin number to hold low on boot to erase NVS (Factory Reset). Default is 9 (BOOT button on Seeed XIAO ESP32C6). + config BOARD_SPECIFIC_INIT + string "Name of file containing any board specfic initialisation" + help + If your board requires some specific initialization C code, place it in + a file called "./boards/.h" and set this to "./boards/your board name.h" + Default is don't include any board-specific initialization file. + endmenu diff --git a/main/boards/xiao_esp32c6.h b/main/boards/xiao_esp32c6.h new file mode 100644 index 0000000..f488d32 --- /dev/null +++ b/main/boards/xiao_esp32c6.h @@ -0,0 +1,14 @@ +// Seeed XIAO ESP32C6: Configure GPIO 3 and GPIO 14 as outputs for Wifi antenna switch +{ + gpio_config_t board_io_conf = { + .pin_bit_mask = (1ULL << 3) | (1ULL << 14), + .mode = GPIO_MODE_OUTPUT, + .pull_up_en = GPIO_PULLUP_DISABLE, + .pull_down_en = GPIO_PULLDOWN_DISABLE, + .intr_type = GPIO_INTR_DISABLE}; + gpio_config(&board_io_conf); + + // Set GPIO 3 and GPIO 14 to low + gpio_set_level(3, 0); + gpio_set_level(14, 0); +} \ No newline at end of file diff --git a/main/main.c b/main/main.c index 4a0cc11..9516758 100644 --- a/main/main.c +++ b/main/main.c @@ -331,20 +331,9 @@ void app_main(void) { gpio_set_level(CONFIG_LED_BUILTIN, 0); #endif - /* Board-specific WiFi init (if any) */ - // Seeed XIAO ESP32C6: Configure GPIO 3 and GPIO 14 as outputs - gpio_config_t board_io_conf = { - .pin_bit_mask = (1ULL << 3) | (1ULL << 14), - .mode = GPIO_MODE_OUTPUT, - .pull_up_en = GPIO_PULLUP_DISABLE, - .pull_down_en = GPIO_PULLDOWN_DISABLE, - .intr_type = GPIO_INTR_DISABLE}; - gpio_config(&board_io_conf); - - // Set GPIO 3 and GPIO 14 to low - gpio_set_level(3, 0); - gpio_set_level(14, 0); - /* end board-specific WiFi init (if any) */ +#ifdef CONFIG_BOARD_SPECIFIC_INIT +#include CONFIG_BOARD_SPECIFIC_INIT +#endif is_ap = wifi_manager_init_wifi(); @@ -503,9 +492,9 @@ static esp_err_t power_handler(httpd_req_t* req) { httpd_resp_set_hdr(req, "Content-Type", "text/html; charset=utf-8"); httpd_resp_send(req, "

Bye!

", HTTPD_RESP_USE_STRLEN); + // delay to ensure network is flushed vTaskDelay(pdMS_TO_TICKS(200)); - esp_sleep_enable_timer_wakeup(30L * 24L * 60L * 60L * 1000000ULL); // One month esp_deep_sleep_start(); return ESP_OK; }