Skip to content

Commit e073d28

Browse files
committed
Merge pull request esp8266#1108 from me-no-dev/master
Get pin levels at point of interrupt
2 parents 14949f5 + 466fa6f commit e073d28

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cores/esp8266/core_esp8266_wiring_digital.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ static uint32_t interrupt_reg = 0;
111111

112112
void interrupt_handler(void *arg) {
113113
uint32_t status = GPIE;
114+
uint32_t levels = GPI;
114115
GPIEC = status;//clear them interrupts
115116
if(status == 0 || interrupt_reg == 0) return;
116117
ETS_GPIO_INTR_DISABLE();
@@ -122,7 +123,7 @@ void interrupt_handler(void *arg) {
122123
interrupt_handler_t *handler = &interrupt_handlers[i];
123124
if (handler->fn &&
124125
(handler->mode == CHANGE ||
125-
(handler->mode & 1) == digitalRead(i))) {
126+
(handler->mode & 1) == !!(levels & (1 << i)))) {
126127
// to make ISR compatible to Arduino AVR model where interrupts are disabled
127128
// we disable them before we call the client ISR
128129
uint32_t savedPS = xt_rsil(15); // stop other interrupts

0 commit comments

Comments
 (0)