diff options
author | Jean-François Milants <jf@codingfield.com> | 2021-03-31 19:47:27 +0200 |
---|---|---|
committer | Jean-François Milants <jf@codingfield.com> | 2021-04-04 15:56:04 +0200 |
commit | 68bdaee1cc301a2aca1849f38d2596debe7d67d1 (patch) | |
tree | 00f3bd9a1554c286aa2d5bd3a86bcfcdf7ba7171 /src/drivers/Bma421.h | |
parent | 04fc33e2d479161ec261f932b908dffbd73e227f (diff) |
First integration of the motion sensor (bma 421) : step counting + wake on wrist rotation + app to see the value of the 3 axis in "real time".
Diffstat (limited to 'src/drivers/Bma421.h')
-rw-r--r-- | src/drivers/Bma421.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/drivers/Bma421.h b/src/drivers/Bma421.h new file mode 100644 index 00000000..bcc06b1c --- /dev/null +++ b/src/drivers/Bma421.h @@ -0,0 +1,43 @@ +#pragma once +#include <drivers/Bma421_C/bma4_defs.h> + +namespace Pinetime { + namespace Drivers { + class TwiMaster; + class Bma421 { + public: + struct Values { + uint32_t steps; + int16_t x; + int16_t y; + int16_t z; + }; + Bma421(TwiMaster& twiMaster, uint8_t twiAddress); + Bma421(const Bma421&) = delete; + Bma421& operator=(const Bma421&) = delete; + Bma421(Bma421&&) = delete; + Bma421& operator=(Bma421&&) = delete; + + void Init(); + void Reset(); + Values Process(); + + void Read(uint8_t registerAddress, uint8_t *buffer, size_t size); + void Write(uint8_t registerAddress, const uint8_t *data, size_t size); + + void OnIrq(); + + uint32_t GetNbInterrupts() const {return nbInterrupts;} + + private: + TwiMaster& twiMaster; + uint8_t twiAddress; + + struct bma4_dev bma; + struct bma4_accel_config accel_conf; + static constexpr uint8_t deviceAddress = 0x18; + + uint32_t nbInterrupts = 0; + }; + } +}
\ No newline at end of file |