Author | Sebastien Lelong, Joep Suijs, Copyright © 2008-2009, all rights reserved. |
Adapted-by | Joep Suijs, Albert Faber |
Compiler | >=2.4i |
this library provides an ISR to implement a stateful i2c hardware slave. This is a jalv2 implementation of Microchip Application Note AN734. According to AN734, there are 5 possible i2c states. During ISR, each of this states are detected. This ISR provides a standard skeleton to implement an i2c hardware slaves, while client code must implement several callbacks the ISR is expecting to call while processing states. Here there are: - procedure i2c_hw_slave_on_state_1(byte in _trash): called when i2c address matches (master starts a talk) - procedure i2c_hw_slave_on_state_2(byte in rcv): called when master is writing a byte. Slave is thus receiving this byte. This callback takes this bytes as argument - procedure i2c_hw_slave_on_state_3(): called when master wants to read a byte from slave. Thus, slave should send a byte (for instance, using i2c_hw_slave_write_i2c from i2c_hw_slave.jal library) - procedure i2c_hw_slave_on_state_4(): called when master still wants to read a byte from slave. That is, master required to read (state 3) and now still want to read a byte - procedure i2c_hw_slave_on_state_5(): called when master does not want to talk to slave anymore usually a good place to reset data or slave's logic - procedure i2c_hw_slave_on_error(): called when something wrong happens. You can do what you want in this case, like resetting the PIC, log some information using usart, ... => called any cases other than states 1, 2, 3, 4 or 5
- AN734: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011798
No dependency found
i2c_hw_slave_isr_handler()
i2c ISR handler. Detects states a call appropriate procedures