![]() |
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 |
Driver for the I2C Bus Interface (IIC).
This module supports the Renesas Inter-Integrated Circuit (IIC) peripheral. It implements the following interfaces:
| #define RIIC_ERROR_RETURN | ( | a, | |
| err | |||
| ) | SSP_ERROR_RETURN((a), (err), &g_module_name[0], &g_riic_master_version) |
Macro for error logger.
| #define RIIC_OPEN (0x52494943ULL) |
"RIIC" in ASCII, used to determine if channel is open.
| enum riic_timeout_mode_t |
| 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.
| SSP_SUCCESS | Device closed without issue. |
| SSP_ERR_ASSERTION | p_api_ctrl is NULL. |
| SSP_ERR_ABORTED | Device 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
| 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.
| SSP_SUCCESS | Requested clock rate was set exactly. |
| SSP_ERR_ASSERTION | The 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_USE | Attempted to open an already open device instance. |
| SSP_ERR_INVALID_ARGUMENT | If fast mode plus is configured and the channel does not support it |
| SSP_ERR_INVALID_RATE | The requested rate cannot be set. |
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
| 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.
| SSP_SUCCESS | Function executed without issue, if no callback was provided, the process was kicked off. |
| SSP_ERR_ASSERTION | p_api_ctrl, p_dest or bytes is NULL. |
| SSP_ERR_INVALID_SIZE | Provided number of bytes more than uint16_t size(65535) while DTC is used for data transfer. |
| SSP_ERR_IN_USE | Another transfer was in progress. |
| SSP_ERR_HW_LOCKED | Driver busy doing RIIC operation |
| SSP_ERR_ABORTED | The 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
| 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.
| SSP_SUCCESS | Channel was reset without issue. |
| SSP_ERR_ASSERTION | p_api_ctrl is NULL. |
| SSP_ERR_ABORTED | A 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
| 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.
| SSP_SUCCESS | Address of the slave is set correctly. |
| SSP_ERR_ASSERTION | Pointer to control structure is NULL. |
| SSP_ERR_HW_LOCKED | Driver busy doing RIIC operation. |
| SSP_ERR_NOT_OPEN | Device 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
| ssp_err_t R_RIIC_MasterVersionGet | ( | ssp_version_t *const | p_version | ) |
Gets version information and stores it in the provided version struct.
| SSP_SUCCESS | Successful version get. |
| SSP_ERR_ASSERTION | p_version is NULL. |
| 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.
| SSP_SUCCESS | Function executed without issue, if no callback was provided, the process was kicked off. |
| SSP_ERR_ASSERTION | p_api_ctrl or p_src is NULL. |
| SSP_ERR_INVALID_SIZE | Provided number of bytes more than uint16_t size(65535) while DTC is used for data transfer. |
| SSP_ERR_IN_USE | Another transfer was in progress. |
| SSP_ERR_HW_LOCKED | Driver busy doing RIIC operation |
| SSP_ERR_ABORTED | The 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
| i2c_api_master_t const g_i2c_master_on_riic |
RIIC Implementation of I2C device master interface