From 88f4c94f8a5017c9ebf0a818f3aec11227d852e6 Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 13 Sep 2020 19:06:02 +0200 Subject: [PATCH] Implement workaround for https://github.com/JF002/Pinetime/issues/60 : disable sleep for TWI and SPI, and add a delay (500ms) between 2 button IRQ. --- src/DisplayApp/DisplayApp.h | 2 +- src/drivers/SpiMaster.cpp | 5 +++-- src/drivers/TwiMaster.cpp | 4 +++- src/main.cpp | 8 +++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/DisplayApp/DisplayApp.h b/src/DisplayApp/DisplayApp.h index 345e06d4..ad251397 100644 --- a/src/DisplayApp/DisplayApp.h +++ b/src/DisplayApp/DisplayApp.h @@ -62,7 +62,7 @@ namespace Pinetime { void IdleState(); QueueHandle_t msgQueue; - static constexpr uint8_t queueSize = 10; + static constexpr uint8_t queueSize = 1; static constexpr uint8_t itemSize = 1; Pinetime::Controllers::Battery &batteryController; diff --git a/src/drivers/SpiMaster.cpp b/src/drivers/SpiMaster.cpp index 2e5852a5..81ce7db1 100644 --- a/src/drivers/SpiMaster.cpp +++ b/src/drivers/SpiMaster.cpp @@ -226,18 +226,19 @@ bool SpiMaster::Read(uint8_t pinCsn, uint8_t* cmd, size_t cmdSize, uint8_t *data void SpiMaster::Sleep() { + /* while(spiBaseAddress->ENABLE != 0) { spiBaseAddress->ENABLE = (SPIM_ENABLE_ENABLE_Disabled << SPIM_ENABLE_ENABLE_Pos); } nrf_gpio_cfg_default(params.pinSCK); nrf_gpio_cfg_default(params.pinMOSI); nrf_gpio_cfg_default(params.pinMISO); - +*/ NRF_LOG_INFO("[SPIMASTER] sleep") } void SpiMaster::Wakeup() { - Init(); + //Init(); NRF_LOG_INFO("[SPIMASTER] Wakeup"); } diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index 14d12f9d..129d6d36 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -140,13 +140,15 @@ void TwiMaster::Write(uint8_t deviceAddress, const uint8_t *data, size_t size, b } void TwiMaster::Sleep() { + /* nrf_gpio_cfg_default(6); nrf_gpio_cfg_default(7); twiBaseAddress->ENABLE = 0; + */ NRF_LOG_INFO("[TWIMASTER] Sleep"); } void TwiMaster::Wakeup() { - Init(); + //Init(); NRF_LOG_INFO("[TWIMASTER] Wakeup"); } diff --git a/src/main.cpp b/src/main.cpp index fe413585..26490c8d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -101,9 +101,15 @@ extern "C" { } } +TickType_t previousTickCount = 0; void DebounceTimerCallback(TimerHandle_t xTimer) { xTimerStop(xTimer, 0); - systemTask->OnButtonPushed(); + + auto currentTickCount = xTaskGetTickCountFromISR(); + if(currentTickCount - previousTickCount > 500) { + systemTask->OnButtonPushed(); + previousTickCount = currentTickCount; + } } void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void) {