Skip to content

Commit

Permalink
Implement workaround for #60 : disable sleep for TWI and SPI, and add…
Browse files Browse the repository at this point in the history
… a delay (500ms) between 2 button IRQ.
  • Loading branch information
JF002 committed Sep 13, 2020
1 parent d757344 commit 88f4c94
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/DisplayApp/DisplayApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/drivers/SpiMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
4 changes: 3 additions & 1 deletion src/drivers/TwiMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 88f4c94

Please sign in to comment.