openMMC
Open Source Modular MMC for AMCs
Loading...
Searching...
No Matches
i2c.h File Reference
#include "FreeRTOS.h"
#include "semphr.h"
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for i2c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  i2c_chip_mapping
 I2C Chips information regarding the bus and slave address. More...
 
struct  i2c_bus_mapping
 I2C Bus description. More...
 
struct  i2c_mux_state
 I2C Mux state. More...
 

Typedefs

typedef struct i2c_chip_mapping i2c_chip_mapping_t
 I2C Chips information regarding the bus and slave address.
 
typedef struct i2c_bus_mapping i2c_bus_mapping_t
 I2C Bus description.
 
typedef struct i2c_mux_state i2c_mux_state_t
 I2C Mux state.
 

Functions

void i2c_init (void)
 Initialize peripheral I2C buses.
 
bool i2c_set_mux_bus (uint8_t bus_id, i2c_mux_state_t *i2c_mux, int8_t new_state)
 Change I2C bus mux state.
 
uint8_t i2c_get_mux_bus (uint8_t bus_id, i2c_mux_state_t *i2c_mux)
 Read I2C bus mux state.
 
bool i2c_take_by_busid (uint8_t bus_id, uint8_t *i2c_interface, uint32_t timeout)
 Take control over an I2C bus given a bus id.
 
bool i2c_take_by_chipid (uint8_t chip_id, uint8_t *i2c_address, uint8_t *i2c_interface, TickType_t timeout)
 Take control over an I2C bus given a chip id.
 
void i2c_give (uint8_t i2c_interface)
 Release the previously gained I2C bus.
 

Typedef Documentation

◆ i2c_bus_mapping_t

I2C Bus description.

◆ i2c_chip_mapping_t

I2C Chips information regarding the bus and slave address.

◆ i2c_mux_state_t

I2C Mux state.

Function Documentation

◆ i2c_get_mux_bus()

uint8_t i2c_get_mux_bus ( uint8_t bus_id,
i2c_mux_state_t * i2c_mux )

Read I2C bus mux state.

Parameters
bus_idTarget bus ID
i2c_muxPointer to bus mux structure
Returns
Bus current state

◆ i2c_give()

void i2c_give ( uint8_t i2c_interface)

Release the previously gained I2C bus.

Parameters
i2c_interfacePhysical I2C bus ID

◆ i2c_init()

void i2c_init ( void )

Initialize peripheral I2C buses.

This function initializes all buses listed on the i2c_mux table, configuring the controller hardware and creating a binary semaphore for each.

◆ i2c_set_mux_bus()

bool i2c_set_mux_bus ( uint8_t bus_id,
i2c_mux_state_t * i2c_mux,
int8_t new_state )

Change I2C bus mux state.

Parameters
bus_idTarget bus ID
i2c_muxPointer to bus mux structure
new_stateNew bus mux state
Return values
trueBus was successfuly changed to the desired mux setting
falseBus could not be changed to the desired mux setting

◆ i2c_take_by_busid()

bool i2c_take_by_busid ( uint8_t bus_id,
uint8_t * i2c_interface,
uint32_t timeout )

Take control over an I2C bus given a bus id.

Parameters
[in]bus_idBus ID to take control
[out]i2c_interfacePointer to variable that will hold the I2C physical bus ID
[in]timeoutLimit time to perform this operation
Return values
trueBus was successfuly gained
falseCould not gain bus

◆ i2c_take_by_chipid()

bool i2c_take_by_chipid ( uint8_t chip_id,
uint8_t * i2c_address,
uint8_t * i2c_interface,
TickType_t timeout )

Take control over an I2C bus given a chip id.

Parameters
[in]chip_idChip ID to communicate
[out]i2c_addressPointer to variable that will hold the chip slave address
[out]i2c_interfacePointer to variable that will hold the I2C physical bus ID
[in]timeoutLimit time to perform this operation
Return values
trueBus was successfuly gained
falseCould not gain bus