2015-09-23 22:58:34 +00:00
|
|
|
/* ESP8266 Xtensa interrupt management functions
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Part of esp-open-rtos
|
|
|
|
* Copyright (C) 2015 Angus Gratton
|
|
|
|
* BSD Licensed as described in the file LICENSE
|
|
|
|
*/
|
|
|
|
#include <esp/interrupts.h>
|
|
|
|
|
|
|
|
_xt_isr isr[16];
|
|
|
|
|
|
|
|
void IRAM _xt_isr_attach(uint8_t i, _xt_isr func)
|
|
|
|
{
|
|
|
|
isr[i] = func;
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:17:07 +00:00
|
|
|
/* Generic ISR handler.
|
|
|
|
|
|
|
|
Handles all flags set for interrupts in 'intset'.
|
2015-09-23 22:58:34 +00:00
|
|
|
*/
|
2015-09-24 00:17:07 +00:00
|
|
|
uint16_t IRAM _xt_isr_handler(uint16_t intset)
|
2015-09-23 22:58:34 +00:00
|
|
|
{
|
2015-09-24 00:17:07 +00:00
|
|
|
/* WDT has highest priority (occasional WDT resets otherwise) */
|
|
|
|
if(intset & BIT(INUM_WDT)) {
|
|
|
|
_xt_clear_ints(BIT(INUM_WDT));
|
|
|
|
isr[INUM_WDT]();
|
|
|
|
intset -= BIT(INUM_WDT);
|
2015-09-23 22:58:34 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:17:07 +00:00
|
|
|
while(intset) {
|
|
|
|
uint8_t index = __builtin_ffs(intset) - 1;
|
|
|
|
uint16_t mask = BIT(index);
|
|
|
|
_xt_clear_ints(mask);
|
|
|
|
isr[index]();
|
|
|
|
intset -= mask;
|
2015-09-23 22:58:34 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:17:07 +00:00
|
|
|
return 0;
|
2015-09-23 22:58:34 +00:00
|
|
|
}
|