summaryrefslogtreecommitdiff
path: root/src/system_fsm/booting.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-03-20 11:43:33 +1100
committerjacqueline <me@jacqueline.id.au>2024-03-20 11:43:33 +1100
commita05d93a1e26181237a76da5ce398c6b08497d591 (patch)
tree3c71ba717dbb04b398ef3f19ad1ac0e0eaab3f98 /src/system_fsm/booting.cpp
parent46e67437717975c10c62775a3f40bec84ac4f44c (diff)
downloadtangara-fw-a05d93a1e26181237a76da5ce398c6b08497d591.tar.gz
Start using the lock switch polarity bit in nvs
Diffstat (limited to 'src/system_fsm/booting.cpp')
-rw-r--r--src/system_fsm/booting.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp
index e911932c..eb931192 100644
--- a/src/system_fsm/booting.cpp
+++ b/src/system_fsm/booting.cpp
@@ -57,14 +57,19 @@ 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()));
-
- // NVS is needed early so that we can correctly initialise the display.
- sServices->nvs(
- std::unique_ptr<drivers::NvsStorage>(drivers::NvsStorage::OpenSync()));
+ sServices->gpios(std::unique_ptr<drivers::Gpios>(
+ drivers::Gpios::Create(sServices->nvs().LockPolarity())));
ESP_LOGI(kTag, "starting ui");
if (!ui::UiState::InitBootSplash(sServices->gpios(), sServices->nvs())) {
@@ -102,8 +107,6 @@ auto Booting::entry() -> void {
sServices->bluetooth().Enable();
}
- sServices->nvs().LockPolarity(false);
-
BootComplete ev{.services = sServices};
events::Audio().Dispatch(ev);
events::Ui().Dispatch(ev);