From d7eaf77a2e01613c006aeb39fa4035e88c8bd41d Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sun, 14 Oct 2018 12:40:55 -0700 Subject: [PATCH 1/2] Make stopWaveform call interrupt callable Match the behavior of pre-2.4.2 PWM by allowing stopWaveform to be called from an interrupt. Fixes #5247 --- cores/esp8266/core_esp8266_waveform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/esp8266/core_esp8266_waveform.c b/cores/esp8266/core_esp8266_waveform.c index fea483343a..3b9cdbee88 100644 --- a/cores/esp8266/core_esp8266_waveform.c +++ b/cores/esp8266/core_esp8266_waveform.c @@ -137,7 +137,7 @@ static void initTimer() { timerRunning = true; } -static void deinitTimer() { +static void ICACHE_RAM_ATTR deinitTimer() { timer1_attachInterrupt(NULL); timer1_disable(); timer1_isr_init(); @@ -202,7 +202,7 @@ int startWaveform(uint8_t pin, uint32_t timeHighUS, uint32_t timeLowUS, uint32_t } // Stops a waveform on a pin -int stopWaveform(uint8_t pin) { +int ICACHE_RAM_ATTR stopWaveform(uint8_t pin) { // Can't possibly need to stop anything if there is no timer active if (!timerRunning) { return false; From 0d4208f36f503c4ffdb984c116fb8aef5b591d5c Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 16 Oct 2018 11:12:11 -0700 Subject: [PATCH 2/2] Move to O2, save ~500 bytes of code The actual runtime difference of -O2 vs -O3 is quite small, but -O3 takes ~500 more bytes of code (~300 more in IRAM, ~200 more in PMEM). --- cores/esp8266/core_esp8266_waveform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/core_esp8266_waveform.c b/cores/esp8266/core_esp8266_waveform.c index 3b9cdbee88..04422ef511 100644 --- a/cores/esp8266/core_esp8266_waveform.c +++ b/cores/esp8266/core_esp8266_waveform.c @@ -41,7 +41,7 @@ #include "core_esp8266_waveform.h" // Need speed, not size, here -#pragma GCC optimize ("O3") +#pragma GCC optimize ("O2") // Maximum delay between IRQs #define MAXIRQUS (10000)