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
1 changed files with 21 additions and 28 deletions

View File

@ -36,17 +36,21 @@ struct ROTARY {
/********************************************************************************************/
void update_position(void)
{
uint8_t s;
#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()) {
/*
* https://github.com/PaulStoffregen/Encoder/blob/master/Encoder.h
*/
s = Rotary.state & 3;
if (digitalRead(pin[GPIO_ROT1A])) s |= 4;
if (digitalRead(pin[GPIO_ROT1B])) s |= 8;
uint8_t s = Rotary.state & 3;
if (digitalRead(pin[GPIO_ROT1A])) { s |= 4; }
if (digitalRead(pin[GPIO_ROT1B])) { s |= 8; }
switch (s) {
case 0: case 5: case 10: case 15:
break;
@ -60,17 +64,6 @@ void update_position(void)
Rotary.position = Rotary.position - 2; break;
}
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();
}
}
}