Skip to content

File syn_port_i2c.h

FileList > port > syn_port_i2c.h

Go to the source code of this file

I2C port interface — implement these for your platform.

  • #include "../common/syn_defs.h"
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_I2C_Config
I2C bus configuration.

Public Functions

Type Name
SYN_Status syn_port_i2c_deinit (uint8_t bus)
Deinitialize an I2C bus.
SYN_Status syn_port_i2c_init (const SYN_I2C_Config * cfg)
Initialize an I2C bus.
SYN_Status syn_port_i2c_read (uint8_t bus, uint8_t addr, uint8_t * data, size_t len)
Read data from an I2C device.
SYN_Status syn_port_i2c_write (uint8_t bus, uint8_t addr, const uint8_t * data, size_t len)
Write data to an I2C device.
SYN_Status syn_port_i2c_write_read (uint8_t bus, uint8_t addr, const uint8_t * tx_data, size_t tx_len, uint8_t * rx_data, size_t rx_len)
Write then read (register access pattern).

Public Functions Documentation

function syn_port_i2c_deinit

Deinitialize an I2C bus.

SYN_Status syn_port_i2c_deinit (
    uint8_t bus
) 

Parameters:

  • bus I2C bus index.

Returns:

SYN_OK on success.


function syn_port_i2c_init

Initialize an I2C bus.

SYN_Status syn_port_i2c_init (
    const SYN_I2C_Config * cfg
) 

Parameters:

  • cfg I2C configuration.

Returns:

SYN_OK on success.


function syn_port_i2c_read

Read data from an I2C device.

SYN_Status syn_port_i2c_read (
    uint8_t bus,
    uint8_t addr,
    uint8_t * data,
    size_t len
) 

Parameters:

  • bus I2C bus index.
  • addr 7-bit device address.
  • data Buffer to receive data.
  • len Number of bytes to read.

Returns:

SYN_OK on ACK, SYN_ERROR on NACK/timeout.


function syn_port_i2c_write

Write data to an I2C device.

SYN_Status syn_port_i2c_write (
    uint8_t bus,
    uint8_t addr,
    const uint8_t * data,
    size_t len
) 

Parameters:

  • bus I2C bus index.
  • addr 7-bit device address.
  • data Data to write.
  • len Number of bytes.

Returns:

SYN_OK on ACK, SYN_ERROR on NACK/timeout.


function syn_port_i2c_write_read

Write then read (register access pattern).

SYN_Status syn_port_i2c_write_read (
    uint8_t bus,
    uint8_t addr,
    const uint8_t * tx_data,
    size_t tx_len,
    uint8_t * rx_data,
    size_t rx_len
) 

Sends a write (typically a register address) followed by a repeated start and read. This is the most common I2C transaction pattern.

Parameters:

  • bus I2C bus index.
  • addr 7-bit device address.
  • tx_data Data to write (e.g., register address).
  • tx_len Write length.
  • rx_data Buffer for read data.
  • rx_len Read length.

Returns:

SYN_OK on success.



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