Rework TouchHandler into not a task

This commit is contained in:
Riku Isokoski
2021-08-10 22:03:34 +03:00
parent 7e92577c14
commit 8a694adb09
6 changed files with 50 additions and 71 deletions

View File

@@ -12,10 +12,9 @@ TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {m
}
void TwiMaster::Init() {
sleeping = false;
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) |
@@ -177,14 +176,11 @@ void TwiMaster::Sleep() {
nrf_gpio_cfg_default(6);
nrf_gpio_cfg_default(7);
NRF_LOG_INFO("[TWIMASTER] Sleep");
sleeping = true;
}
void TwiMaster::Wakeup() {
if (sleeping) {
Init();
NRF_LOG_INFO("[TWIMASTER] Wakeup");
}
Init();
NRF_LOG_INFO("[TWIMASTER] Wakeup");
}
/* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX.
@@ -210,4 +206,4 @@ void TwiMaster::FixHwFreezed() {
// Re-enable I²C
twiBaseAddress->ENABLE = twi_state;
}
}

View File

@@ -39,7 +39,6 @@ namespace Pinetime {
uint8_t internalBuffer[maxDataSize + registerSize];
uint32_t txStartedCycleCount = 0;
static constexpr uint32_t HwFreezedDelay {161000};
bool sleeping;
};
}
}
}