# i2c_hw_slave

i2c_hardware slave procedures

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

Description

    Common and useful functions and procedure to implement an I2C slave

Notes

    Modifications by Rob Hamerling (may 2017)
          - Clock stretching - when control-bit present - enabled for all types of core.

Dependencies

No dependency found

## Summary

### Global variables/contants

- `var byte tmpstat ; this contains the last sspstat value, on which the user functions are`

### Procedures

- `i2c_hw_slave_init(byte in height_bits_icaddress)`
- `i2c_hw_slave_write_i2c(byte in what)`

### Functions

- `i2c_hw_slave_read_i2c() return byte`

## API details

### Global variables/contants

- `var byte tmpstat ; this contains the last sspstat value, on which the user functions are`

  No documentation found

### Procedures

- `i2c_hw_slave_init(byte in height_bits_icaddress)`

      setup an i2c slave, with low address (not high addresses coded with 10-bits)
      The passed address must be 8-bits long: it's a 7-bits address + the 8th R/W bit
      A global "i2c_enable_start_stop_interrupts" constant can be defined to so
      interrupts are generated on Start/Stop signals.
      /!\ careful: calling this procedure will enable interrupts (global, peripherals and i2c)

- `i2c_hw_slave_write_i2c(byte in what)`

      write a byte to i2c bus

### Functions

- `i2c_hw_slave_read_i2c() return byte`

      read a byte from i2c buffer and returns it

## Related samples

Here are the list of samples which use this library:

16f723 | 16f723_i2c_hw_slave_check_bus.jal
16f723 | 16f723_i2c_hw_slave_echo.jal
16f73 | 16f73_i2c_hw_slave_echo.jal
16f73 | 16f73_i2c_hw_slave_check_bus.jal
16f877 | 16f877_i2c_hw_slave_check_bus.jal
16f877 | 16f877_i2c_hw_slave_echo.jal
16f877a | 16f877a_servo_rc_master_dedicated_slave_i2c.jal
16f877a | 16f877a_i2c_hw_slave_check_bus.jal
16f877a | 16f877a_i2c_hw_slave_echo.jal
16f88 | 16f88_i2c_hw_slave_check_bus.jal
16f88 | 16f88_i2c_hw_slave_echo.jal
18f14k50 | 18f14k50_i2c_hw_slave_echo.jal
18f14k50 | 18f14k50_i2c_hw_slave_check_bus.jal
18f2520 | 18f2520_i2c_hw_slave_check_bus.jal
18f2520 | 18f2520_i2c_hw_slave_echo.jal
18f2550 | 18f2550_i2c_hw_slave_check_bus.jal
18f2550 | 18f2550_i2c_hw_slave_echo.jal
18f2620 | 18f2620_i2c_hw_slave_echo.jal
18f2620 | 18f2620_i2c_hw_slave_check_bus.jal
18f452 | 18f452_i2c_hw_slave_check_bus.jal
18f452 | 18f452_i2c_hw_slave_echo.jal
18f452 | 18f452_servo_rc_master_dedicated_slave_i2c.jal
18f4550 | 18f4550_i2c_hw_slave_check_bus.jal
18f4550 | 18f4550_i2c_hw_slave_echo.jal
18f4620 | 18f4620_servo_rc_master_dedicated_slave_i2c.jal
18f4620 | 18f4620_i2c_hw_slave_check_bus.jal
18f4620 | 18f4620_i2c_hw_slave_echo.jal
18f67j50 | 18f67j50_i2c_hw_slave_echo.jal
18f67j50 | 18f67j50_i2c_hw_slave_check_bus.jal