summaryrefslogtreecommitdiff
path: root/src/drivers/TwiMaster.cpp
diff options
context:
space:
mode:
authorKieran Cawthray <kieranc@gmail.com>2021-06-16 14:33:34 (GMT)
committerKieran Cawthray <kieranc@gmail.com>2021-06-16 14:33:34 (GMT)
commitf5d756928ffef032fb5ac85e73f9a68b7b8f64dc (patch)
tree907608958d0be8a97a3d646c842fde3095cef939 /src/drivers/TwiMaster.cpp
parentf2d01166c380b72ebcb13ef649def88ff4cf2d21 (diff)
parente90e8c7426f9a44e696b208a5b393a60476a3d43 (diff)
Merge remote-tracking branch 'upstream/develop' into pinetimestyle
Diffstat (limited to 'src/drivers/TwiMaster.cpp')
-rw-r--r--src/drivers/TwiMaster.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp
index 7b6582d..fc9edf8 100644
--- a/src/drivers/TwiMaster.cpp
+++ b/src/drivers/TwiMaster.cpp
@@ -9,10 +9,12 @@ using namespace Pinetime::Drivers;
// TODO use DMA/IRQ
TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {module}, params {params} {
- mutex = xSemaphoreCreateBinary();
}
void TwiMaster::Init() {
+ if(mutex == nullptr)
+ mutex = xSemaphoreCreateBinary();
+
NRF_GPIO->PIN_CNF[params.pinScl] =
((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |