diff options
author | JF002 <JF002@users.noreply.github.com> | 2021-04-16 19:57:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-16 19:57:35 +0200 |
commit | 36e27842e146ddcfbcd5dcef4ebb2c92955242be (patch) | |
tree | 54c2b4f658a82d5effc5f1a19f5937006aa748cd /src/drivers/TwiMaster.h | |
parent | eb769fb60ecb8f96ecf6901082ec3f0610842af8 (diff) | |
parent | 3c413bdd5283f6ef95d23a4b7274722da680f039 (diff) |
Merge pull request #263 from joaquimorg/0.16.0Update
Fix Issue #262 for 0.16.0 version
Diffstat (limited to 'src/drivers/TwiMaster.h')
-rw-r--r-- | src/drivers/TwiMaster.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/drivers/TwiMaster.h b/src/drivers/TwiMaster.h index 6e3ff721..f3c87b0a 100644 --- a/src/drivers/TwiMaster.h +++ b/src/drivers/TwiMaster.h @@ -3,13 +3,13 @@ #include <semphr.h> #include <drivers/include/nrfx_twi.h> // NRF_TWIM_Type #include <cstdint> -#include <nrfx_twim.h> namespace Pinetime { namespace Drivers { class TwiMaster { public: enum class Modules { TWIM1 }; + enum class Frequencies {Khz100, Khz250, Khz400}; enum class ErrorCodes {NoError, TransactionFailed}; struct Parameters { uint32_t frequency; @@ -27,13 +27,19 @@ namespace Pinetime { void Wakeup(); private: - nrfx_twim_t twim; + + ErrorCodes Read(uint8_t deviceAddress, uint8_t* buffer, size_t size, bool stop); + ErrorCodes Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop); + void FixHwFreezed(); + NRF_TWIM_Type* twiBaseAddress; + SemaphoreHandle_t mutex; const Modules module; const Parameters params; - SemaphoreHandle_t mutex; - static constexpr uint8_t maxDataSize{8}; + static constexpr uint8_t maxDataSize{16}; static constexpr uint8_t registerSize{1}; uint8_t internalBuffer[maxDataSize + registerSize]; + uint32_t txStartedCycleCount = 0; + static constexpr uint32_t HwFreezedDelay{161000}; }; } }
\ No newline at end of file |