some function renames for better code readability

This commit is contained in:
Klaus K Wilting 2020-10-04 14:29:57 +02:00
parent 502434abc4
commit 1186b000b6
13 changed files with 40 additions and 33 deletions

View File

@ -61,7 +61,7 @@ const uint8_t bsec_config_iaq[454] = {
// Helper functions declarations // Helper functions declarations
int bme_init(); int bme_init();
void bmecycle(void); void setBMEIRQ(void);
void bme_storedata(bmeStatus_t *bme_store); void bme_storedata(bmeStatus_t *bme_store);
int checkIaqSensorStatus(void); int checkIaqSensorStatus(void);
void loadState(void); void loadState(void);

View File

@ -11,9 +11,9 @@
#include "sds011read.h" #include "sds011read.h"
#include "sdcard.h" #include "sdcard.h"
extern Ticker housekeeper; extern Ticker cyclicTimer;
void housekeeping(void); void setCyclicIRQ(void);
void doHousekeeping(void); void doHousekeeping(void);
uint64_t uptime(void); uint64_t uptime(void);
void reset_counters(void); void reset_counters(void);

View File

@ -26,7 +26,7 @@ extern TaskHandle_t mqttTask;
void mqtt_enqueuedata(MessageBuffer_t *message); void mqtt_enqueuedata(MessageBuffer_t *message);
void mqtt_queuereset(void); void mqtt_queuereset(void);
void mqtt_irq(void); void setMqttIRQ(void);
void mqtt_loop(void); void mqtt_loop(void);
void mqtt_client_task(void *param); void mqtt_client_task(void *param);
int mqtt_connect(const char *my_host, const uint16_t my_port); int mqtt_connect(const char *my_host, const uint16_t my_port);

View File

@ -10,12 +10,12 @@
#include "sdcard.h" #include "sdcard.h"
#include "corona.h" #include "corona.h"
extern Ticker sendcycler; extern Ticker sendTimer;
void SendPayload(uint8_t port, sendprio_t prio); void SendPayload(uint8_t port, sendprio_t prio);
void sendData(void); void sendData(void);
void checkSendQueues(void); void checkSendQueues(void);
void flushQueues(); void flushQueues();
void sendcycle(void); void setSendIRQ(void);
#endif // _SENDDATA_H_ #endif // _SENDDATA_H_

View File

@ -17,7 +17,7 @@ void IRAM_ATTR CLOCKIRQ(void);
void clock_init(void); void clock_init(void);
void clock_loop(void *pvParameters); void clock_loop(void *pvParameters);
void timepulse_start(void); void timepulse_start(void);
void timeSync(void); void setTimeSyncIRQ(void);
uint8_t timepulse_init(void); uint8_t timepulse_init(void);
time_t timeIsValid(time_t const t); time_t timeIsValid(time_t const t);
void calibrateTime(void); void calibrateTime(void);

View File

@ -44,7 +44,7 @@ Adafruit_BMP085 bmp; // I2C
#endif #endif
void bmecycle() { xTaskNotify(irqHandlerTask, BME_IRQ, eSetBits); } void setBMEIRQ() { xTaskNotify(irqHandlerTask, BME_IRQ, eSetBits); }
// initialize BME680 sensor // initialize BME680 sensor
int bme_init(void) { int bme_init(void) {
@ -133,7 +133,7 @@ int bme_init(void) {
finish: finish:
I2C_MUTEX_UNLOCK(); // release i2c bus access I2C_MUTEX_UNLOCK(); // release i2c bus access
if (rc) if (rc)
bmecycler.attach(BMECYCLE, bmecycle); bmecycler.attach(BMECYCLE, setBMEIRQ);
return rc; return rc;
} // bme_init() } // bme_init()

View File

@ -7,13 +7,13 @@
// Local logging tag // Local logging tag
static const char TAG[] = __FILE__; static const char TAG[] = __FILE__;
Ticker housekeeper; Ticker cyclicTimer;
#if (HAS_SDS011) #if (HAS_SDS011)
extern boolean isSDS011Active; extern boolean isSDS011Active;
#endif #endif
void housekeeping() { void setCyclicIRQ() {
xTaskNotifyFromISR(irqHandlerTask, CYCLIC_IRQ, eSetBits, NULL); xTaskNotifyFromISR(irqHandlerTask, CYCLIC_IRQ, eSetBits, NULL);
} }

View File

@ -55,17 +55,24 @@ So don't do it if you do not own a digital oscilloscope.
// Interrupt routines // Interrupt routines
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
irqHandlerTask (Core 1), see irqhandler.cpp
fired by hardware fired by hardware
DisplayIRQ -> esp32 timer 0 -> irqHandlerTask (Core 1) DisplayIRQ -> esp32 timer 0
CLOCKIRQ -> esp32 timer 1 -> ClockTask (Core 1) ButtonIRQ -> external gpio
ButtonIRQ -> external gpio -> irqHandlerTask (Core 1) PMUIRQ -> PMU chip gpio
PMUIRQ -> PMU chip gpio -> irqHandlerTask (Core 1)
fired by software (Ticker.h) fired by software (Ticker.h)
TIMESYNC_IRQ -> timeSync() -> irqHandlerTask (Core 1) TIMESYNC_IRQ -> setTimeSyncIRQ()
CYCLIC_IRQ -> housekeeping() -> irqHandlerTask (Core 1) CYCLIC_IRQ -> setCyclicIRQ()
SENDCYCLE_IRQ -> sendcycle() -> irqHandlerTask (Core 1) SENDCYCLE_IRQ -> setSendIRQ()
BME_IRQ -> bmecycle() -> irqHandlerTask (Core 1) BME_IRQ -> setBMEIRQ()
MQTT_IRQ -> setMqttIRQ()
ClockTask (Core 1), see timekeeper.cpp
fired by hardware
CLOCKIRQ -> esp32 timer 1
// External RTC timer (if present) // External RTC timer (if present)
@ -478,8 +485,8 @@ void setup() {
#endif // HAS_BUTTON #endif // HAS_BUTTON
// cyclic function interrupts // cyclic function interrupts
sendcycler.attach(SENDCYCLE * 2, sendcycle); sendTimer.attach(cfg.sendcycle * 2, setSendIRQ);
housekeeper.attach(HOMECYCLE, housekeeping); cyclicTimer.attach(HOMECYCLE, setCyclicIRQ);
#if (TIME_SYNC_INTERVAL) #if (TIME_SYNC_INTERVAL)

View File

@ -33,7 +33,7 @@ esp_err_t mqtt_init(void) {
SEND_QUEUE_SIZE * PAYLOAD_BUFFER_SIZE); SEND_QUEUE_SIZE * PAYLOAD_BUFFER_SIZE);
ESP_LOGI(TAG, "Starting MQTTloop..."); ESP_LOGI(TAG, "Starting MQTTloop...");
mqttTimer.attach(MQTT_KEEPALIVE, mqtt_irq); mqttTimer.attach(MQTT_KEEPALIVE, setMqttIRQ);
xTaskCreate(mqtt_client_task, "mqttloop", 4096, (void *)NULL, 1, &mqttTask); xTaskCreate(mqtt_client_task, "mqttloop", 4096, (void *)NULL, 1, &mqttTask);
return ESP_OK; return ESP_OK;
@ -183,6 +183,6 @@ void mqtt_loop(void) {
} }
void mqtt_queuereset(void) { xQueueReset(MQTTSendQueue); } void mqtt_queuereset(void) { xQueueReset(MQTTSendQueue); }
void mqtt_irq(void) { xTaskNotify(irqHandlerTask, MQTT_IRQ, eSetBits); } void setMqttIRQ(void) { xTaskNotify(irqHandlerTask, MQTT_IRQ, eSetBits); }
#endif // HAS_MQTT #endif // HAS_MQTT

View File

@ -49,7 +49,7 @@ void set_rssi(uint8_t val[]) {
void set_sendcycle(uint8_t val[]) { void set_sendcycle(uint8_t val[]) {
cfg.sendcycle = val[0]; cfg.sendcycle = val[0];
// update send cycle interrupt [seconds / 2] // update send cycle interrupt [seconds / 2]
sendcycler.attach(cfg.sendcycle * 2, sendcycle); sendTimer.attach(cfg.sendcycle * 2, setSendIRQ);
ESP_LOGI(TAG, "Remote command: set send cycle to %d seconds", ESP_LOGI(TAG, "Remote command: set send cycle to %d seconds",
cfg.sendcycle * 2); cfg.sendcycle * 2);
} }
@ -330,7 +330,7 @@ void get_time(uint8_t val[]) {
void set_time(uint8_t val[]) { void set_time(uint8_t val[]) {
ESP_LOGI(TAG, "Timesync requested by timeserver"); ESP_LOGI(TAG, "Timesync requested by timeserver");
timeSync(); setTimeSyncIRQ();
}; };
void set_flush(uint8_t val[]) { void set_flush(uint8_t val[]) {

View File

@ -1,9 +1,9 @@
// Basic Config // Basic Config
#include "senddata.h" #include "senddata.h"
Ticker sendcycler; Ticker sendTimer;
void sendcycle() { void setSendIRQ() {
xTaskNotifyFromISR(irqHandlerTask, SENDCYCLE_IRQ, eSetBits, NULL); xTaskNotifyFromISR(irqHandlerTask, SENDCYCLE_IRQ, eSetBits, NULL);
} }

View File

@ -23,7 +23,7 @@ HardwareSerial IF482(2); // use UART #2 (#1 may be in use for serial GPS)
Ticker timesyncer; Ticker timesyncer;
void timeSync() { xTaskNotify(irqHandlerTask, TIMESYNC_IRQ, eSetBits); } void setTimeSyncIRQ() { xTaskNotify(irqHandlerTask, TIMESYNC_IRQ, eSetBits); }
void calibrateTime(void) { void calibrateTime(void) {
ESP_LOGD(TAG, "[%0.3f] calibrateTime, timeSource == %d", millis() / 1000.0, ESP_LOGD(TAG, "[%0.3f] calibrateTime, timeSource == %d", millis() / 1000.0,
@ -104,11 +104,11 @@ void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec,
setTime(time_to_set); // set the time on top of second setTime(time_to_set); // set the time on top of second
timeSource = mytimesource; // set global variable timeSource = mytimesource; // set global variable
timesyncer.attach(TIME_SYNC_INTERVAL * 60, timeSync); timesyncer.attach(TIME_SYNC_INTERVAL * 60, setTimeSyncIRQ);
ESP_LOGI(TAG, "[%0.3f] Timesync finished, time was set | source: %c", ESP_LOGI(TAG, "[%0.3f] Timesync finished, time was set | source: %c",
millis() / 1000.0, timeSetSymbols[mytimesource]); millis() / 1000.0, timeSetSymbols[mytimesource]);
} else { } else {
timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, timeSync); timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, setTimeSyncIRQ);
ESP_LOGI(TAG, "[%0.3f] Timesync failed, invalid time fetched | source: %c", ESP_LOGI(TAG, "[%0.3f] Timesync failed, invalid time fetched | source: %c",
millis() / 1000.0, timeSetSymbols[mytimesource]); millis() / 1000.0, timeSetSymbols[mytimesource]);
} }
@ -167,8 +167,8 @@ void timepulse_start(void) {
#endif #endif
// start cyclic time sync // start cyclic time sync
timeSync(); // init systime by RTC or GPS or LORA setTimeSyncIRQ(); // init systime by RTC or GPS or LORA
timesyncer.attach(TIME_SYNC_INTERVAL * 60, timeSync); timesyncer.attach(TIME_SYNC_INTERVAL * 60, setTimeSyncIRQ);
} }
// interrupt service routine triggered by either pps or esp32 hardware timer // interrupt service routine triggered by either pps or esp32 hardware timer

View File

@ -151,7 +151,7 @@ void IRAM_ATTR timesync_processReq(void *taskparameter) {
Fail: Fail:
// set retry timer // set retry timer
timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, timeSync); timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, setTimeSyncIRQ);
Finish: Finish:
// end of time critical section: release app irq lock // end of time critical section: release app irq lock