Power optimization - Enable HRS3300 (heart rate sensor) sleep mode.
Put the HRS3300 to sleep mode when InfiniTime is going to sleep. This change reduces the power consumption by 130µA when the heart rate sensor is disabled.
This commit is contained in:
parent
32a9fff60c
commit
a48d4e0b13
1 changed files with 9 additions and 1 deletions
|
@ -14,6 +14,10 @@
|
||||||
|
|
||||||
using namespace Pinetime::Drivers;
|
using namespace Pinetime::Drivers;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static constexpr uint8_t ledDriveCurrentValue = 0x2f;
|
||||||
|
}
|
||||||
|
|
||||||
/** Driver for the HRS3300 heart rate sensor.
|
/** Driver for the HRS3300 heart rate sensor.
|
||||||
* Original implementation from wasp-os : https://github.com/daniel-thompson/wasp-os/blob/master/wasp/drivers/hrs3300.py
|
* Original implementation from wasp-os : https://github.com/daniel-thompson/wasp-os/blob/master/wasp/drivers/hrs3300.py
|
||||||
*
|
*
|
||||||
|
@ -35,7 +39,7 @@ void Hrs3300::Init() {
|
||||||
// Note: Setting low nibble to 0x8 per the datasheet results in
|
// Note: Setting low nibble to 0x8 per the datasheet results in
|
||||||
// modulated LED driver output. Setting to 0xF results in clean,
|
// modulated LED driver output. Setting to 0xF results in clean,
|
||||||
// steady output during the ADC conversion period.
|
// steady output during the ADC conversion period.
|
||||||
WriteRegister(static_cast<uint8_t>(Registers::PDriver), 0x2f);
|
WriteRegister(static_cast<uint8_t>(Registers::PDriver), ledDriveCurrentValue);
|
||||||
|
|
||||||
// HRS and ALS both in 15-bit mode results in ~50ms LED drive period
|
// HRS and ALS both in 15-bit mode results in ~50ms LED drive period
|
||||||
// and presumably ~50ms ADC conversion period.
|
// and presumably ~50ms ADC conversion period.
|
||||||
|
@ -50,6 +54,8 @@ void Hrs3300::Enable() {
|
||||||
auto value = ReadRegister(static_cast<uint8_t>(Registers::Enable));
|
auto value = ReadRegister(static_cast<uint8_t>(Registers::Enable));
|
||||||
value |= 0x80;
|
value |= 0x80;
|
||||||
WriteRegister(static_cast<uint8_t>(Registers::Enable), value);
|
WriteRegister(static_cast<uint8_t>(Registers::Enable), value);
|
||||||
|
|
||||||
|
WriteRegister(static_cast<uint8_t>(Registers::PDriver), ledDriveCurrentValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hrs3300::Disable() {
|
void Hrs3300::Disable() {
|
||||||
|
@ -57,6 +63,8 @@ void Hrs3300::Disable() {
|
||||||
auto value = ReadRegister(static_cast<uint8_t>(Registers::Enable));
|
auto value = ReadRegister(static_cast<uint8_t>(Registers::Enable));
|
||||||
value &= ~0x80;
|
value &= ~0x80;
|
||||||
WriteRegister(static_cast<uint8_t>(Registers::Enable), value);
|
WriteRegister(static_cast<uint8_t>(Registers::Enable), value);
|
||||||
|
|
||||||
|
WriteRegister(static_cast<uint8_t>(Registers::PDriver), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Hrs3300::ReadHrs() {
|
uint32_t Hrs3300::ReadHrs() {
|
||||||
|
|
Loading…
Reference in a new issue