RA Flexible Software Package Documentation  Release v5.6.0

 
I2C Slave Interface

Detailed Description

Interface for I2C slave communication.

Summary

The I2C slave interface provides a common API for I2C HAL drivers. The I2C slave interface supports:

Data Structures

struct  i2c_slave_callback_args_t
 
struct  i2c_slave_cfg_t
 
struct  i2c_slave_api_t
 
struct  i2c_slave_instance_t
 

Typedefs

typedef void i2c_slave_ctrl_t
 

Enumerations

enum  i2c_slave_rate_t
 
enum  i2c_slave_addr_mode_t
 
enum  i2c_slave_event_t
 

Data Structure Documentation

◆ i2c_slave_callback_args_t

struct i2c_slave_callback_args_t

I2C callback parameter definition

Data Fields
void const * p_context Pointer to user-provided context.
uint32_t bytes Number of received/transmitted bytes in buffer.
i2c_slave_event_t event Event code.

◆ i2c_slave_cfg_t

struct i2c_slave_cfg_t

I2C configuration block

Data Fields

uint8_t channel
 Identifier recognizable by implementation. More...
 
i2c_slave_rate_t rate
 Device's maximum clock rate from enum i2c_rate_t.
 
uint16_t slave
 The address of the slave device.
 
i2c_slave_addr_mode_t addr_mode
 Indicates how slave fields should be interpreted.
 
bool general_call_enable
 Allow a General call from master.
 
IRQn_Type rxi_irq
 Receive IRQ number.
 
IRQn_Type txi_irq
 Transmit IRQ number.
 
IRQn_Type tei_irq
 Transmit end IRQ number.
 
IRQn_Type eri_irq
 Error IRQ number.
 
uint8_t ipl
 Interrupt priority level for receive, transmit, and transmit end interrupts.
 
uint8_t eri_ipl
 Interrupt priority level for error interrupt.
 
bool clock_stretching_enable
 Low Hold SCL during reception for the period between the 9th and the 1st clock cycle.
 
transfer_instance_t const * p_transfer_tx
 DTC instance for I2C transmit.Set to NULL if unused. More...
 
transfer_instance_t const * p_transfer_rx
 DTC instance for I2C receive. Set to NULL if unused.
 
void(* p_callback )(i2c_slave_callback_args_t *p_args)
 Pointer to callback function. More...
 
void const * p_context
 Pointer to the user-provided context.
 
void const * p_extend
 Any configuration data needed by the hardware. More...
 

Field Documentation

◆ channel

uint8_t i2c_slave_cfg_t::channel

Identifier recognizable by implementation.

Generic configuration

◆ p_transfer_tx

transfer_instance_t const* i2c_slave_cfg_t::p_transfer_tx

DTC instance for I2C transmit.Set to NULL if unused.

DTC support

◆ p_callback

void(* i2c_slave_cfg_t::p_callback) (i2c_slave_callback_args_t *p_args)

Pointer to callback function.

Parameters to control software behavior

◆ p_extend

void const* i2c_slave_cfg_t::p_extend

Any configuration data needed by the hardware.

Implementation-specific configuration

◆ i2c_slave_api_t

struct i2c_slave_api_t

Interface definition for I2C access as slave

Data Fields

fsp_err_t(* open )(i2c_slave_ctrl_t *const p_ctrl, i2c_slave_cfg_t const *const p_cfg)
 
fsp_err_t(* read )(i2c_slave_ctrl_t *const p_ctrl, uint8_t *const p_dest, uint32_t const bytes)
 
fsp_err_t(* write )(i2c_slave_ctrl_t *const p_ctrl, uint8_t *const p_src, uint32_t const bytes)
 
fsp_err_t(* callbackSet )(i2c_slave_ctrl_t *const p_ctrl, void(*p_callback)(i2c_slave_callback_args_t *), void const *const p_context, i2c_slave_callback_args_t *const p_callback_memory)
 
fsp_err_t(* close )(i2c_slave_ctrl_t *const p_ctrl)
 

Field Documentation

◆ open

fsp_err_t(* i2c_slave_api_t::open) (i2c_slave_ctrl_t *const p_ctrl, i2c_slave_cfg_t const *const p_cfg)

