further fixes irq mask & i2c lock
This commit is contained in:
parent
95faea9e71
commit
4a2845a3f6
@ -42,7 +42,7 @@
|
|||||||
#define SCREEN_MODE (0x80)
|
#define SCREEN_MODE (0x80)
|
||||||
|
|
||||||
// I2C bus access control
|
// I2C bus access control
|
||||||
#define I2C_MUTEX_LOCK() (xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == pdTRUE)
|
#define I2C_MUTEX_LOCK() (xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(2000)) == pdTRUE)
|
||||||
#define I2C_MUTEX_UNLOCK() (xSemaphoreGive(I2Caccess))
|
#define I2C_MUTEX_UNLOCK() (xSemaphoreGive(I2Caccess))
|
||||||
|
|
||||||
// Struct holding devices's runtime configuration
|
// Struct holding devices's runtime configuration
|
||||||
|
@ -510,12 +510,12 @@ void IRAM_ATTR user_request_network_time_callback(void *pVoidUserUTCTime,
|
|||||||
// begin of time critical section
|
// begin of time critical section
|
||||||
|
|
||||||
// lock I2C bus and application irq to ensure accurate timing
|
// lock I2C bus and application irq to ensure accurate timing
|
||||||
|
mask_user_IRQ();
|
||||||
if (!I2C_MUTEX_LOCK()) {
|
if (!I2C_MUTEX_LOCK()) {
|
||||||
ESP_LOGW(TAG, "[%0.3f] Timesync handshake error: i2c bus locking failed",
|
ESP_LOGW(TAG, "[%0.3f] Timesync handshake error: i2c bus locking failed",
|
||||||
millis() / 1000.0);
|
millis() / 1000.0);
|
||||||
goto finish; // failure
|
goto finish; // failure
|
||||||
}
|
}
|
||||||
mask_user_IRQ();
|
|
||||||
|
|
||||||
// Update userUTCTime, considering the difference between the GPS and UTC
|
// Update userUTCTime, considering the difference between the GPS and UTC
|
||||||
// time, and the leap seconds until year 2019
|
// time, and the leap seconds until year 2019
|
||||||
|
@ -64,7 +64,7 @@ void process_timesync_req(void *taskparameter) {
|
|||||||
|
|
||||||
// wait until we are joined if we are not
|
// wait until we are joined if we are not
|
||||||
while (!LMIC.devaddr) {
|
while (!LMIC.devaddr) {
|
||||||
vTaskDelay(1000);
|
vTaskDelay(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect timestamp samples
|
// collect timestamp samples
|
||||||
@ -111,12 +111,12 @@ void process_timesync_req(void *taskparameter) {
|
|||||||
} // end of for loop to collect timestamp samples
|
} // end of for loop to collect timestamp samples
|
||||||
|
|
||||||
// lock I2C bus and application irq to ensure accurate timing
|
// lock I2C bus and application irq to ensure accurate timing
|
||||||
|
mask_user_IRQ();
|
||||||
if (!I2C_MUTEX_LOCK()) {
|
if (!I2C_MUTEX_LOCK()) {
|
||||||
ESP_LOGW(TAG, "[%0.3f] Timesync handshake error: i2c bus locking failed",
|
ESP_LOGW(TAG, "[%0.3f] Timesync handshake error: i2c bus locking failed",
|
||||||
millis() / 1000.0);
|
millis() / 1000.0);
|
||||||
goto finish; // failure
|
goto finish; // failure
|
||||||
}
|
}
|
||||||
mask_user_IRQ();
|
|
||||||
|
|
||||||
// average time offset over all collected diffs
|
// average time offset over all collected diffs
|
||||||
time_offset_ms /= TIME_SYNC_SAMPLES;
|
time_offset_ms /= TIME_SYNC_SAMPLES;
|
||||||
|
Loading…
Reference in New Issue
Block a user