RZA Flexible Software Package Documentation  Release v1.1.0

 
I2C Master on RIIC (r_riic_master)

Functions

fsp_err_t R_RIIC_MASTER_Open (i2c_master_ctrl_t *const p_api_ctrl, i2c_master_cfg_t const *const p_cfg)
 
fsp_err_t R_RIIC_MASTER_Read (i2c_master_ctrl_t *const p_api_ctrl, uint8_t *const p_dest, uint32_t const bytes, bool const restart)
 
fsp_err_t R_RIIC_MASTER_Write (i2c_master_ctrl_t *const p_api_ctrl, uint8_t *const p_src, uint32_t const bytes, bool const restart)
 
fsp_err_t R_RIIC_MASTER_Abort (i2c_master_ctrl_t *const p_api_ctrl)
 
fsp_err_t R_RIIC_MASTER_SlaveAddressSet (i2c_master_ctrl_t *const p_api_ctrl, uint32_t const slave, i2c_master_addr_mode_t const addr_mode)
 
fsp_err_t R_RIIC_MASTER_Close (i2c_master_ctrl_t *const p_api_ctrl)
 
fsp_err_t R_RIIC_MASTER_CallbackSet (i2c_master_ctrl_t *const p_api_ctrl, void(*p_callback)(i2c_master_callback_args_t *), void const *const p_context, i2c_master_callback_args_t *const p_callback_memory)
 
fsp_err_t R_RIIC_MASTER_StatusGet (i2c_master_ctrl_t *const p_api_ctrl, i2c_master_status_t *p_status)
 

Detailed Description

Driver for the RIIC peripheral on RZ MPUs. This module implements the I2C Master Interface.

Data Structures

struct  iic_master_clock_settings_t
 
struct  iic_master_instance_ctrl_t
 
struct  riic_master_extended_cfg_t
 

Enumerations

enum  iic_master_timeout_mode_t
 
enum  iic_master_timeout_scl_low_t
 

Data Structure Documentation

◆ iic_master_clock_settings_t

struct iic_master_clock_settings_t

I2C clock settings

Data Fields
uint8_t cks_value Internal Reference Clock Select.
uint8_t brh_value High-level period of SCL clock.
uint8_t brl_value Low-level period of SCL clock.

◆ iic_master_instance_ctrl_t

struct iic_master_instance_ctrl_t

I2C control structure. DO NOT INITIALIZE.

◆ riic_master_extended_cfg_t

struct riic_master_extended_cfg_t

RIIC extended configuration

Data Fields
iic_master_timeout_mode_t timeout_mode Timeout Detection Time Select: Long Mode = 0 and Short Mode = 1.
iic_master_timeout_scl_low_t timeout_scl_low Allows timeouts to occur when SCL is held low.
iic_master_clock_settings_t clock_settings I2C Clock settings.
uint8_t noise_filter_stage Noise Filter Stage Selection.
IRQn_Type naki_irq NACK IRQ Number.
IRQn_Type sti_irq Start condition IRQ Number.
IRQn_Type spi_irq Stop condition IRQ Number.
IRQn_Type ali_irq Arbitration lost IRQ Number.
IRQn_Type tmoi_irq Timeout IRQ Number.

Enumeration Type Documentation

◆ iic_master_timeout_mode_t

I2C Timeout mode parameter definition

Enumerator
IIC_MASTER_TIMEOUT_MODE_LONG 

Timeout Detection Time Select: Long Mode -> TMOS = 0.

IIC_MASTER_TIMEOUT_MODE_SHORT 

Timeout Detection Time Select: Short Mode -> TMOS = 1.

◆ iic_master_timeout_scl_low_t

Enumerator
IIC_MASTER_TIMEOUT_SCL_LOW_DISABLED 

Timeout detection during SCL low disabled.

IIC_MASTER_TIMEOUT_SCL_LOW_ENABLED 

Timeout detection during SCL low enabled.

Function Documentation

◆ R_RIIC_MASTER_Open()

fsp_err_t R_RIIC_MASTER_Open ( i2c_master_ctrl_t *const  p_api_ctrl,
i2c_master_cfg_t const *const  p_cfg 
)

Opens the I2C device.

Return values
FSP_SUCCESSRequested clock rate was set exactly.
FSP_ERR_ALREADY_OPENModule is already open.
FSP_ERR_IP_CHANNEL_NOT_PRESENTChannel is not available on this MCU.
FSP_ERR_ASSERTIONParameter check failure due to one or more reasons below:
  1. p_api_ctrl or p_cfg is NULL.
  2. extended parameter is NULL.
  3. Callback parameter is NULL.
  4. Set the rate to fast mode plus on a channel which does not support it.
  5. Invalid IRQ number assigned