Opens the I2C Slave driver and initializes the hardware.

Parameters
[in]p_ctrlPointer to control block. Must be declared by user. Elements are set here.
[in]p_cfgPointer to configuration structure.

◆ read

fsp_err_t(* i2c_slave_api_t::read) (i2c_slave_ctrl_t *const p_ctrl, uint8_t *const p_dest, uint32_t const bytes)

Performs a read operation on an I2C Slave device.

Parameters
[in]p_ctrlPointer to control block set in i2c_slave_api_t::open call.
[in]p_destPointer to the location to store read data.
[in]bytesNumber of bytes to read.

◆ write

fsp_err_t(* i2c_slave_api_t::write) (i2c_slave_ctrl_t *const p_ctrl, uint8_t *const p_src, uint32_t const bytes)

Performs a write operation on an I2C Slave device.

Parameters
[in]p_ctrlPointer to control block set in i2c_slave_api_t::open call.
[in]p_srcPointer to the location to get write data from.
[in]bytesNumber of bytes to write.

◆ callbackSet

fsp_err_t(* i2c_slave_api_t::callbackSet) (i2c_slave_ctrl_t *const p_ctrl, void(*p_callback)(i2c_slave_callback_args_t *), void const *const p_context, i2c_slave_callback_args_t *const p_callback_memory)

Specify callback function and optional context pointer and working memory pointer.

Parameters
[in]p_ctrlPointer to the IIC Slave control block.
[in]p_callbackCallback function
[in]p_contextPointer to send to callback function
[in]p_working_memoryPointer to volatile memory where callback structure can be allocated. Callback arguments allocated here are only valid during the callback.

◆ close

fsp_err_t(* i2c_slave_api_t::close) (i2c_slave_ctrl_t *const p_ctrl)

Closes the driver and releases the I2C Slave device.

Parameters
[in]p_ctrlPointer to control block set in i2c_slave_api_t::open call.

◆ i2c_slave_instance_t

struct i2c_slave_instance_t

This structure encompasses everything that is needed to use an instance of this interface.

Data Fields
i2c_slave_ctrl_t * p_ctrl Pointer to the control structure for this instance.
i2c_slave_cfg_t const * p_cfg Pointer to the configuration structure for this instance.
i2c_slave_api_t const * p_api Pointer to the API structure for this instance.

Typedef Documentation

◆ i2c_slave_ctrl_t

typedef void i2c_slave_ctrl_t

I2C control block. Allocate an instance specific control block to pass into the I2C API calls.

Enumeration Type Documentation

◆ i2c_slave_rate_t

Communication speed options

Enumerator
I2C_SLAVE_RATE_STANDARD 

100 kHz

I2C_SLAVE_RATE_FAST 

400 kHz

I2C_SLAVE_RATE_FASTPLUS 

1 MHz

◆ i2c_slave_addr_mode_t

Addressing mode options

Enumerator
I2C_SLAVE_ADDR_MODE_7BIT 

Use 7-bit addressing mode.

I2C_SLAVE_ADDR_MODE_10BIT 

Use 10-bit addressing mode.

◆ i2c_slave_event_t

Callback events

Enumerator
I2C_SLAVE_EVENT_ABORTED 

A transfer was aborted.

I2C_SLAVE_EVENT_RX_COMPLETE 

A receive operation was completed successfully.

I2C_SLAVE_EVENT_TX_COMPLETE 

A transmit operation was completed successfully.

I2C_SLAVE_EVENT_RX_REQUEST 

A read operation expected from slave. Detected a write from master.

I2C_SLAVE_EVENT_TX_REQUEST 

A write operation expected from slave. Detected a read from master.

I2C_SLAVE_EVENT_RX_MORE_REQUEST 

A read operation expected from slave. Master sends out more data than configured to be read in slave.

I2C_SLAVE_EVENT_TX_MORE_REQUEST 

A write operation expected from slave. Master requests more data than configured to be written by slave.

I2C_SLAVE_EVENT_GENERAL_CALL 

General Call address received from Master. Detected a write from master.