mirror of https://github.com/arendst/Tasmota.git
The latest core file updates
This commit is contained in:
parent
9c74a4a041
commit
e6f95fcace
|
@ -105,12 +105,15 @@ extern int ICACHE_RAM_ATTR __digitalRead(uint8_t pin) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef void (*voidFuncPtr)(void);
|
typedef void (*voidFuncPtr)(void);
|
||||||
|
typedef void (*voidFuncPtrArg)(void*);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t mode;
|
uint8_t mode;
|
||||||
void (*fn)(void);
|
void (*fn)(void);
|
||||||
|
void * arg;
|
||||||
} interrupt_handler_t;
|
} interrupt_handler_t;
|
||||||
|
|
||||||
|
|
||||||
static interrupt_handler_t interrupt_handlers[16];
|
static interrupt_handler_t interrupt_handlers[16];
|
||||||
static uint32_t interrupt_reg = 0;
|
static uint32_t interrupt_reg = 0;
|
||||||
|
|
||||||
|
@ -133,33 +136,51 @@ void ICACHE_RAM_ATTR interrupt_handler(void *arg) {
|
||||||
// to make ISR compatible to Arduino AVR model where interrupts are disabled
|
// to make ISR compatible to Arduino AVR model where interrupts are disabled
|
||||||
// we disable them before we call the client ISR
|
// we disable them before we call the client ISR
|
||||||
uint32_t savedPS = xt_rsil(15); // stop other interrupts
|
uint32_t savedPS = xt_rsil(15); // stop other interrupts
|
||||||
|
if (handler->arg)
|
||||||
|
{
|
||||||
|
((voidFuncPtrArg)handler->fn)(handler->arg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
handler->fn();
|
handler->fn();
|
||||||
|
}
|
||||||
xt_wsr_ps(savedPS);
|
xt_wsr_ps(savedPS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ETS_GPIO_INTR_ENABLE();
|
ETS_GPIO_INTR_ENABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void ICACHE_RAM_ATTR __attachInterrupt(uint8_t pin, voidFuncPtr userFunc, int mode) {
|
extern void ICACHE_RAM_ATTR __attachInterruptArg(uint8_t pin, voidFuncPtr userFunc, void *arg, int mode) {
|
||||||
if(pin < 16) {
|
if(pin < 16) {
|
||||||
|
ETS_GPIO_INTR_DISABLE();
|
||||||
interrupt_handler_t *handler = &interrupt_handlers[pin];
|
interrupt_handler_t *handler = &interrupt_handlers[pin];
|
||||||
handler->mode = mode;
|
handler->mode = mode;
|
||||||
handler->fn = userFunc;
|
handler->fn = userFunc;
|
||||||
|
handler->arg = arg;
|
||||||
interrupt_reg |= (1 << pin);
|
interrupt_reg |= (1 << pin);
|
||||||
GPC(pin) &= ~(0xF << GPCI);//INT mode disabled
|
GPC(pin) &= ~(0xF << GPCI);//INT mode disabled
|
||||||
GPIEC = (1 << pin); //Clear Interrupt for this pin
|
GPIEC = (1 << pin); //Clear Interrupt for this pin
|
||||||
GPC(pin) |= ((mode & 0xF) << GPCI);//INT mode "mode"
|
GPC(pin) |= ((mode & 0xF) << GPCI);//INT mode "mode"
|
||||||
|
ETS_GPIO_INTR_ENABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void ICACHE_RAM_ATTR __attachInterrupt(uint8_t pin, voidFuncPtr userFunc, int mode )
|
||||||
|
{
|
||||||
|
__attachInterruptArg (pin, userFunc, 0, mode);
|
||||||
|
}
|
||||||
|
|
||||||
extern void ICACHE_RAM_ATTR __detachInterrupt(uint8_t pin) {
|
extern void ICACHE_RAM_ATTR __detachInterrupt(uint8_t pin) {
|
||||||
if(pin < 16) {
|
if(pin < 16) {
|
||||||
|
ETS_GPIO_INTR_DISABLE();
|
||||||
GPC(pin) &= ~(0xF << GPCI);//INT mode disabled
|
GPC(pin) &= ~(0xF << GPCI);//INT mode disabled
|
||||||
GPIEC = (1 << pin); //Clear Interrupt for this pin
|
GPIEC = (1 << pin); //Clear Interrupt for this pin
|
||||||
interrupt_reg &= ~(1 << pin);
|
interrupt_reg &= ~(1 << pin);
|
||||||
interrupt_handler_t *handler = &interrupt_handlers[pin];
|
interrupt_handler_t *handler = &interrupt_handlers[pin];
|
||||||
handler->mode = 0;
|
handler->mode = 0;
|
||||||
handler->fn = 0;
|
handler->fn = 0;
|
||||||
|
handler->arg = 0;
|
||||||
|
ETS_GPIO_INTR_ENABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,3 +207,4 @@ extern void digitalWrite(uint8_t pin, uint8_t val) __attribute__ ((weak, alias("
|
||||||
extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead")));
|
extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead")));
|
||||||
extern void attachInterrupt(uint8_t pin, voidFuncPtr handler, int mode) __attribute__ ((weak, alias("__attachInterrupt")));
|
extern void attachInterrupt(uint8_t pin, voidFuncPtr handler, int mode) __attribute__ ((weak, alias("__attachInterrupt")));
|
||||||
extern void detachInterrupt(uint8_t pin) __attribute__ ((weak, alias("__detachInterrupt")));
|
extern void detachInterrupt(uint8_t pin) __attribute__ ((weak, alias("__detachInterrupt")));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue