summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiku Isokoski <riksu9000@gmail.com>2021-08-18 21:40:27 +0300
committerRiku Isokoski <riksu9000@gmail.com>2021-08-18 21:40:27 +0300
commit40392d7b9199c87de9784cacb1dee5476e5a5b6f (patch)
treefd5221182420ee5a4712f219502ec0c2751994e6
parent81a36dc31ed22237e3cc06c8f4ba2a5cbcf07f8e (diff)
Use highest frequency and move mutex creation to Init
-rw-r--r--src/drivers/TwiMaster.cpp5
-rw-r--r--src/main.cpp4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp
index f17d7168..76009278 100644
--- a/src/drivers/TwiMaster.cpp
+++ b/src/drivers/TwiMaster.cpp
@@ -10,7 +10,6 @@ using namespace Pinetime::Drivers;
TwiMaster::TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, uint8_t pinScl)
: module {module}, frequency {frequency}, pinSda {pinSda}, pinScl {pinScl} {
- mutex = xSemaphoreCreateBinary();
}
void TwiMaster::ConfigurePins() const {
@@ -30,6 +29,10 @@ void TwiMaster::ConfigurePins() const {
}
void TwiMaster::Init() {
+ if (mutex == nullptr) {
+ mutex = xSemaphoreCreateBinary();
+ }
+
ConfigurePins();
twiBaseAddress = module;
diff --git a/src/main.cpp b/src/main.cpp
index 4e94ab19..524035fc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -81,8 +81,8 @@ Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
// The TWI device should work @ up to 400Khz but there is a HW bug which prevent it from
// respecting correct timings. According to erratas heet, this magic value makes it run
// at ~390Khz with correct timings.
-//static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000};
-Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, TWI_FREQUENCY_FREQUENCY_K250, pinTwiSda, pinTwiScl};
+static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000};
+Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, MaxTwiFrequencyWithoutHardwareBug, pinTwiSda, pinTwiScl};
Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
#ifdef PINETIME_IS_RECOVERY
static constexpr bool isFactory = true;