diff options
Diffstat (limited to 'src/system_fsm')
| -rw-r--r-- | src/system_fsm/booting.cpp | 6 | ||||
| -rw-r--r-- | src/system_fsm/include/system_fsm.hpp | 2 | ||||
| -rw-r--r-- | src/system_fsm/system_fsm.cpp | 10 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp index e7080e9b..c9a0a2d2 100644 --- a/src/system_fsm/booting.cpp +++ b/src/system_fsm/booting.cpp @@ -51,6 +51,8 @@ static auto bt_event_cb(drivers::bluetooth::Event ev) -> void { } } +static const TickType_t kInterruptCheckPeriod = pdMS_TO_TICKS(100); + auto Booting::entry() -> void { ESP_LOGI(kTag, "beginning tangara boot"); sServices.reset(new ServiceLocator()); @@ -109,6 +111,10 @@ auto Booting::exit() -> void { sAppConsole = new console::AppConsole(); sAppConsole->sServices = sServices; sAppConsole->Launch(); + + TimerHandle_t timer = xTimerCreate("INTERRUPTS", kInterruptCheckPeriod, true, + NULL, check_interrupts_cb); + xTimerStart(timer, portMAX_DELAY); } auto Booting::react(const BootComplete& ev) -> void { diff --git a/src/system_fsm/include/system_fsm.hpp b/src/system_fsm/include/system_fsm.hpp index c9803bef..cb733639 100644 --- a/src/system_fsm/include/system_fsm.hpp +++ b/src/system_fsm/include/system_fsm.hpp @@ -32,6 +32,8 @@ namespace system_fsm { +void check_interrupts_cb(TimerHandle_t timer); + /* * State machine for the overall system state. Responsible for managing * peripherals, and bringing the rest of the system up and down. diff --git a/src/system_fsm/system_fsm.cpp b/src/system_fsm/system_fsm.cpp index ca191324..9cca7eda 100644 --- a/src/system_fsm/system_fsm.cpp +++ b/src/system_fsm/system_fsm.cpp @@ -6,6 +6,7 @@ #include "system_fsm.hpp" #include "audio_fsm.hpp" +#include "driver/gpio.h" #include "event_queue.hpp" #include "gpios.hpp" #include "relative_wheel.hpp" @@ -23,6 +24,15 @@ std::unique_ptr<drivers::SdStorage> SystemState::sStorage; console::AppConsole* SystemState::sAppConsole; +void check_interrupts_cb(TimerHandle_t timer) { + if (!gpio_get_level(GPIO_NUM_34)) { + events::System().Dispatch(internal::GpioInterrupt{}); + } + if (!gpio_get_level(GPIO_NUM_35)) { + events::System().Dispatch(internal::SamdInterrupt{}); + } +} + void SystemState::react(const FatalError& err) { if (!is_in_state<states::Error>()) { transit<states::Error>(); |
