piface / libpifacedigital

A simple C library for controlling PiFace Digital.
GNU General Public License v3.0
16 stars 10 forks source link

Added interrupt support with enhanced & commented example #2

Closed scm6079 closed 10 years ago

scm6079 commented 10 years ago

Added interrupt support, including GPIO interrupt export to userspace and blocking input read method. Commented example program and included simple example efficient wait for input method.

tompreston commented 10 years ago

Thank you. I'll test it next time I'm near a PiFace Digital. Before I merge it though, I have a few ideas:

  1. The interrupt logic should be inside the libmcp23s17 library since it's a feature specific to that microcontroller and not PiFace Digital. This would means that PiFace Control and Display (and anyone else wanting to use an MCP23S17) would also benefit from your code. Your functions would remain in libpifacedigital but they would call parent functions in libmcp23s17.
  2. What do you think about adding in a pifacedigital_disable_interrupts function? The idea sprung to mind however I can't really see people disabling and enabling interrupts throughout their program. Does the interrupts logic require cleaning up?
scm6079 commented 10 years ago

Not bad ideas -- I don't have a PiFace C&D -- so I'll let you add them to that module since I have no way to test. I'll add interrupt enable + disable methods to the libmcp23s17 and issue a new pull request for both libs.

tompreston commented 10 years ago

Just an FYI, I changed the order of the arguments for the wait function for consistency with the rest of the library. hw_addr always comes last.

uint8_t pifacedigital_wait_for_input(uint8_t hw_addr, int timeout)

to

uint8_t pifacedigital_wait_for_input(int timeout, uint8_t hw_addr)