diff options
| author | Joaquim <joaquim.org@gmail.com> | 2021-04-10 18:09:33 (GMT) |
|---|---|---|
| committer | Joaquim <joaquim.org@gmail.com> | 2021-04-10 18:09:33 (GMT) |
| commit | 012c246e401c0745d4b6765217ce7137680070da (patch) | |
| tree | f5ac127917689dd57a36d7152f44bb923e2a9e9e /src/drivers/TwiMaster.h | |
| parent | eb769fb60ecb8f96ecf6901082ec3f0610842af8 (diff) | |
0.16.0 TWI problems fix
More memory for freertos heap and timer stack
Fix warning in watchface
Fix number of bytes read by cst816
Debug app to show freertos tasks
Increased the number of bytes of the twi write buffer
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 6e3ff72..f3c87b0 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 |
