Skip to content

Commit 40392d7

Browse files
committed
Use highest frequency and move mutex creation to Init
1 parent 81a36dc commit 40392d7

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/drivers/TwiMaster.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ using namespace Pinetime::Drivers;
1010

1111
TwiMaster::TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, uint8_t pinScl)
1212
: module {module}, frequency {frequency}, pinSda {pinSda}, pinScl {pinScl} {
13-
mutex = xSemaphoreCreateBinary();
1413
}
1514

1615
void TwiMaster::ConfigurePins() const {
@@ -30,6 +29,10 @@ void TwiMaster::ConfigurePins() const {
3029
}
3130

3231
void TwiMaster::Init() {
32+
if (mutex == nullptr) {
33+
mutex = xSemaphoreCreateBinary();
34+
}
35+
3336
ConfigurePins();
3437

3538
twiBaseAddress = module;

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
8181
// The TWI device should work @ up to 400Khz but there is a HW bug which prevent it from
8282
// respecting correct timings. According to erratas heet, this magic value makes it run
8383
// at ~390Khz with correct timings.
84-
//static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000};
85-
Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, TWI_FREQUENCY_FREQUENCY_K250, pinTwiSda, pinTwiScl};
84+
static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000};
85+
Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, MaxTwiFrequencyWithoutHardwareBug, pinTwiSda, pinTwiScl};
8686
Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
8787
#ifdef PINETIME_IS_RECOVERY
8888
static constexpr bool isFactory = true;

0 commit comments

Comments
 (0)