summaryrefslogtreecommitdiff
path: root/src/drivers/Hrs3300.h
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2021-01-10 17:57:26 +0100
committerJean-François Milants <jf@codingfield.com>2021-01-10 17:57:26 +0100
commit1a582815ba218d2a9047abae92b9f33a3301ffd5 (patch)
tree18aa0aeba146d990a0302f4840e870cad1c4ad6f /src/drivers/Hrs3300.h
parent50ae0ae5e073ac48652e6c26549f9b19655e8da3 (diff)
First implementation of the HR sensor using 100% foss code (ported from waspos)
Diffstat (limited to 'src/drivers/Hrs3300.h')
-rw-r--r--src/drivers/Hrs3300.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/drivers/Hrs3300.h b/src/drivers/Hrs3300.h
new file mode 100644
index 00000000..c34d55c6
--- /dev/null
+++ b/src/drivers/Hrs3300.h
@@ -0,0 +1,47 @@
+#pragma once
+
+#include "TwiMaster.h"
+
+namespace Pinetime {
+ namespace Drivers {
+ class Hrs3300 {
+ public:
+ enum class Registers : uint8_t {
+ Id = 0x00,
+ Enable = 0x01,
+ EnableHen = 0x80,
+ C1dataM = 0x08,
+ C0DataM = 0x09,
+ C0DataH = 0x0a,
+ PDriver = 0x0c,
+ C1dataH = 0x0d,
+ C1dataL = 0x0e,
+ C0dataL = 0x0f,
+ Res = 0x16,
+ Hgain = 0x17
+ };
+
+ Hrs3300(TwiMaster& twiMaster, uint8_t twiAddress);
+ Hrs3300(const Hrs3300&) = delete;
+ Hrs3300& operator=(const Hrs3300&) = delete;
+ Hrs3300(Hrs3300&&) = delete;
+ Hrs3300& operator=(Hrs3300&&) = delete;
+
+ void Init();
+ void Enable();
+ void Disable();
+ uint16_t ReadHrs();
+ uint16_t ReadAls();
+ void SetGain(uint8_t gain);
+ void SetDrive(uint8_t drive);
+
+ private:
+ TwiMaster& twiMaster;
+ uint8_t twiAddress;
+
+ void WriteRegister(uint8_t reg, uint8_t data);
+ uint8_t ReadRegister(uint8_t reg);
+
+ };
+ }
+}