Use highest frequency and move mutex creation to Init

This commit is contained in:
Riku Isokoski 2021-08-18 21:40:27 +03:00
parent 81a36dc31e
commit 40392d7b91
2 changed files with 6 additions and 3 deletions

View File

@ -10,7 +10,6 @@ using namespace Pinetime::Drivers;
TwiMaster::TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, uint8_t pinScl) TwiMaster::TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, uint8_t pinScl)
: module {module}, frequency {frequency}, pinSda {pinSda}, pinScl {pinScl} { : module {module}, frequency {frequency}, pinSda {pinSda}, pinScl {pinScl} {
mutex = xSemaphoreCreateBinary();
} }
void TwiMaster::ConfigurePins() const { void TwiMaster::ConfigurePins() const {
@ -30,6 +29,10 @@ void TwiMaster::ConfigurePins() const {
} }
void TwiMaster::Init() { void TwiMaster::Init() {
if (mutex == nullptr) {
mutex = xSemaphoreCreateBinary();
}
ConfigurePins(); ConfigurePins();
twiBaseAddress = module; twiBaseAddress = module;

View File

@ -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 // 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 // respecting correct timings. According to erratas heet, this magic value makes it run
// at ~390Khz with correct timings. // at ~390Khz with correct timings.
//static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000}; static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000};
Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, TWI_FREQUENCY_FREQUENCY_K250, pinTwiSda, pinTwiScl}; Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, MaxTwiFrequencyWithoutHardwareBug, pinTwiSda, pinTwiScl};
Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress}; Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
#ifdef PINETIME_IS_RECOVERY #ifdef PINETIME_IS_RECOVERY
static constexpr bool isFactory = true; static constexpr bool isFactory = true;