i2c_hardware

i2c_hardware

Author Stef Mientki, Copyright © 2005 Stef Mientki
Adapted-by Joep Suijs, Albert Faber
Compiler >=2.4g

Description

Hardware implementation of I2C (single) master.
.
Define i2c pins like:
alias i2c_scl            is pin_c3              -- optional
alias i2c_scl_direction  is pin_c3_direction
alias i2c_sda            is pin_c4              -- optional
alias i2c_sda_direction  is pin_c4_direction
- --
const word _i2c_bus_speed = 1                   -- 100kHz
const bit  _i2c_level     = true                -- i2c levels (not SMB)


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • i2c_restart()

    i2c_restart - Sends Restart bit and waits untill finished
    
    

  • i2c_initialize()

    if the device has changed, change the speed if necessary
    
    

  • i2c_stop()

    i2c_stop - Sends Stop bit and waits until finished
    
    

  • i2c_start()

    i2c_start - Sends Start bit and waits untill finished
    
    

Functions

  • i2c_receive_byte(bit in ACK ) return byte

    i2c_receive_byte -
    
    start receiving of a byte and waits till finished
    if param ACK is true, the byte is acknowledged and next bytes can be received.
    if param ACK is false, the byte is nacked and a stop *should be* sent.
    note: this behavior is inverted from the line level and orignal library, but
    consistent with the i2c_software library.
    
    

  • i2c_transmit_byte(byte in data) return bit

    i2c_transmit_byte -
    
    
    


Related samples

Here are the list of samples which use this library:

16f87716f877_i2c_hw_l0.jal
16f87716f877_i2c_hw_l1.jal
16f877a16f877a_i2c_hw_l0.jal
16f877a16f877a_rtc_pcf8563.jal
16f877a16f877a_ds1307_hw.jal
16f877a16f877a_i2c_hw_l1.jal
18f14k5018f14k50_i2c_hw_l1.jal
18f14k5018f14k50_i2c_hw_l0.jal
18f252018f2520_i2c_hw_l0.jal
18f252018f2520_i2c_hw_l1.jal
18f255018f2550_i2c_hw_l0.jal
18f255018f2550_i2c_hw_l1.jal
18f25k2218f25k22_i2c_hw_master_echo.jal
18f262018f2620_i2c_hw_l0.jal
18f262018f2620_i2c_hw_l1.jal
18f45218f452_i2c_hw_l1.jal
18f45218f452_i2c_hw_l0.jal
18f455018f4550_i2c_hw_l1.jal
18f455018f4550_i2c_hw_l0.jal
18f462018f4620_i2c_hw_l0.jal
18f462018f4620_i2c_hw_l1.jal
18f67j5018f67j50_i2c_hw_l1.jal
18f67j5018f67j50_i2c_hw_l0.jal
18f67k2218f67k22_co2_i2c.jal