i2c_hw_slave_isr

i2c hardware slave ISR

Author Sebastien Lelong, Joep Suijs, Copyright © 2008-2009, all rights reserved.
Adapted-by Joep Suijs, Albert Faber
Compiler >=2.4i

Description

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


Sources

  - AN734: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011798


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f72316f723_i2c_hw_slave_echo.jal
16f7316f73_i2c_hw_slave_echo.jal
16f87716f877_i2c_hw_slave_echo.jal
16f877a16f877a_i2c_hw_slave_echo.jal
16f877a16f877a_servo_rc_master_dedicated_slave_i2c.jal
16f8816f88_i2c_hw_slave_echo.jal
18f14k5018f14k50_i2c_hw_slave_echo.jal
18f252018f2520_i2c_hw_slave_echo.jal
18f255018f2550_i2c_hw_slave_echo.jal
18f262018f2620_i2c_hw_slave_echo.jal
18f45218f452_i2c_hw_slave_echo.jal
18f45218f452_servo_rc_master_dedicated_slave_i2c.jal
18f455018f4550_i2c_hw_slave_echo.jal
18f462018f4620_i2c_hw_slave_echo.jal
18f462018f4620_servo_rc_master_dedicated_slave_i2c.jal
18f67j5018f67j50_i2c_hw_slave_echo.jal