Move all Rotary interrupt code to iRAM

Move all Rotary interrupt code to iRAM (#7410)
This commit is contained in:
Theo Arends 2020-01-03 17:07:40 +01:00
parent 8c2ff7237e
commit b82d1fdcc3

View File

@ -36,17 +36,21 @@ struct ROTARY {
/********************************************************************************************/ /********************************************************************************************/
void update_position(void) #ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
{ void update_rotary(void) ICACHE_RAM_ATTR;
uint8_t s; #endif // ARDUINO_ESP8266_RELEASE_2_3_0
void update_rotary(void)
{
if (MI_DESK_LAMP == my_module_type) {
if (LightPower()) {
/* /*
* https://github.com/PaulStoffregen/Encoder/blob/master/Encoder.h * https://github.com/PaulStoffregen/Encoder/blob/master/Encoder.h
*/ */
s = Rotary.state & 3; uint8_t s = Rotary.state & 3;
if (digitalRead(pin[GPIO_ROT1A])) s |= 4; if (digitalRead(pin[GPIO_ROT1A])) { s |= 4; }
if (digitalRead(pin[GPIO_ROT1B])) s |= 8; if (digitalRead(pin[GPIO_ROT1B])) { s |= 8; }
switch (s) { switch (s) {
case 0: case 5: case 10: case 15: case 0: case 5: case 10: case 15:
break; break;
@ -60,17 +64,6 @@ void update_position(void)
Rotary.position = Rotary.position - 2; break; Rotary.position = Rotary.position - 2; break;
} }
Rotary.state = (s >> 2); Rotary.state = (s >> 2);
}
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
void update_rotary(void) ICACHE_RAM_ATTR;
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
void update_rotary(void)
{
if (MI_DESK_LAMP == my_module_type){
if (LightPower()) {
update_position();
} }
} }
} }