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: | 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/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 b350c1b..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() { @@ -21,11 +24,17 @@ 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); + 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); + } } @@ -81,8 +90,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 +131,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; } diff --git a/mk-hsm b/mk-hsm index edb994c..646d63d 160000 --- a/mk-hsm +++ b/mk-hsm @@ -1 +1 @@ -Subproject commit edb994c4ae94321d3db40ca43cf9bf8b942e50a0 +Subproject commit 646d63d9bd65a7c93510c2a1fa6f3c59e35151e1 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); }