Micropython supports hardware interrupts, but this is for Pin and since the latest changes also for UART available.
- https://docs.micropython.org/en/latest/ ... ne.Pin.irq
- https://docs.micropython.org/en/latest/ ... e.UART.irq
I2C does not provide Hardware Interrupts. A read and write is run by your code. The read and write operation is blocking until it's done or it raises an OSError if something went wrong.
Just run your code before or after the read/write operation.
Some I2C-slaves do have interrupt pins for the MCU.
The MCP23017 has two interrupt pins, which are driven high, if the MCP23017 is configured right and a pin state has been changed. Then the MCU could react on the interrupt and run a read command via I2C to get the new state of all pins.
Datasheet: https://ww1.microchip.com/downloads/aem ... 001952.pdf
- https://docs.micropython.org/en/latest/ ... ne.Pin.irq
- https://docs.micropython.org/en/latest/ ... e.UART.irq
I2C does not provide Hardware Interrupts. A read and write is run by your code. The read and write operation is blocking until it's done or it raises an OSError if something went wrong.
Just run your code before or after the read/write operation.
Some I2C-slaves do have interrupt pins for the MCU.
The MCP23017 has two interrupt pins, which are driven high, if the MCP23017 is configured right and a pin state has been changed. Then the MCU could react on the interrupt and run a read command via I2C to get the new state of all pins.
Datasheet: https://ww1.microchip.com/downloads/aem ... 001952.pdf
Statistics: Posted by DeaD_EyE — Fri Nov 08, 2024 1:05 pm