summaryrefslogtreecommitdiff
path: root/src/system_fsm/booting.cpp
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-03-20 13:42:03 +1100
committerailurux <ailuruxx@gmail.com>2024-03-20 13:42:03 +1100
commit51dfb5b3e30caf823c2355ff957c01864f35f9f6 (patch)
tree1f0e41397259c6e206aba136ad5070b9de30e1b1 /src/system_fsm/booting.cpp
parent170c23b832eed6dad2b118e50164464cc93e5c4c (diff)
parenta05d93a1e26181237a76da5ce398c6b08497d591 (diff)
downloadtangara-fw-51dfb5b3e30caf823c2355ff957c01864f35f9f6.tar.gz
Merge branch 'main' into themes
Diffstat (limited to 'src/system_fsm/booting.cpp')
-rw-r--r--src/system_fsm/booting.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp
index 41f46df2..eb931192 100644
--- a/src/system_fsm/booting.cpp
+++ b/src/system_fsm/booting.cpp
@@ -57,13 +57,22 @@ auto Booting::entry() -> void {
sServices.reset(new ServiceLocator());
ESP_LOGI(kTag, "installing early drivers");
+ // NVS is needed first because it contains information about what specific
+ // hardware configuration we're running on.
+ sServices->nvs(
+ std::unique_ptr<drivers::NvsStorage>(drivers::NvsStorage::OpenSync()));
+
+ // HACK: fix up the switch polarity on newer dev units
+ sServices->nvs().LockPolarity(false);
+
// I2C and SPI are both always needed. We can't even power down or show an
// error without these.
ESP_ERROR_CHECK(drivers::init_spi());
- sServices->gpios(std::unique_ptr<drivers::Gpios>(drivers::Gpios::Create()));
+ sServices->gpios(std::unique_ptr<drivers::Gpios>(
+ drivers::Gpios::Create(sServices->nvs().LockPolarity())));
ESP_LOGI(kTag, "starting ui");
- if (!ui::UiState::InitBootSplash(sServices->gpios())) {
+ if (!ui::UiState::InitBootSplash(sServices->gpios(), sServices->nvs())) {
events::System().Dispatch(FatalError{});
return;
}
@@ -74,8 +83,6 @@ auto Booting::entry() -> void {
ESP_LOGI(kTag, "installing remaining drivers");
drivers::spiffs_mount();
sServices->samd(std::unique_ptr<drivers::Samd>(drivers::Samd::Create()));
- sServices->nvs(
- std::unique_ptr<drivers::NvsStorage>(drivers::NvsStorage::OpenSync()));
sServices->touchwheel(
std::unique_ptr<drivers::TouchWheel>{drivers::TouchWheel::Create()});
sServices->haptics(std::make_unique<drivers::Haptics>());
@@ -100,8 +107,6 @@ auto Booting::entry() -> void {
sServices->bluetooth().Enable();
}
- sServices->nvs().LockPolarity(true);
-
BootComplete ev{.services = sServices};
events::Audio().Dispatch(ev);
events::Ui().Dispatch(ev);