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

Fix crash in Servo library when flash caching is disabled (#898)

This commit is contained in:
Ivan Grokhotkov 2015-10-18 22:30:32 +03:00
parent 000e762af3
commit 28890b39e6
2 changed files with 34 additions and 23 deletions

View File

@ -57,7 +57,11 @@ static uint8_t s_servoCount = 0; // the total number of attached s_se
// Interrupt handler template method that takes a class that implements // Interrupt handler template method that takes a class that implements
// a standard set of methods for the timer abstraction // a standard set of methods for the timer abstraction
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
template <class T> void Servo_Handler(T* timer) template <class T>
static void Servo_Handler(T* timer) ICACHE_RAM_ATTR;
template <class T>
static void Servo_Handler(T* timer)
{ {
uint8_t servoIndex; uint8_t servoIndex;
@ -101,15 +105,27 @@ template <class T> void Servo_Handler(T* timer)
} }
} }
static void handler0() ICACHE_RAM_ATTR;
static void handler0()
{
Servo_Handler<ServoTimer0>(&s_servoTimer0);
}
static void handler1() ICACHE_RAM_ATTR;
static void handler1()
{
Servo_Handler<ServoTimer1>(&s_servoTimer1);
}
static void initISR(ServoTimerSequence timerId) static void initISR(ServoTimerSequence timerId)
{ {
#if !defined (SERVO_EXCLUDE_TIMER0) #if !defined (SERVO_EXCLUDE_TIMER0)
if (timerId == ServoTimerSequence_Timer0) if (timerId == ServoTimerSequence_Timer0)
s_servoTimer0.InitInterrupt([]() {Servo_Handler<ServoTimer0>(&s_servoTimer0); }); s_servoTimer0.InitInterrupt(&handler0);
#endif #endif
#if !defined (SERVO_EXCLUDE_TIMER1) #if !defined (SERVO_EXCLUDE_TIMER1)
if (timerId == ServoTimerSequence_Timer1) if (timerId == ServoTimerSequence_Timer1)
s_servoTimer1.InitInterrupt([]() {Servo_Handler<ServoTimer1>(&s_servoTimer1); }); s_servoTimer1.InitInterrupt(&handler1);
#endif #endif
} }
@ -243,4 +259,3 @@ bool Servo::attached()
} }
#endif #endif

View File

@ -221,7 +221,3 @@ private:
}; };
#endif #endif