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
This commit is contained in:
@@ -56,6 +56,7 @@ class Samd {
|
||||
auto UpdateUsbStatus() -> void;
|
||||
|
||||
auto ResetToFlashSamd() -> void;
|
||||
auto SetFastChargeEnabled(bool) -> void;
|
||||
auto PowerDown() -> void;
|
||||
|
||||
auto UsbMassStorage(bool en) -> void;
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user