bugfixing mutex lock

This commit is contained in:
Verkehrsrot 2019-07-23 17:53:20 +02:00
parent 31c0037cba
commit 7d2d753252
3 changed files with 13 additions and 10 deletions

View File

@ -62,8 +62,9 @@ void DisplayKey(const uint8_t *key, uint8_t len, bool lsb) {
void init_display(const char *Productname, const char *Version) { void init_display(const char *Productname, const char *Version) {
// block i2c bus access // block i2c bus access
if (I2C_MUTEX_LOCK()) { if (!I2C_MUTEX_LOCK())
ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
else {
// show startup screen // show startup screen
uint8_t buf[32]; uint8_t buf[32];
u8x8.begin(); u8x8.begin();
@ -141,8 +142,9 @@ void refreshTheDisplay(bool nextPage) {
myTZ.toLocal(now()); // note: call now() here *before* locking mutex! myTZ.toLocal(now()); // note: call now() here *before* locking mutex!
// block i2c bus access // block i2c bus access
if (I2C_MUTEX_LOCK()) { if (!I2C_MUTEX_LOCK())
ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
else {
// set display on/off according to current device configuration // set display on/off according to current device configuration
if (DisplayIsOn != cfg.screenon) { if (DisplayIsOn != cfg.screenon) {
DisplayIsOn = cfg.screenon; DisplayIsOn = cfg.screenon;

View File

@ -120,12 +120,13 @@ void IRAM_ATTR GpsIRQ() {
#endif #endif
int mask_user_IRQ() { int mask_user_IRQ() {
// begin of time critical section: lock I2C bus to ensure accurate timing if (!I2C_MUTEX_LOCK()) {
if (I2C_MUTEX_LOCK()) { ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
return 0; // failure
} else {
xTaskNotify(irqHandlerTask, MASK_IRQ, eSetBits); xTaskNotify(irqHandlerTask, MASK_IRQ, eSetBits);
return 0; return 1; // success
} else }
return 1; // failure
} }
int unmask_user_IRQ() { int unmask_user_IRQ() {

View File

@ -113,7 +113,7 @@ void process_timesync_req(void *taskparameter) {
// begin of time critical section: lock app irq's and I2C bus // begin of time critical section: lock app irq's and I2C bus
if (!mask_user_IRQ()) { if (!mask_user_IRQ()) {
ESP_LOGW(TAG, ESP_LOGW(TAG,
"[%0.3f] Timesync handshake error: irq / i2c masking failed", "[%0.3f] Timesync handshake error: irq masking failed",
millis() / 1000.0); millis() / 1000.0);
goto finish; // failure goto finish; // failure
} }