From ae92bf377d0ee12293e764eaef5b03c86e83178a Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Thu, 4 Oct 2018 22:59:02 +0200 Subject: [PATCH] code sanitization --- src/button.h | 1 - src/cyclic.h | 1 - src/display.h | 1 - src/irqhandler.h | 17 +++++++++++++---- src/main.cpp | 11 +++++++++-- src/senddata.h | 1 - src/wifiscan.h | 1 - 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/button.h b/src/button.h index bae8e6b5..a7555c0a 100644 --- a/src/button.h +++ b/src/button.h @@ -3,7 +3,6 @@ #include "senddata.h" -void IRAM_ATTR ButtonIRQ(); void readButton(); #endif \ No newline at end of file diff --git a/src/cyclic.h b/src/cyclic.h index d8ee73b2..6b1e8d73 100644 --- a/src/cyclic.h +++ b/src/cyclic.h @@ -5,7 +5,6 @@ #include "senddata.h" void doHousekeeping(void); -void IRAM_ATTR homeCycleIRQ(void); uint64_t uptime(void); void reset_counters(void); int redirect_log(const char *fmt, va_list args); diff --git a/src/display.h b/src/display.h index 84ff9b7a..492af565 100644 --- a/src/display.h +++ b/src/display.h @@ -9,6 +9,5 @@ extern HAS_DISPLAY u8x8; void init_display(const char *Productname, const char *Version); void refreshtheDisplay(void); void DisplayKey(const uint8_t *key, uint8_t len, bool lsb); -void IRAM_ATTR DisplayIRQ(void); #endif \ No newline at end of file diff --git a/src/irqhandler.h b/src/irqhandler.h index fab9bee1..674d825b 100644 --- a/src/irqhandler.h +++ b/src/irqhandler.h @@ -1,10 +1,10 @@ #ifndef _IRQHANDLER_H #define _IRQHANDLER_H -#define DISPLAY_IRQ 0x01 -#define BUTTON_IRQ 0x02 -#define SENDPAYLOAD_IRQ 0x04 -#define CYCLIC_IRQ 0x08 +#define DISPLAY_IRQ 0x01 +#define BUTTON_IRQ 0x02 +#define SENDPAYLOAD_IRQ 0x04 +#define CYCLIC_IRQ 0x08 #include "globals.h" #include "cyclic.h" @@ -14,5 +14,14 @@ #include "senddata.h" void irqHandler(void *pvParameters); +void IRAM_ATTR ChannelSwitchIRQ(); +void IRAM_ATTR homeCycleIRQ(); +void IRAM_ATTR SendCycleIRQ(); +#ifdef HAS_DISPLAY +void IRAM_ATTR DisplayIRQ(); +#endif +#ifdef HAS_BUTTON +void IRAM_ATTR ButtonIRQ(); +#endif #endif diff --git a/src/main.cpp b/src/main.cpp index abc94c9e..4268bb3a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -140,12 +140,10 @@ void setup() { strcat_P(features, "PU"); // install button interrupt (pullup mode) pinMode(HAS_BUTTON, INPUT_PULLUP); - attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), ButtonIRQ, RISING); #else strcat_P(features, "PD"); // install button interrupt (pulldown mode) pinMode(HAS_BUTTON, INPUT_PULLDOWN); - attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), ButtonIRQ, FALLING); #endif // BUTTON_PULLUP #endif // HAS_BUTTON @@ -346,6 +344,15 @@ void setup() { timerAlarmEnable(homeCycle); timerAlarmEnable(channelSwitch); + // start button interrupt +#ifdef HAS_BUTTON +#ifdef BUTTON_PULLUP + attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), ButtonIRQ, RISING); +#else + attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), ButtonIRQ, FALLING); +#endif +#endif // HAS_BUTTON + } // setup() void loop() { diff --git a/src/senddata.h b/src/senddata.h index fc236b5f..07819609 100644 --- a/src/senddata.h +++ b/src/senddata.h @@ -3,7 +3,6 @@ void SendData(uint8_t port); void sendPayload(void); -void IRAM_ATTR SendCycleIRQ(void); void checkSendQueues(void); void flushQueues(); diff --git a/src/wifiscan.h b/src/wifiscan.h index 48c218a1..9ad06422 100644 --- a/src/wifiscan.h +++ b/src/wifiscan.h @@ -27,7 +27,6 @@ typedef struct { void wifi_sniffer_init(void); void IRAM_ATTR wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type); -void IRAM_ATTR ChannelSwitchIRQ(void); void switchWifiChannel(void * parameter); #endif \ No newline at end of file