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
int bme_init();
void bmecycle(void);
void setBMEIRQ(void);
void bme_storedata(bmeStatus_t *bme_store);
int checkIaqSensorStatus(void);
void loadState(void);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,13 +7,13 @@
// Local logging tag
static const char TAG[] = __FILE__;
Ticker housekeeper;
Ticker cyclicTimer;
#if (HAS_SDS011)
extern boolean isSDS011Active;
#endif
void housekeeping() {
void setCyclicIRQ() {
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
-------------------------------------------------------------------------------
irqHandlerTask (Core 1), see irqhandler.cpp
fired by hardware
DisplayIRQ -> esp32 timer 0 -> irqHandlerTask (Core 1)
CLOCKIRQ -> esp32 timer 1 -> ClockTask (Core 1)
ButtonIRQ -> external gpio -> irqHandlerTask (Core 1)
PMUIRQ -> PMU chip gpio -> irqHandlerTask (Core 1)
DisplayIRQ -> esp32 timer 0
ButtonIRQ -> external gpio
PMUIRQ -> PMU chip gpio
fired by software (Ticker.h)
TIMESYNC_IRQ -> timeSync() -> irqHandlerTask (Core 1)
CYCLIC_IRQ -> housekeeping() -> irqHandlerTask (Core 1)
SENDCYCLE_IRQ -> sendcycle() -> irqHandlerTask (Core 1)
BME_IRQ -> bmecycle() -> irqHandlerTask (Core 1)
TIMESYNC_IRQ -> setTimeSyncIRQ()
CYCLIC_IRQ -> setCyclicIRQ()
SENDCYCLE_IRQ -> setSendIRQ()
BME_IRQ -> setBMEIRQ()
MQTT_IRQ -> setMqttIRQ()
ClockTask (Core 1), see timekeeper.cpp
fired by hardware
CLOCKIRQ -> esp32 timer 1
// External RTC timer (if present)
@ -478,8 +485,8 @@ void setup() {
#endif // HAS_BUTTON
// cyclic function interrupts
sendcycler.attach(SENDCYCLE * 2, sendcycle);
housekeeper.attach(HOMECYCLE, housekeeping);
sendTimer.attach(cfg.sendcycle * 2, setSendIRQ);
cyclicTimer.attach(HOMECYCLE, setCyclicIRQ);
#if (TIME_SYNC_INTERVAL)

View File

@ -33,7 +33,7 @@ esp_err_t mqtt_init(void) {
SEND_QUEUE_SIZE * PAYLOAD_BUFFER_SIZE);
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);
return ESP_OK;
@ -183,6 +183,6 @@ void mqtt_loop(void) {
}
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

View File

@ -49,7 +49,7 @@ void set_rssi(uint8_t val[]) {
void set_sendcycle(uint8_t val[]) {
cfg.sendcycle = val[0];
// 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",
cfg.sendcycle * 2);
}
@ -330,7 +330,7 @@ void get_time(uint8_t val[]) {
void set_time(uint8_t val[]) {
ESP_LOGI(TAG, "Timesync requested by timeserver");
timeSync();
setTimeSyncIRQ();
};
void set_flush(uint8_t val[]) {

View File

@ -1,9 +1,9 @@
// Basic Config
#include "senddata.h"
Ticker sendcycler;
Ticker sendTimer;
void sendcycle() {
void setSendIRQ() {
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;
void timeSync() { xTaskNotify(irqHandlerTask, TIMESYNC_IRQ, eSetBits); }
void setTimeSyncIRQ() { xTaskNotify(irqHandlerTask, TIMESYNC_IRQ, eSetBits); }
void calibrateTime(void) {
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
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",
millis() / 1000.0, timeSetSymbols[mytimesource]);
} 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",
millis() / 1000.0, timeSetSymbols[mytimesource]);
}
@ -167,8 +167,8 @@ void timepulse_start(void) {
#endif
// start cyclic time sync
timeSync(); // init systime by RTC or GPS or LORA
timesyncer.attach(TIME_SYNC_INTERVAL * 60, timeSync);
setTimeSyncIRQ(); // init systime by RTC or GPS or LORA
timesyncer.attach(TIME_SYNC_INTERVAL * 60, setTimeSyncIRQ);
}
// 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:
// set retry timer
timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, timeSync);
timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, setTimeSyncIRQ);
Finish:
// end of time critical section: release app irq lock