summaryrefslogtreecommitdiff
path: root/src/drivers/TwiMaster.h
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2021-04-08 20:07:24 +0200
committerJean-François Milants <jf@codingfield.com>2021-04-08 20:07:24 +0200
commit9ac4be8b759bb2cedeb999ce5e87d983261beded (patch)
tree2a5fabd9b7505976c20b5512f9335e75290bdd86 /src/drivers/TwiMaster.h
parent1d7576de64a33837434e6f414a74ae7dbe929196 (diff)
TwiMaster is now based on the NRFX TWI driver, as it handles more edge cases and workarounds for errors on the bus.
Reset the TWI bus after the soft-reset of the motion sensor to workaround issues on the TWI bus.
Diffstat (limited to 'src/drivers/TwiMaster.h')
-rw-r--r--src/drivers/TwiMaster.h14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/drivers/TwiMaster.h b/src/drivers/TwiMaster.h
index 399e3d0f..6e3ff721 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,21 +27,13 @@ namespace Pinetime {
void Wakeup();
private:
- ErrorCodes ReadWithRetry(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, size_t size);
- ErrorCodes WriteWithRetry(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t* data, size_t size);
-
- 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;
+ nrfx_twim_t twim;
const Modules module;
const Parameters params;
+ SemaphoreHandle_t mutex;
static constexpr uint8_t maxDataSize{8};
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