commit
051977a25a
@ -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(2000)) == pdTRUE)
|
#define I2C_MUTEX_LOCK() (xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == 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
|
||||||
|
@ -41,9 +41,6 @@ IDLE 1 0 ESP32 arduino scheduler -> runs wifi channel rotator
|
|||||||
|
|
||||||
Low priority numbers denote low priority tasks.
|
Low priority numbers denote low priority tasks.
|
||||||
|
|
||||||
Tasks using i2c bus all must have same priority, because using mutex semaphore
|
|
||||||
(irqhandler, bmeloop)
|
|
||||||
|
|
||||||
NOTE: Changing any timings will have impact on time accuracy of whole code.
|
NOTE: Changing any timings will have impact on time accuracy of whole code.
|
||||||
So don't do it if you do not own a digital oscilloscope.
|
So don't do it if you do not own a digital oscilloscope.
|
||||||
|
|
||||||
|
@ -65,6 +65,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(pdMS_TO_TICKS(3000));
|
vTaskDelay(pdMS_TO_TICKS(3000));
|
||||||
|
}
|
||||||
|
|
||||||
// collect timestamp samples
|
// collect timestamp samples
|
||||||
for (uint8_t i = 0; i < TIME_SYNC_SAMPLES; i++) {
|
for (uint8_t i = 0; i < TIME_SYNC_SAMPLES; i++) {
|
||||||
@ -111,11 +112,11 @@ void process_timesync_req(void *taskparameter) {
|
|||||||
|
|
||||||
// lock I2C bus and application irq to ensure accurate timing
|
// lock I2C bus and application irq to ensure accurate timing
|
||||||
mask_user_IRQ();
|
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
|
||||||
}
|
//}
|
||||||
|
|
||||||
// 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;
|
||||||
@ -136,7 +137,7 @@ void process_timesync_req(void *taskparameter) {
|
|||||||
|
|
||||||
finish:
|
finish:
|
||||||
// end of time critical section: release I2C bus and app irq
|
// end of time critical section: release I2C bus and app irq
|
||||||
I2C_MUTEX_UNLOCK();
|
//I2C_MUTEX_UNLOCK();
|
||||||
unmask_user_IRQ();
|
unmask_user_IRQ();
|
||||||
|
|
||||||
timeSyncPending = false;
|
timeSyncPending = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user