From 1bc63bad940d019bf5003a3ebc8cdad93fbc299a Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Tue, 23 Jul 2019 11:47:38 +0200 Subject: [PATCH] bugfix IRQ masking --- include/irqhandler.h | 4 ++-- src/irqhandler.cpp | 10 +++++----- src/main.cpp | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/irqhandler.h b/include/irqhandler.h index db5dd2f1..c1802d41 100644 --- a/include/irqhandler.h +++ b/include/irqhandler.h @@ -17,8 +17,8 @@ #include "timekeeper.h" void irqHandler(void *pvParameters); -int mask_user_IRQ(); -int unmask_user_IRQ(); +bool mask_user_IRQ(); +bool unmask_user_IRQ(); #ifdef HAS_DISPLAY void IRAM_ATTR DisplayIRQ(); diff --git a/src/irqhandler.cpp b/src/irqhandler.cpp index f95f6fe9..116664a2 100644 --- a/src/irqhandler.cpp +++ b/src/irqhandler.cpp @@ -119,18 +119,18 @@ void IRAM_ATTR GpsIRQ() { } #endif -int mask_user_IRQ() { +bool mask_user_IRQ() { // begin of time critical section: lock I2C bus to ensure accurate timing if (I2C_MUTEX_LOCK()) { xTaskNotify(irqHandlerTask, MASK_IRQ, eSetBits); - return 0; + return true; } else - return 1; // failure + return false; // failure } -int unmask_user_IRQ() { +bool unmask_user_IRQ() { // end of time critical section: release I2C bus I2C_MUTEX_UNLOCK(); xTaskNotify(irqHandlerTask, UNMASK_IRQ, eSetBits); - return 0; + return true; } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 8a674885..f06eb6cd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -116,10 +116,9 @@ void setup() { // create some semaphores for syncing / mutexing tasks I2Caccess = xSemaphoreCreateMutex(); // for access management of i2c bus - if (I2Caccess) - xSemaphoreGive(I2Caccess); // Flag the i2c bus available for use + assert(I2Caccess != NULL); - // disable brownout detection + // disable brownout detection #ifdef DISABLE_BROWNOUT // register with brownout is at address DR_REG_RTCCNTL_BASE + 0xd4 (*((uint32_t volatile *)ETS_UNCACHED_ADDR((DR_REG_RTCCNTL_BASE + 0xd4)))) = 0;