![]() |
RZ Flexible Software Package Documentation
Release v4.2.0
|
|
Functions | |
| fsp_err_t | R_RIIC_SLAVE_Open (i2c_slave_ctrl_t *const p_api_ctrl, i2c_slave_cfg_t const *const p_cfg) |
| fsp_err_t | R_RIIC_SLAVE_Read (i2c_slave_ctrl_t *const p_api_ctrl, uint8_t *const p_dest, uint32_t const bytes) |
| fsp_err_t | R_RIIC_SLAVE_Write (i2c_slave_ctrl_t *const p_api_ctrl, uint8_t *const p_src, uint32_t const bytes) |
| fsp_err_t | R_RIIC_SLAVE_Close (i2c_slave_ctrl_t *const p_api_ctrl) |
| fsp_err_t | R_RIIC_SLAVE_CallbackSet (i2c_slave_ctrl_t *const p_api_ctrl, void(*p_callback)(i2c_slave_callback_args_t *), void *const p_context, i2c_slave_callback_args_t *const p_callback_memory) |
Driver for the RIIC peripheral on RZ MPUs. This module implements the I2C Slave Interface.
| Configuration | Options | Default | Description |
|---|---|---|---|
| Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
| DMAC Support |
| Disabled | If enabled, DMAC instances will be included in the build for both transmission and reception. |
| Configuration | Options | Default | Description |
|---|---|---|---|
| Interrupt Priority Level > Transmit, Receive, and Transmit End | Value must be an integer between 0 and 31 | 24 | Select the interrupt priority level. This is set for TXI, RXI, and TEI interrupts. |
| Interrupt Priority Level > NACK, Start, Stop, Timeout, Arbitration lost | Value must be an integer between 0 and 31 | 24 | Select the interrupt priority level. This is set for NAKI, SPI, STI, ALI, TMOI interrupt. |
| Name | Name must be a valid C symbol | g_i2c_slave0 | Module name. |
| Channel | Value must be a non-negative integer | 0 | Specify the RIIC channel. |
| Rate |
| Standard | Select the transfer rate. |
| Internal Reference Clock |
| P0CLK / 1 | Select the internal reference clock for RIIC slave. The internal reference clock is used only to determine the clock frequency of the noise filter samples. |
| Digital Noise Filter Stage Select |
| 3-stage filter | Select the number of digital filter stages for RIIC Slave. |
| Slave Address | Value must be non-negative | 0x08 | Specify the slave address. |
| General Call |
| Disabled | Allows the slave to respond to general call address: 0x00. |
| Address Mode |
| 7-Bit | Select the slave address mode. |
| Clock Stretching |
| Disabled | Configure Clock Stretching. |
| Callback | Name must be a valid C symbol | NULL | A user callback function must be provided. This will be called from the interrupt service routine (ISR) to report I2C Slave transaction events and status. |
The RIIC peripheral module uses the P0 clock as its clock source. The actual I2C transfer rate will be calculated and set by the tooling depending on the selected transfer rate. If the P0 clock is configured in such a manner that the selected transfer rate cannot be achieved, an error will be returned.
The IIC peripheral module uses pins on the MPU to communicate to external devices. I/O pins must be selected and configured as required by the external device. An I2C channel would consist of two pins - SDA and SCL for data/address and clock respectively.
| RIIC Slave Callback Event | RIIC Slave API expected to be called |
|---|---|
| I2C_SLAVE_EVENT_ABORTED | Handle event based on application |
| I2C_SLAVE_EVENT_RX_COMPLETE | Handle event based on application |
| I2C_SLAVE_EVENT_TX_COMPLETE | Handle event based on application |
| I2C_SLAVE_EVENT_RX_REQUEST | R_RIIC_SLAVE_Read API. If the slave is a Write Only device call this API with 0 bytes to send a NACK to the master. |
| I2C_SLAVE_EVENT_TX_REQUEST | R_RIIC_SLAVE_Write API |
| I2C_SLAVE_EVENT_RX_MORE_REQUEST | R_RIIC_SLAVE_Read API. If the slave cannot read any more data call this API with 0 bytes to send a NACK to the master. |
| I2C_SLAVE_EVENT_TX_MORE_REQUEST | R_RIIC_SLAVE_Write API |
| I2C_SLAVE_EVENT_GENERAL_CALL | R_RIIC_SLAVE_Read |
This is a basic example of minimal use of the R_RIIC_SLAVE in an application. This example shows how this driver can be used for basic read and write operations.
Classes | |
| struct | st_iic_slave_clock_settings |
| struct | st_iic_slave_instance_ctrl |
| struct | st_riic_slave_extended_cfg |
Typedefs | |
| typedef struct st_iic_slave_clock_settings | iic_slave_clock_settings_t |
| typedef struct st_iic_slave_instance_ctrl | iic_slave_instance_ctrl_t |
| typedef struct st_riic_slave_extended_cfg | riic_slave_extended_cfg_t |
| struct RZA::st_iic_slave_clock_settings |
| struct RZA::st_iic_slave_instance_ctrl |
I2C control structure. DO NOT INITIALIZE.
| struct RZA::st_riic_slave_extended_cfg |
R_IIC_SLAVE extended configuration
| Class Members | ||
|---|---|---|
| iic_slave_clock_settings_t | clock_settings | I2C Clock settings. |
| 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. |
| void * | p_reg | Register base address for specified channel. |
| typedef struct st_iic_slave_clock_settings iic_slave_clock_settings_t |
I2C clock settings. Please refer to the struct st_iic_slave_clock_settings.
| typedef struct st_iic_slave_instance_ctrl iic_slave_instance_ctrl_t |
I2C control structure. DO NOT INITIALIZE. Please refer to the struct st_iic_slave_instance_ctrl.
| typedef struct st_riic_slave_extended_cfg riic_slave_extended_cfg_t |
R_IIC_SLAVE extended configuration. Please refer to the struct st_riic_slave_extended_cfg.
| fsp_err_t R_RIIC_SLAVE_Open | ( | i2c_slave_ctrl_t *const | p_api_ctrl, |
| i2c_slave_cfg_t const *const | p_cfg | ||
| ) |
Opens the I2C slave device.
| FSP_SUCCESS | I2C slave device opened successfully. |
| FSP_ERR_ALREADY_OPEN | Module is already open. |
| FSP_ERR_IP_CHANNEL_NOT_PRESENT | Channel is not available on this MPU. |
| FSP_ERR_INVALID_ARGUMENT | NACK, Start, Stop, Timeout, Arbitration lost interrupt priority is lower than Transmit, Receive and Transmit End interrupt priority |
| FSP_ERR_ASSERTION | Parameter check failure due to one or more reasons below:
|
| fsp_err_t R_RIIC_SLAVE_Read | ( | i2c_slave_ctrl_t *const | p_api_ctrl, |
| uint8_t *const | p_dest, | ||
| uint32_t const | bytes | ||
| ) |
Performs a read from the I2C Master device.
This function will fail if there is already an in-progress I2C transfer on the associated channel. Otherwise, the I2C slave read operation will begin. The caller will be notified when the operation has finished by an I2C_SLAVE_EVENT_RX_COMPLETE in the callback. In case the master continues to write more data, an I2C_SLAVE_EVENT_RX_MORE_REQUEST will be issued via callback. In case of errors, an I2C_SLAVE_EVENT_ABORTED will be issued via callback.
| FSP_SUCCESS | Function executed without issue |
| FSP_ERR_ASSERTION | p_api_ctrl, bytes or p_dest is NULL. |
| FSP_ERR_IN_USE | Another transfer was in progress. |
| FSP_ERR_NOT_OPEN | Device is not open. |
| fsp_err_t R_RIIC_SLAVE_Write | ( | i2c_slave_ctrl_t *const | p_api_ctrl, |
| uint8_t *const | p_src, | ||
| uint32_t const | bytes | ||
| ) |
Performs a write to the I2C Master device.
This function will fail if there is already an in-progress I2C transfer on the associated channel. Otherwise, the I2C slave write operation will begin. The caller will be notified when the operation has finished by an I2C_SLAVE_EVENT_TX_COMPLETE in the callback. In case the master continues to read more data, an I2C_SLAVE_EVENT_TX_MORE_REQUEST will be issued via callback. In case of errors, an I2C_SLAVE_EVENT_ABORTED will be issued via callback.
| FSP_SUCCESS | Function executed without issue. |
| FSP_ERR_ASSERTION | p_api_ctrl or p_src is NULL. |
| FSP_ERR_IN_USE | Another transfer was in progress. |
| FSP_ERR_NOT_OPEN | Device is not open. |
| fsp_err_t R_RIIC_SLAVE_Close | ( | i2c_slave_ctrl_t *const | p_api_ctrl | ) |
Closes the I2C device.
| FSP_SUCCESS | Device closed successfully. |
| FSP_ERR_NOT_OPEN | Device not opened. |
| FSP_ERR_ASSERTION | p_api_ctrl is NULL. |
| fsp_err_t R_RIIC_SLAVE_CallbackSet | ( | i2c_slave_ctrl_t *const | p_api_ctrl, |
| void(*)(i2c_slave_callback_args_t *) | p_callback, | ||
| void *const | p_context, | ||
| i2c_slave_callback_args_t *const | p_callback_memory | ||
| ) |
Updates the user callback and has option of providing memory for callback structure. Implements i2c_slave_api_t::callbackSet
| FSP_SUCCESS | Callback updated successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |