changes for target esp32, such as ESP32-WROOM-32

This commit is contained in:
Victor Talpaert
2026-04-04 17:58:29 +02:00
parent c4bda245f9
commit 9b38e6de11
4 changed files with 26 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
menu "espScope Configuration" menu "espScope Configuration"
config LED_BUILTIN config LED_BUILTIN
int "LED IO Pin" int "LED IO Pin"
default 15 default 2
help help
LED IO pin LED IO pin
@@ -13,10 +13,11 @@ menu "espScope Configuration"
Default is 9 (BOOT button on Seeed XIAO ESP32C6). Default is 9 (BOOT button on Seeed XIAO ESP32C6).
config BOARD_SPECIFIC_INIT config BOARD_SPECIFIC_INIT
string "Name of file containing any board specfic initialisation" string "Name of file containing any board specific initialisation"
default "boards/default.h"
help help
If your board requires some specific initialization C code, place it in If your board requires some specific initialization C code, place it in
a file called "./boards/<your board name>.h" and set this to "./boards/your board name.h" a file called "./boards/<your board name>.h" and set this to "./boards/your board name.h"
Default is don't include any board-specific initialization file. Default is boards/default.h which is empty.
endmenu endmenu

0
main/boards/default.h Normal file
View File

View File

@@ -57,7 +57,7 @@ static int s_ws_client_fd = -1;
// Global configuration state // Global configuration state
static volatile bool s_reconfig_needed = false; static volatile bool s_reconfig_needed = false;
static uint32_t s_sample_rate = 10000; static uint32_t s_sample_rate = 20000;
static adc_atten_t s_atten = ADC_ATTEN_DB_12; static adc_atten_t s_atten = ADC_ATTEN_DB_12;
static adc_bitwidth_t s_bit_width = ADC_BIT_WIDTH; static adc_bitwidth_t s_bit_width = ADC_BIT_WIDTH;
static uint16_t s_test_hz = 100; static uint16_t s_test_hz = 100;
@@ -225,11 +225,13 @@ static void continuous_adc_init(adc_channel_t* channel, uint8_t channel_num,
dig_cfg.adc_pattern = adc_pattern; dig_cfg.adc_pattern = adc_pattern;
ESP_ERROR_CHECK(adc_continuous_config(*out_handle, &dig_cfg)); ESP_ERROR_CHECK(adc_continuous_config(*out_handle, &dig_cfg));
} }
#define TEST_SIGNAL_GPIO 4
static bool ledc_inited = false; static bool ledc_inited = false;
static void start_test_signal(uint32_t hz) { static void start_test_signal(uint32_t hz) {
if (ledc_inited) { if (ledc_inited) {
ESP_LOGI(TAG, "De-init test signal"); ESP_LOGI(TAG, "De-init test signal");
gpio_reset_pin(GPIO_NUM_1); gpio_reset_pin(TEST_SIGNAL_GPIO);
// Stop the PWM signal on channel 0 // Stop the PWM signal on channel 0
ledc_stop(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, 0); ledc_stop(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, 0);
@@ -240,7 +242,7 @@ static void start_test_signal(uint32_t hz) {
// (Optional) Uninstall fade functionality if used // (Optional) Uninstall fade functionality if used
ledc_fade_func_uninstall(); ledc_fade_func_uninstall();
} }
ESP_LOGI(TAG, "Starting test signal at %u Hz", hz); ESP_LOGI(TAG, "Starting test signal at %u Hz on GPIO %d", hz, TEST_SIGNAL_GPIO);
ledc_timer_config_t ledc_timer = { ledc_timer_config_t ledc_timer = {
.speed_mode = LEDC_LOW_SPEED_MODE, .speed_mode = LEDC_LOW_SPEED_MODE,
.duty_resolution = LEDC_TIMER_14_BIT, .duty_resolution = LEDC_TIMER_14_BIT,
@@ -248,7 +250,7 @@ static void start_test_signal(uint32_t hz) {
.freq_hz = hz, .freq_hz = hz,
.clk_cfg = LEDC_AUTO_CLK}; .clk_cfg = LEDC_AUTO_CLK};
ledc_channel_config_t ledc_channel = { ledc_channel_config_t ledc_channel = {
.gpio_num = 1, // GPIO data pin 1 .gpio_num = TEST_SIGNAL_GPIO,
.speed_mode = LEDC_LOW_SPEED_MODE, .speed_mode = LEDC_LOW_SPEED_MODE,
.channel = LEDC_CHANNEL_0, .channel = LEDC_CHANNEL_0,
.timer_sel = LEDC_TIMER_0, .timer_sel = LEDC_TIMER_0,
@@ -334,22 +336,27 @@ void app_main(void) {
gpio_set_level(CONFIG_LED_BUILTIN, 0); gpio_set_level(CONFIG_LED_BUILTIN, 0);
#endif #endif
#ifdef CONFIG_BOARD_SPECIFIC_INIT /* Board-specific initialisation hook. Defaults to boards/default.h (empty).
* To customise, create main/boards/<your_board>.h and set CONFIG_BOARD_SPECIFIC_INIT
* to "boards/<your_board>.h" via menuconfig or sdkconfig. */
#include CONFIG_BOARD_SPECIFIC_INIT #include CONFIG_BOARD_SPECIFIC_INIT
#endif
is_ap = wifi_manager_init_wifi(); is_ap = wifi_manager_init_wifi();
start_test_signal(100); // In STA mode, wait for an IP before touching hardware peripherals.
xTaskCreate(adc_read_task, "adc_read_task", 8192 + ADC_READ_LEN, NULL, 5, NULL); // ADC continuous mode on ESP32 conflicts with WiFi initialisation if started too early.
if (!is_ap) {
// Wait for WiFi connection (Not strict blocking anymore, manager handles it) ESP_LOGI(TAG, "Waiting for WiFi connection...");
// But let's keep it to print status while (!is_connected()) {
// Note: s_wifi_event_group is local to this file, we removed it in place of manager's. vTaskDelay(pdMS_TO_TICKS(100));
// Proper way: expose event group from manager or just dont block here. }
// For now, let's just proceed. The webserver will start and wait for connections. }
start_webserver(); start_webserver();
start_test_signal(s_test_hz);
xTaskCreate(adc_read_task, "adc_read_task", 8192 + ADC_READ_LEN, NULL, 5, NULL);
show_status_led(); show_status_led();
} }

View File

@@ -217,7 +217,7 @@ static void wifi_init_softap(void) {
ESP_LOGI(TAG, "SoftAP Started. SSID: %s", AP_SSID); ESP_LOGI(TAG, "SoftAP Started. SSID: %s", AP_SSID);
// Start DNS Server Task // Start DNS Server Task
xTaskCreate(dns_server_task, "dns_task", 2048, NULL, 5, NULL); xTaskCreate(dns_server_task, "dns_task", 4096, NULL, 5, NULL);
} }
static void wifi_init_station(const char* ssid, const char* pass) { static void wifi_init_station(const char* ssid, const char* pass) {