Skip to content

File syn_i2c.h

FileList > drivers > syn_i2c.h

Go to the source code of this file

Hardware-decoupled I2C driver supporting Master/Slave roles & register access.

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

Classes

Type Name
struct SYN_I2C
I2C driver handle structure.
struct SYN_I2C_Config
I2C driver instance configuration parameters.

Public Types

Type Name
enum SYN_I2C_Role
I2C operational mode role.

Public Functions

Type Name
SYN_Status syn_i2c_deinit (SYN_I2C * i2c)
De-initialize an I2C instance.
SYN_Status syn_i2c_init (SYN_I2C * i2c, const SYN_I2C_Config * cfg)
Initialize an I2C instance.
SYN_Status syn_i2c_read_reg (SYN_I2C * i2c, uint16_t addr, uint8_t reg, uint8_t * val)
Read an 8-bit register from a slave device.
SYN_Status syn_i2c_transfer (SYN_I2C * i2c, uint16_t addr, const uint8_t * tx, size_t tx_len, uint8_t * rx, size_t rx_len)
Perform raw buffer transfer (Write, Read, or Write-Read restart).
SYN_Status syn_i2c_write_reg (SYN_I2C * i2c, uint16_t addr, uint8_t reg, uint8_t val)
Write an 8-bit register on a slave device.

Public Types Documentation

enum SYN_I2C_Role

I2C operational mode role.

enum SYN_I2C_Role {
    SYN_I2C_ROLE_MASTER = 0,
    SYN_I2C_ROLE_SLAVE
};


Public Functions Documentation

function syn_i2c_deinit

De-initialize an I2C instance.

SYN_Status syn_i2c_deinit (
    SYN_I2C * i2c
) 

Parameters:

Returns:

SYN_OK on success.


function syn_i2c_init

Initialize an I2C instance.

SYN_Status syn_i2c_init (
    SYN_I2C * i2c,
    const SYN_I2C_Config * cfg
) 

Parameters:

  • i2c Pointer to SYN_I2C handle.
  • cfg Configuration structure.

Returns:

SYN_OK on success.


function syn_i2c_read_reg

Read an 8-bit register from a slave device.

SYN_Status syn_i2c_read_reg (
    SYN_I2C * i2c,
    uint16_t addr,
    uint8_t reg,
    uint8_t * val
) 

Parameters:

  • i2c Pointer to initialized I2C handle.
  • addr 7-bit slave address.
  • reg Register index byte.
  • val Pointer to store output register byte.

Returns:

SYN_OK on success.


function syn_i2c_transfer

Perform raw buffer transfer (Write, Read, or Write-Read restart).

SYN_Status syn_i2c_transfer (
    SYN_I2C * i2c,
    uint16_t addr,
    const uint8_t * tx,
    size_t tx_len,
    uint8_t * rx,
    size_t rx_len
) 

Parameters:

  • i2c Pointer to initialized I2C handle.
  • addr Target 7-bit slave address.
  • tx TX data buffer (can be NULL).
  • tx_len TX byte count.
  • rx RX data buffer (can be NULL).
  • rx_len RX byte count.

Returns:

SYN_OK on success.


function syn_i2c_write_reg

Write an 8-bit register on a slave device.

SYN_Status syn_i2c_write_reg (
    SYN_I2C * i2c,
    uint16_t addr,
    uint8_t reg,
    uint8_t val
) 

Parameters:

  • i2c Pointer to initialized I2C handle.
  • addr 7-bit slave address.
  • reg Register index byte.
  • val Byte to write into register.

Returns:

SYN_OK on success.



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