diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-05-15 15:57:16 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-05-15 15:57:16 +1000 |
| commit | 4c9b77ea1308ef3fe72a81d888560161d19485d6 (patch) | |
| tree | efbe0c69ea555915cbbd414ac91b96ae8f279e9f /src/drivers | |
| parent | 00d6c2eca20571f1a53400f4f465c8dd7af557db (diff) | |
| download | tangara-fw-4c9b77ea1308ef3fe72a81d888560161d19485d6.tar.gz | |
Support setting the samd charge rate
We default to the fast one, and do not try setting the charge rate bit
on older samd versions
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/include/drivers/samd.hpp | 1 | ||||
| -rw-r--r-- | src/drivers/samd.cpp | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/drivers/include/drivers/samd.hpp b/src/drivers/include/drivers/samd.hpp index 55ea513c..897e78d6 100644 --- a/src/drivers/include/drivers/samd.hpp +++ b/src/drivers/include/drivers/samd.hpp @@ -56,6 +56,7 @@ class Samd { auto UpdateUsbStatus() -> void; auto ResetToFlashSamd() -> void; + auto SetFastChargeEnabled(bool) -> void; auto PowerDown() -> void; auto UsbMassStorage(bool en) -> void; diff --git a/src/drivers/samd.cpp b/src/drivers/samd.cpp index c5e8c08a..e4aa73ad 100644 --- a/src/drivers/samd.cpp +++ b/src/drivers/samd.cpp @@ -51,6 +51,7 @@ Samd::Samd() { UpdateChargeStatus(); UpdateUsbStatus(); + SetFastChargeEnabled(true); } Samd::~Samd() {} @@ -125,6 +126,18 @@ auto Samd::ResetToFlashSamd() -> void { ESP_ERROR_CHECK(transaction.Execute(3)); } +auto Samd::SetFastChargeEnabled(bool en) -> void { + if (version_ < 4) { + return; + } + I2CTransaction transaction; + transaction.start() + .write_addr(kAddress, I2C_MASTER_WRITE) + .write_ack(Registers::kPowerControl, (en << 1)) + .stop(); + ESP_ERROR_CHECK(transaction.Execute(3)); +} + auto Samd::PowerDown() -> void { I2CTransaction transaction; transaction.start() |
