From fbf9fc0c56515398392bcdd3de47671d4b10036e Mon Sep 17 00:00:00 2001 From: mikael Date: Sat, 6 Sep 2025 01:49:02 +0300 Subject: [PATCH 1/4] f(switch_to_s3_pcb): Change pinout to match ESP32 S3 PCB --- build.py | 2 +- drivers/ports/ESP32/bsp.cpp | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/build.py b/build.py index f32e609..2ef012c 100644 --- a/build.py +++ b/build.py @@ -7,7 +7,7 @@ ESP_IDF_DIR = '''$HOME/esp/''' -CMAKE_GEN_CMD = '''cmake -S . -B cmake-build/{PORT} -G Ninja -DPORT={PORT} -DPLATFORM={PLATFORM}''' +CMAKE_GEN_CMD = '''cmake -S . -B cmake-build/{PORT} -G Ninja -DPORT={PORT} -DPLATFORM={PLATFORM} -DIDF_TARGET=esp32s3''' CMAKE_BUILD_CMD = '''cmake --build cmake-build/{PORT}''' IMAGE_DIR = '''cmake-build/{PORT}/mission-timer.bin''' diff --git a/drivers/ports/ESP32/bsp.cpp b/drivers/ports/ESP32/bsp.cpp index b350c1b..5a3f3e4 100644 --- a/drivers/ports/ESP32/bsp.cpp +++ b/drivers/ports/ESP32/bsp.cpp @@ -21,11 +21,13 @@ namespace BSP{ } void init_sensors() { - gpio_set_direction(GPIO_NUM_25, GPIO_MODE_INPUT); - gpio_set_pull_mode(GPIO_NUM_25, GPIO_PULLDOWN_ONLY); + gpio_set_direction(GPIO_NUM_42, GPIO_MODE_INPUT); + gpio_set_pull_mode(GPIO_NUM_42, GPIO_PULLDOWN_ONLY); + + gpio_set_direction(GPIO_NUM_41, GPIO_MODE_INPUT); + gpio_set_pull_mode(GPIO_NUM_41, GPIO_PULLDOWN_ONLY); + } - gpio_set_direction(GPIO_NUM_26, GPIO_MODE_INPUT); - gpio_set_pull_mode(GPIO_NUM_26, GPIO_PULLDOWN_ONLY); } @@ -81,8 +83,8 @@ namespace BSP{ uint16_t previous; } button = {0U, 0U}, button2 = {0U, 0U}; - button_status[0] = gpio_get_level(GPIO_NUM_25); - button_status[1] = gpio_get_level(GPIO_NUM_26); + button_status[0] = gpio_get_level(GPIO_NUM_42); + button_status[1] = gpio_get_level(GPIO_NUM_41); uint16_t tmp = button.depressed; uint16_t tmp2 = button2.depressed; @@ -122,17 +124,17 @@ namespace BSP{ } LED* get_blue_led() { - static ESP_LED led(16); + static ESP_LED led(47); return &led; } LED* get_green_led() { - static ESP_LED led(17); + static ESP_LED led(3); return &led; } LED* get_red_led() { - static ESP_LED led(5); + static ESP_LED led(48); return &led; } From f98f9893fe049051ad27ffdca08c21e4a267be58 Mon Sep 17 00:00:00 2001 From: mikael Date: Sat, 6 Sep 2025 01:50:29 +0300 Subject: [PATCH 2/4] f(switch_to_s3_pcb): Enhance separation of concerns with mk-hsm --- drivers/include/bsp.h | 4 ++++ drivers/ports/ESP32/bsp.cpp | 7 +++++++ mk-hsm | 2 +- services/timebomb.cpp | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/include/bsp.h b/drivers/include/bsp.h index c077a19..704c70d 100644 --- a/drivers/include/bsp.h +++ b/drivers/include/bsp.h @@ -20,6 +20,10 @@ namespace BSP */ void init_sensors(); /** + * @brief Init hardware timers for periodic tasks + */ + void init_hardware_timers(); + /** * @brief Turn onboard LED ON * @note Init actuators must have been called */ diff --git a/drivers/ports/ESP32/bsp.cpp b/drivers/ports/ESP32/bsp.cpp index 5a3f3e4..bf4ba39 100644 --- a/drivers/ports/ESP32/bsp.cpp +++ b/drivers/ports/ESP32/bsp.cpp @@ -7,10 +7,13 @@ #include "driver/gpio.h" #include "timebomb.h" +constexpr unsigned int BUTTON_INTERVAL_MS = 50; + namespace BSP{ void init() { init_actuators(); init_sensors(); + init_hardware_timers(); } void init_actuators() { @@ -28,6 +31,10 @@ namespace BSP{ gpio_set_pull_mode(GPIO_NUM_41, GPIO_PULLDOWN_ONLY); } + void init_hardware_timers() { + if (TimerHandle_t button_timer = xTimerCreate("ButtonTimer", pdMS_TO_TICKS(BUTTON_INTERVAL_MS), pdTRUE, nullptr, ESP_BSP::button_read); button_timer != nullptr) { + xTimerStart(button_timer, 0); + } } diff --git a/mk-hsm b/mk-hsm index edb994c..0797d6f 160000 --- a/mk-hsm +++ b/mk-hsm @@ -1 +1 @@ -Subproject commit edb994c4ae94321d3db40ca43cf9bf8b942e50a0 +Subproject commit 0797d6f44a921375b85095ead632f353ae8fd82c diff --git a/services/timebomb.cpp b/services/timebomb.cpp index 8f626fb..021d0f0 100644 --- a/services/timebomb.cpp +++ b/services/timebomb.cpp @@ -15,6 +15,8 @@ StateHandler defused = std::bind(&TimeBomb::_defused, TimeBomb::get_default_inst TimeBomb::TimeBomb(): Active((std::bind(&TimeBomb::_initial, this, std::placeholders::_1))) { printf("Timebomb init\n"); + _task_name = "TimeBomb"; + _stack_size = 4096; te = TimeEvent::get_default_instance(TIMEOUT_SIG, this); } From 95031ba81fa3f5dc4aaaec6f0ccedc0c38faa4a4 Mon Sep 17 00:00:00 2001 From: mikael Date: Sat, 6 Sep 2025 01:57:54 +0300 Subject: [PATCH 3/4] f(switch_to_s3_pcb): Change CI target to ESP32-S3 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2a00bd3..a0a48ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -94,7 +94,7 @@ jobs: uses: espressif/esp-idf-ci-action@v1 with: esp_idf_version: v5.2.3 - target: esp32 + target: esp32-s3 - name: Check for Binary run: | From a551ee9c664e92a05c864b7a3b09efa308a38393 Mon Sep 17 00:00:00 2001 From: mikael Date: Sat, 6 Sep 2025 02:42:40 +0300 Subject: [PATCH 4/4] f(switch_to_s3_pcb): Update mbed port hsm --- mk-hsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk-hsm b/mk-hsm index 0797d6f..646d63d 160000 --- a/mk-hsm +++ b/mk-hsm @@ -1 +1 @@ -Subproject commit 0797d6f44a921375b85095ead632f353ae8fd82c +Subproject commit 646d63d9bd65a7c93510c2a1fa6f3c59e35151e1