Timer bugfix (issue #145 #148)

This commit is contained in:
Klaus K Wilting 2018-09-21 12:25:52 +02:00
parent ebc3aac991
commit 67832da09d
4 changed files with 23 additions and 22 deletions

View File

@ -63,7 +63,7 @@ void gps_loop(void *pvParameters) {
#endif
} // if (cfg.gpsmode)
vTaskDelay(2 / portTICK_PERIOD_MS); // reset watchdog
vTaskDelay(2 / portTICK_PERIOD_MS); // yield to CPU
} // end of infinite loop

View File

@ -248,7 +248,7 @@ void lorawan_loop(void *pvParameters) {
while (1) {
os_runloop_once(); // execute LMIC jobs
vTaskDelay(2 / portTICK_PERIOD_MS); // reset watchdog
vTaskDelay(2 / portTICK_PERIOD_MS); // yield to CPU
}
}

View File

@ -236,19 +236,22 @@ void setup() {
channelSwitch = timerBegin(1, 800, true);
timerAttachInterrupt(channelSwitch, &ChannelSwitchIRQ, true);
timerAlarmWrite(channelSwitch, cfg.wifichancycle * 1000, true);
timerAlarmEnable(channelSwitch);
//ESP_LOGI(TAG, "chanelswitch alarm threshold %d", cfg.wifichancycle * 1000);
// setup send cycle trigger IRQ using esp32 hardware timer 2
sendCycle = timerBegin(2, 8000, true);
timerAttachInterrupt(sendCycle, &SendCycleIRQ, true);
timerAlarmWrite(sendCycle, cfg.sendcycle * 2 * 10000, true);
timerAlarmEnable(sendCycle);
// setup house keeping cycle trigger IRQ using esp32 hardware timer 3
homeCycle = timerBegin(3, 8000, true);
timerAttachInterrupt(homeCycle, &homeCycleIRQ, true);
timerAlarmWrite(homeCycle, HOMECYCLE * 10000, true);
//enable timers, caution: order is critical here
timerAlarmEnable(homeCycle);
timerAlarmEnable(sendCycle);
timerAlarmEnable(channelSwitch);
// show payload encoder
#if PAYLOAD_ENCODER == 1
@ -324,33 +327,31 @@ void setup() {
void loop() {
while (1) {
// state machine for switching display, LED, button, housekeeping,
// senddata
// state machine for switching display, LED, button, housekeeping,
// senddata
#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
led_loop();
led_loop();
#endif
#ifdef HAS_BUTTON
readButton();
readButton();
#endif
#ifdef HAS_DISPLAY
updateDisplay();
updateDisplay();
#endif
// check housekeeping cycle and if expired do homework
checkHousekeeping();
// check send queue and process it
processSendBuffer();
// check send cycle and enqueue payload if cycle is expired
sendPayload();
// reset watchdog
vTaskDelay(2 / portTICK_PERIOD_MS);
// check housekeeping cycle and if expired do homework
checkHousekeeping();
// check send queue and process it
processSendBuffer();
// check send cycle and enqueue payload if cycle is expired
sendPayload();
// yield to CPU
vTaskDelay(2 / portTICK_PERIOD_MS);
} // loop()
}
} // loop()
/* end Arduino main loop
* ------------------------------------------------------------ */

View File

@ -58,10 +58,10 @@ void wifi_channel_loop(void *pvParameters) {
channel = (channel % WIFI_CHANNEL_MAX) + 1;
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
ESP_LOGD(TAG, "Wifi set channel %d", channel);
vTaskDelay(2 / portTICK_PERIOD_MS); // reset watchdog
}
vTaskDelay(2 / portTICK_PERIOD_MS); // yield to CPU
} // end of infinite wifi channel rotation loop
}