# i2c_hw_slave_isr

i2c hardware slave ISR

Author | Sebastien Lelong, Joep Suijs, Copyright © 2008..2019, all rights reserved.
Adapted-by | Joep Suijs, Albert Faber, Rob Jansen
Compiler | >=2.5r2

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

- `i2c_hw_slave_isr_handler()`

### Functions

## API details

### Global variables/contants

### Procedures

- `i2c_hw_slave_isr_handler()`

      i2c ISR handler. Detects states a call appropriate procedures

### Functions

## Related samples

Here are the list of samples which use this library:

16f723 | 16f723_i2c_hw_slave_echo.jal
16f73 | 16f73_i2c_hw_slave_echo.jal
16f877 | 16f877_i2c_hw_slave_echo.jal
16f877a | 16f877a_i2c_hw_slave_echo.jal
16f877a | 16f877a_servo_rc_master_dedicated_slave_i2c.jal
16f88 | 16f88_i2c_hw_slave_echo.jal
18f14k50 | 18f14k50_i2c_hw_slave_echo.jal
18f2520 | 18f2520_i2c_hw_slave_echo.jal
18f2550 | 18f2550_i2c_hw_slave_echo.jal
18f2620 | 18f2620_i2c_hw_slave_echo.jal
18f452 | 18f452_i2c_hw_slave_echo.jal
18f452 | 18f452_servo_rc_master_dedicated_slave_i2c.jal
18f4550 | 18f4550_i2c_hw_slave_echo.jal
18f4620 | 18f4620_i2c_hw_slave_echo.jal
18f4620 | 18f4620_servo_rc_master_dedicated_slave_i2c.jal
18f67j50 | 18f67j50_i2c_hw_slave_echo.jal