summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-08-20 21:10:05 +1000
committerjacqueline <me@jacqueline.id.au>2023-08-20 21:10:05 +1000
commit27f329a9dbf18a046ade534c9330b03e586cdb98 (patch)
tree085e6c003a850c79156e45a830e2d7a997250284 /src/drivers
parent51cb168f79d19eed6083cb5ced3e9f3d97c16746 (diff)
downloadtangara-fw-27f329a9dbf18a046ade534c9330b03e586cdb98.tar.gz
Add an app console triggered shutdown
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/include/samd.hpp1
-rw-r--r--src/drivers/samd.cpp9
2 files changed, 10 insertions, 0 deletions
diff --git a/src/drivers/include/samd.hpp b/src/drivers/include/samd.hpp
index 4a31a577..2640eb8b 100644
--- a/src/drivers/include/samd.hpp
+++ b/src/drivers/include/samd.hpp
@@ -52,6 +52,7 @@ class Samd {
auto UpdateUsbStatus() -> void;
auto ResetToFlashSamd() -> void;
+ auto PowerDown() -> void;
static auto CreateReadPending() -> SemaphoreHandle_t;
diff --git a/src/drivers/samd.cpp b/src/drivers/samd.cpp
index 455e9ce5..176da241 100644
--- a/src/drivers/samd.cpp
+++ b/src/drivers/samd.cpp
@@ -138,6 +138,15 @@ auto Samd::ResetToFlashSamd() -> void {
ESP_ERROR_CHECK(transaction.Execute());
}
+auto Samd::PowerDown() -> void {
+ I2CTransaction transaction;
+ transaction.start()
+ .write_addr(kAddress, I2C_MASTER_WRITE)
+ .write_ack(Registers::kPowerControl, 0b1)
+ .stop();
+ ESP_ERROR_CHECK(transaction.Execute());
+}
+
auto Samd::CreateReadPending() -> SemaphoreHandle_t {
sReadPending = xSemaphoreCreateBinary();
return sReadPending;