Synergy Software Package User's Manual

Driver for the I2C Bus Interface (IIC). More...

Data Structures

struct  riic_instance_ctrl_t
 
struct  riic_extended_cfg
 

Macros

#define RIIC_OPEN   (0x52494943ULL)
 
#define RIIC_ERROR_RETURN(a, err)   SSP_ERROR_RETURN((a), (err), &g_module_name[0], &g_riic_master_version)
 

Enumerations

enum  riic_timeout_mode_t { RIIC_TIMEOUT_MODE_LONG = 0, RIIC_TIMEOUT_MODE_SHORT = 1 }
 

Functions

ssp_err_t R_RIIC_MasterVersionGet (ssp_version_t *const p_version)
 Gets version information and stores it in the provided version struct. More...
 
ssp_err_t R_RIIC_MasterOpen (i2c_ctrl_t *const p_api_ctrl, i2c_cfg_t const *const p_cfg)
 Opens the I2C device. May power on IIC peripheral and perform initialization described in hardware manual. More...
 
ssp_err_t R_RIIC_MasterClose (i2c_ctrl_t *const p_api_ctrl)
 Closes the I2C device. May power down IIC peripheral. More...
 
ssp_err_t R_RIIC_MasterRead (i2c_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. More...
 
ssp_err_t R_RIIC_MasterWrite (i2c_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. More...
 
ssp_err_t R_RIIC_MasterReset (i2c_ctrl_t *const p_api_ctrl)
 Aborts any in-progress transfer and forces the IIC peripheral into a ready state. More...
 
ssp_err_t R_RIIC_MasterSlaveAddressSet (i2c_ctrl_t *const p_api_ctrl, uint16_t const slave_address, i2c_addr_mode_t const addr_mode)
 Sets address and addressing mode of the slave device. More...
 

Variables

i2c_api_master_t const g_i2c_master_on_riic
 

Detailed Description

Driver for the I2C Bus Interface (IIC).

This module supports the Renesas Inter-Integrated Circuit (IIC) peripheral. It implements the following interfaces:

Macro Definition Documentation

◆ RIIC_ERROR_RETURN

#define RIIC_ERROR_RETURN (   a,
  err 
)    SSP_ERROR_RETURN((a), (err), &g_module_name[0], &g_riic_master_version)

Macro for error logger.

◆ RIIC_OPEN

#define RIIC_OPEN   (0x52494943ULL)

"RIIC" in ASCII, used to determine if channel is open.

Enumeration Type Documentation

◆ riic_timeout_mode_t

I2C Timeout mode parameter definition

Enumerator
RIIC_TIMEOUT_MODE_LONG 

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

RIIC_TIMEOUT_MODE_SHORT 

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

Function Documentation

◆ R_RIIC_MasterClose()

ssp_err_t R_RIIC_MasterClose ( i2c_ctrl_t *const  p_api_ctrl)

Closes the I2C device. May power down IIC peripheral.

This function will safely terminate any in-progress I2C transfer with the device. If a transfer is aborted, the user will be notified via callback with an abort event. Since the callback is optional, this function will also return a specific error code in this situation.

Return values
SSP_SUCCESSDevice closed without issue.
SSP_ERR_ASSERTIONp_api_ctrl is NULL.
SSP_ERR_ABORTEDDevice was closed while a transfer was in progress.

Check if the device is even open, return an error if not

Abort an in-progress transfer with this device only

Close the DTC transfer interfaces if configured

Disable the interrupt sources for I2C peripheral

◆ R_RIIC_MasterOpen()

ssp_err_t R_RIIC_MasterOpen ( i2c_ctrl_t *const  p_api_ctrl,
i2c_cfg_t const *const  p_cfg 
)

Opens the I2C device. May power on IIC peripheral and perform initialization described in hardware manual.

This function will reconfigure the clock settings of the peripheral when a device with a lower rate than previously configured is opened.

Return values
SSP_SUCCESSRequested clock rate was set exactly.
SSP_ERR_ASSERTIONThe parameter p_api_ctrl or p_cfg is NULL or clock rate is greater than 1MHz. or the extended parameter is NULL
SSP_ERR_IN_USEAttempted to open an already open device instance.
SSP_ERR_INVALID_ARGUMENTIf fast mode plus is configured and the channel does not support it
SSP_ERR_INVALID_RATEThe requested rate cannot be set.
Returns
See Common Error Codes for other possible return codes. This function calls

If rate is configured as Fast mode plus, check whether the channel supports it

set valid interrupts with user provided priority

Open the hardware in master mode

Open the RIIC DTC transfer interface if enabled

Initialize control block

◆ R_RIIC_MasterRead()

ssp_err_t R_RIIC_MasterRead ( i2c_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.

This function will fail if there is already an in-progress I2C transfer on the associated channel. Otherwise, the I2C read operation will begin. When no callback is provided by the user, this function performs a blocking read. Otherwise, the read operation is non-blocking and the caller will be notified when the operation has finished by an I2C_EVENT_RX_COMPLETE in the callback.

Return values
SSP_SUCCESSFunction executed without issue, if no callback was provided, the process was kicked off.
SSP_ERR_ASSERTIONp_api_ctrl, p_dest or bytes is NULL.
SSP_ERR_INVALID_SIZEProvided number of bytes more than uint16_t size(65535) while DTC is used for data transfer.
SSP_ERR_IN_USEAnother transfer was in progress.
SSP_ERR_HW_LOCKEDDriver busy doing RIIC operation
SSP_ERR_ABORTEDThe transfer failed.

Check if the device is even open, return an error if not

Attempt to acquire lock for this transfer operation. Prevents re-entrance conflict.

Record the new information about this transfer

Kickoff the read operation as a master

◆ R_RIIC_MasterReset()

ssp_err_t R_RIIC_MasterReset ( i2c_ctrl_t *const  p_api_ctrl)

Aborts any in-progress transfer and forces the IIC peripheral into a ready state.

This function will safely terminate any in-progress I2C transfer with the device. If a transfer is aborted, the user will be notified via callback with an abort event. Since the callback is optional, this function will also return a specific error code in this situation.

Return values
SSP_SUCCESSChannel was reset without issue.
SSP_ERR_ASSERTIONp_api_ctrl is NULL.
SSP_ERR_ABORTEDA transfer was aborted while resetting the hardware.

Check if the device is even open, return an error if not

Abort any on-going transfer on the channel

◆ R_RIIC_MasterSlaveAddressSet()

ssp_err_t R_RIIC_MasterSlaveAddressSet ( i2c_ctrl_t *const  p_api_ctrl,
uint16_t const  slave_address,
i2c_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
SSP_SUCCESSAddress of the slave is set correctly.
SSP_ERR_ASSERTIONPointer to control structure is NULL.
SSP_ERR_HW_LOCKEDDriver busy doing RIIC operation.
SSP_ERR_NOT_OPENDevice was not even opened.

Check if the device is open, return an error if not

Attempt to acquire lock for configuring the slave address. Prevents re-entrance conflict.

Return failure if there is already a transfer in progress

Sets the address of the slave device

Sets the mode of addressing

◆ R_RIIC_MasterVersionGet()

ssp_err_t R_RIIC_MasterVersionGet ( ssp_version_t *const  p_version)

Gets version information and stores it in the provided version struct.

Return values
SSP_SUCCESSSuccessful version get.
SSP_ERR_ASSERTIONp_version is NULL.

◆ R_RIIC_MasterWrite()

ssp_err_t R_RIIC_MasterWrite ( i2c_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.

This function will fail if there is already an in-progress I2C transfer on the associated channel. Otherwise, the I2C write operation will begin. When no callback is provided by the user, this function performs a blocking write. Otherwise, the write operation is non-blocking and the caller will be notified when the operation has finished by an I2C_EVENT_TX_COMPLETE in the callback.

Return values
SSP_SUCCESSFunction executed without issue, if no callback was provided, the process was kicked off.
SSP_ERR_ASSERTIONp_api_ctrl or p_src is NULL.
SSP_ERR_INVALID_SIZEProvided number of bytes more than uint16_t size(65535) while DTC is used for data transfer.
SSP_ERR_IN_USEAnother transfer was in progress.
SSP_ERR_HW_LOCKEDDriver busy doing RIIC operation
SSP_ERR_ABORTEDThe transfer failed.

Check if the device is even open, return an error if not

Attempt to acquire lock for this transfer operation. Prevents re-entrance conflict.

Record the new information about this transfer

Kickoff the write operation as a master

Variable Documentation

◆ g_i2c_master_on_riic

i2c_api_master_t const g_i2c_master_on_riic
Initial value:

RIIC Implementation of I2C device master interface