HomeACcessoryKid / ESP8266-HomeKit-Demo

User part of the ESP8266-HomeKit foundation
https://www.youtube.com/watch?v=Xnr-utWDIR8
Apache License 2.0
125 stars 27 forks source link

Possible issue in GPIO.C #34

Closed maccoylton closed 6 years ago

maccoylton commented 6 years ago

Hi, working on a motion detector and I believe there may be a flaw in the logic of GPIO.C

in GPIO.C function gpio_intr_handler, should this line

    if ( (0x1<<i) & gpio_status & gpio_intr_callbacks[i]!= NULL ){

not be

   if ( (0x1<<i) & gpio_status && gpio_intr_callbacks[i]!= NULL ){

i.e. the second and should be a logical and, not a bitwise and. I was having problems getting interrupts to fire, so I added some debug trace, with the original I get this:-

checking GPIO 2, 0x1<<i=4 , gpio_status=4, callback=4024c940
no match

with the revised code I get:-

checking GPIO 2, 0x1<<i=4 , gpio_status=4, callback=4024c940
called interupt handler for GPIO 2

TIA for your thoughts

HomeACcessoryKid commented 6 years ago

Good catch. That bit of code was never tested to the fullest since it was in response to a request to show a button work. I've pushed code just now.