1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Make stopWaveform call interrupt callable (#5248)

* 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

* 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).
This commit is contained in:
Earle F. Philhower, III 2018-10-16 16:39:22 -07:00 committed by GitHub
parent 2eb5b5600a
commit d742df84e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
@ -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;