Skip to content

File syn_port_i2c.h

FileList > port > syn_port_i2c.h

Go to the source code of this file

Port contract for Inter-Integrated Circuit (I2C) hardware.

  • #include "../common/syn_defs.h"

Public Functions

Type Name
SYN_Status syn_port_i2c_deinit (uint8_t i2c_id)
De-initialize an I2C hardware instance.
SYN_Status syn_port_i2c_init (uint8_t i2c_id, uint32_t clock_speed_hz, uint8_t role, uint16_t own_addr)
Initialize an I2C hardware instance.
SYN_Status syn_port_i2c_transfer (uint8_t i2c_id, uint16_t addr, const uint8_t * tx, size_t tx_len, uint8_t * rx, size_t rx_len)
Perform an I2C transaction (Write, Read, or Write-Then-Read restart).

Public Functions Documentation

function syn_port_i2c_deinit

De-initialize an I2C hardware instance.

SYN_Status syn_port_i2c_deinit (
    uint8_t i2c_id
) 

Parameters:

  • i2c_id Instance index.

Returns:

SYN_OK on success.


function syn_port_i2c_init

Initialize an I2C hardware instance.

SYN_Status syn_port_i2c_init (
    uint8_t i2c_id,
    uint32_t clock_speed_hz,
    uint8_t role,
    uint16_t own_addr
) 

Parameters:

  • i2c_id Instance index (0 = I2C1, 1 = I2C2).
  • clock_speed_hz Bus clock frequency in Hz (e.g. 100000, 400000).
  • role 0 = Master, 1 = Slave.
  • own_addr 7-bit own slave address (used in Slave mode).

Returns:

SYN_OK on success.


function syn_port_i2c_transfer

Perform an I2C transaction (Write, Read, or Write-Then-Read restart).

SYN_Status syn_port_i2c_transfer (
    uint8_t i2c_id,
    uint16_t addr,
    const uint8_t * tx,
    size_t tx_len,
    uint8_t * rx,
    size_t rx_len
) 

Parameters:

  • i2c_id Instance index.
  • addr Target 7-bit slave address.
  • tx TX data buffer (can be NULL if rx_len > 0).
  • tx_len Bytes to transmit.
  • rx RX destination buffer (can be NULL if tx_len > 0).
  • rx_len Bytes to receive.

Returns:

SYN_OK on success.



The documentation for this class was generated from the following file src/syntropic/port/syn_port_i2c.h