bugfixing mutex lock
This commit is contained in:
		
							parent
							
								
									31c0037cba
								
							
						
					
					
						commit
						7d2d753252
					
				@ -62,8 +62,9 @@ void DisplayKey(const uint8_t *key, uint8_t len, bool lsb) {
 | 
			
		||||
void init_display(const char *Productname, const char *Version) {
 | 
			
		||||
 | 
			
		||||
  // 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
 | 
			
		||||
    uint8_t buf[32];
 | 
			
		||||
    u8x8.begin();
 | 
			
		||||
@ -141,8 +142,9 @@ void refreshTheDisplay(bool nextPage) {
 | 
			
		||||
      myTZ.toLocal(now()); // note: call now() here *before* locking mutex!
 | 
			
		||||
 | 
			
		||||
  // 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
 | 
			
		||||
    if (DisplayIsOn != cfg.screenon) {
 | 
			
		||||
      DisplayIsOn = cfg.screenon;
 | 
			
		||||
 | 
			
		||||
@ -120,12 +120,13 @@ void IRAM_ATTR GpsIRQ() {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
    return 0;
 | 
			
		||||
  } else
 | 
			
		||||
    return 1; // failure
 | 
			
		||||
    return 1; // success
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int unmask_user_IRQ() {
 | 
			
		||||
 | 
			
		||||
@ -113,7 +113,7 @@ void process_timesync_req(void *taskparameter) {
 | 
			
		||||
    // begin of time critical section: lock app irq's and I2C bus
 | 
			
		||||
    if (!mask_user_IRQ()) {
 | 
			
		||||
      ESP_LOGW(TAG,
 | 
			
		||||
               "[%0.3f] Timesync handshake error: irq / i2c masking failed",
 | 
			
		||||
               "[%0.3f] Timesync handshake error: irq masking failed",
 | 
			
		||||
               millis() / 1000.0);
 | 
			
		||||
      goto finish; // failure
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user