◆ R_RIIC_MASTER_Read()

fsp_err_t R_RIIC_MASTER_Read ( i2c_master_ctrl_t *const  p_api_ctrl,
uint8_t *const  p_dest,
uint32_t const  bytes,
bool const  restart 
)

Performs a read from the I2C device. The caller will be notified when the operation has completed (successfully) by an I2C_MASTER_EVENT_RX_COMPLETE in the callback.

Return values
FSP_SUCCESSFunction executed without issue.
FSP_ERR_ASSERTIONp_api_ctrl, p_dest or bytes is NULL.
FSP_ERR_IN_USEBus busy condition. Another transfer was in progress.
FSP_ERR_NOT_OPENHandle is not initialized. Call R_RIIC_MASTER_Open to initialize the control block.

◆ R_RIIC_MASTER_Write()

fsp_err_t R_RIIC_MASTER_Write ( i2c_master_ctrl_t *const  p_api_ctrl,
uint8_t *const  p_src,
uint32_t const  bytes,
bool const  restart 
)

Performs a write to the I2C device. The caller will be notified when the operation has completed (successfully) by an I2C_MASTER_EVENT_TX_COMPLETE in the callback.

Return values
FSP_SUCCESSFunction executed without issue.
FSP_ERR_ASSERTIONp_api_ctrl or p_src is NULL.
FSP_ERR_IN_USEBus busy condition. Another transfer was in progress.
FSP_ERR_NOT_OPENHandle is not initialized. Call R_RIIC_MASTER_Open to initialize the control block.

◆ R_RIIC_MASTER_Abort()

fsp_err_t R_RIIC_MASTER_Abort ( i2c_master_ctrl_t *const  p_api_ctrl)

Safely aborts any in-progress transfer and forces the RIIC peripheral into ready state.

Return values
FSP_SUCCESSChannel was reset successfully.
FSP_ERR_ASSERTIONp_api_ctrl is NULL.
FSP_ERR_NOT_OPENHandle is not initialized. Call R_RIIC_MASTER_Open to initialize the control block.
Note
A callback will not be invoked in case an in-progress transfer gets aborted by calling this API.

◆ R_RIIC_MASTER_SlaveAddressSet()

fsp_err_t R_RIIC_MASTER_SlaveAddressSet ( i2c_master_ctrl_t *const  p_api_ctrl,
uint32_t const  slave,
i2c_master_addr_mode_t const  addr_mode 
)

Sets address and addressing mode of the slave device. This function is used to set the device address and addressing mode of the slave without reconfiguring the entire bus.

Return values
FSP_SUCCESSAddress of the slave is set correctly.
FSP_ERR_ASSERTIONPointer to control structure is NULL.
FSP_ERR_IN_USEAnother transfer was in-progress.
FSP_ERR_NOT_OPENHandle is not initialized. Call R_RIIC_MASTER_Open to initialize the control block.

◆ R_RIIC_MASTER_Close()

fsp_err_t R_RIIC_MASTER_Close ( i2c_master_ctrl_t *const  p_api_ctrl)

Closes the I2C device. May power down RIIC peripheral. This function will safely terminate any in-progress I2C transfers.

Return values
FSP_SUCCESSDevice closed without issue.
FSP_ERR_ASSERTIONp_api_ctrl is NULL.
FSP_ERR_NOT_OPENHandle is not initialized. Call R_RIIC_MASTER_Open to initialize the control block.
Note
A callback will not be invoked in case an in-progress transfer gets aborted by calling this API.

◆ R_RIIC_MASTER_CallbackSet()

fsp_err_t R_RIIC_MASTER_CallbackSet ( i2c_master_ctrl_t *const  p_api_ctrl,
void(*)(i2c_master_callback_args_t *)  p_callback,
void const *const  p_context,
i2c_master_callback_args_t *const  p_callback_memory 
)

Updates the user callback and has option of providing memory for callback structure. Implements i2c_master_api_t::callbackSet

Return values
FSP_SUCCESSCallback updated successfully.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe control block has not been opened.
FSP_ERR_NO_CALLBACK_MEMORYp_callback is non-secure and p_callback_memory is either secure or NULL.

◆ R_RIIC_MASTER_StatusGet()

fsp_err_t R_RIIC_MASTER_StatusGet ( i2c_master_ctrl_t *const  p_api_ctrl,
i2c_master_status_t p_status 
)

Provides driver status.

Return values
FSP_SUCCESSStatus stored in p_status.
FSP_ERR_ASSERTIONNULL pointer.