![]() |
Synergy Software Package User's Manual
|
The I2C Slave HAL Module provides a high-level API for I2C slave applications and uses the RIIC peripheral on the Synergy MCU. Callbacks are provided to signal read/write request received from master and transfer completion events.
RIIC Slave driver supported features:
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | I2C Format | SMBus Format | Master Mode | Slave Mode | Fast Mode Plus | Selectable duty cycle |
|---|---|---|---|---|---|---|
| S124 | ✓ | ⌧ | ⌧ | ✓ | N/A | ⌧ |
| S128 | ✓ | ⌧ | ⌧ | ✓ | N/A | ⌧ |
| S1JA | ✓ | ⌧ | ⌧ | ✓ | N/A | ⌧ |
| S3A1 | ✓ | ⌧ | ⌧ | ✓ | N/A | ⌧ |
| S3A3 | ✓ | ⌧ | ⌧ | ✓ | N/A | ⌧ |
| S3A6 | ✓ | ⌧ | ⌧ | ✓ | N/A | ⌧ |
| S3A7 | ✓ | ⌧ | ⌧ | ✓ | N/A | ⌧ |
| S5D3 | ✓ | ⌧ | ⌧ | ✓ | ✓ | ⌧ |
| S5D5 | ✓ | ⌧ | ⌧ | ✓ | ✓ | ⌧ |
| S5D9 | ✓ | ⌧ | ⌧ | ✓ | ✓ | ⌧ |
| S7G2 | ✓ | ⌧ | ⌧ | ✓ | ✓ | ⌧ |
| MCU Group | Configurable to up to three different slave addresses | 7- and 10- bit address formats | General call address, Device ID address and SMBus host address detectable | Automatic loading of the acknowledge bit | SDA output delay function | Selectable Wait functions (8/9 or 9/1) |
|---|---|---|---|---|---|---|
| S124 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S128 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S1JA | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S3A1 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S3A3 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S3A6 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S3A7 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S5D3 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S5D5 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S5D9 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| S7G2 | One slave address | 7 and 10-bit | ⌧ | ✓ | ⌧ | ⌧ |
| MCU Group | Full Arbitration Support | Internal Detect Time-Out | Programmable Digital Noise Filters | Support all Interrupt Sources | Event link function through ELC HAL driver |
|---|---|---|---|---|---|
| S124 | Slave, NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S128 | Slave, NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S1JA | Slave, NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S3A1 | Slave, NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S3A3 | Slave and NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S3A6 | Slave and NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S3A7 | Slave, NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S5D3 | Slave, NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S5D5 | Slave, NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S5D9 | Slave, NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
| S7G2 | Slave and NACK arbitration | ✓ | ⌧ | ✓ | ⌧ |
The I2C RIIC Slave HAL Module defines APIs for reading and writing to a master I2C device. A complete list of the available APIs, an example API call and a short description of each can be found in the following table. A table of status return values follows the API summary table.
I2C Slave HAL Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| open | g_i2c.p_api->open(g_i2c.p_ctrl, g_i2c.p_cfg);Open the instance and initialize the hardware. |
| close | g_i2c.p_api->close(g_i2c.p_ctrl);Closes the driver and releases the I2C device. |
| masterWriteSlaveRead | g_i2c.p_api->masterWriteSlaveRead(g_i2c.p_ctrl, &destination, bytes);Performs a read operation on an I2C device. |
| masterReadSlaveWrite | g_i2c.p_api->masterReadSlaveWrite(g_i2c.p_ctrl, &source, bytes);Performs a write operation on an I2C device. |
| versionGet | g_i2c.p_api->versionGet(&version);Retrieve the API version with the version pointer. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | API Call Successful. |
| SSP_ERR_INVALID_POINTER | Pointer is NULL. |
| SSP_ERR_IN_USE | Attempted to open an already open device instance. |
| SSP_ERR_ABORTED | Device was closed while a transfer was in progress. |
| SSP_ERR_INVALID_ARGUMENT | Parameter has invalid value. |
The I2C RIIC Slave HAL Module supports transfers to an I2C Master device. Callbacks are provided to enable the application identify the occurrence of any of the following events.
This is the initial version of I2C RIIC Slave Driver with only basic functionality implemented. The following limitations are known:
This section describes how to include the I2C Slave HAL Module in an application using the SSP configurator.
To add the I2C Slave Driver to an application, simply add it to a thread using the stacks selection sequence given in the following table. (The default name for the I2C Slave Driver is g_i2c0. This name can be changed in the associated Properties window.)
I2C Slave HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_i2c0 I2C Slave Driver on r_riic_slave | Threads | New Stack> Driver> Communications> I2C Slave Driver on r_riic_slave |
When the I2C Slave Driver on r_riic_slave is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower‑level modules. Any modules needing additional configuration information have the box text highlighted in Red. Modules with a Grayband are individual modules that stand alone. Modules with a Blue band are shared or common; they need only be added once and can be used by multiple stacks. Modules with a Pink band can require the selection of lower-level modules; these are either optional or recommended. (This is indicated in the block with the inclusion of this text.) If the addition of lower-level modules is required, the module description include Add in the text. Clicking on any Pink banded modules brings up the New icon and displays possible choices.
The I2C Slave HAL Module must be configured by the user for the desired operation. The available configuration settings and defaults for all the user-accessible properties are given in the properties tab within the SSP configurator and are shown in the following tables for easy reference. Only properties that can be changed without causing conflicts are available for modification. Other properties are locked and not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error-prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP Configurator and are shown in the following tables for easy reference.
Configuration Settings for the I2C Slave HAL Module on r_riic_slave
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enable or disable parameter error checking. |
| Name | g_i2c0 | Module name. |
| Channel | 0 | Specify the IIC channel to be used with this configuration. |
| Rate | Standard, Fast-mode, Fast-mode plus Default: Standard | Transfer rate to which the IIC peripheral should be configured to operate. |
| Slave Address | 0x00 | Set the address of the device as the I2C slave address. Both 7-bit and 10-bit addresses are supported. |
| Address Mode | 7-Bit, 10 Bit Default: 7-Bit | Address mode selection. |
| Callback | NULL | A user callback function can be registered in i2c_api_master_t::open. If this callback function is provided, it will be called from the interrupt service routine (ISR) for each of the conditions defined in i2c_event_t. Warning: Since the callback is called from an ISR, do not use blocking calls or lengthy processing. Spending excessive time in an ISR can affect the responsiveness of the system. |
| Receive Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Priority 12 | Receive interrupt priority selection. |
| Transmit Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Priority 12 | Transmit interrupt priority selection. |
| Transmit End Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Priority 12 | Transmit End interrupt priority selection. |
| Error Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Priority 12 | Error interrupt priority selection. |
The RIIC peripheral module uses PCLKB as its clock source.
The RIIC peripheral module uses pins on the MCU to communicate to external devices. I/O pins must be selected and configured as required by the external device. The following table illustrates the method for selecting the pins within the SSP configuration window and the subsequent table illustrates an example selection for the pins:
Pin Selection for the I2C Slave HAL Module on r_riic_slave
| Resource | ISDE Tab | Pin selection Sequence |
|---|---|---|
| I2C | Pins | Select Peripherals> Connectivity: IIC> IIC0. |
Pin Configuration Settings for the I2C Slave HAL Module on r_riic_slave
| Pin Configuration Property | Value | Description |
|---|---|---|
| Pin Group Selection | _A only, _B only, Mixed Default: _A only | Select Simple I2C as the Operation Mode for I2C on SCI. |
| Operation Mode | Enabled, Disabled Default: Disabled | Enable or disable peripheral module. |
| SDA | None, P401, P407 Default: None | SDA Pin. |
| SCL | None, P400, P204 Default: None | SCL Pin. |
The sequence for using the I2C Slave HAL module (blocking mode) in an application is:
1. Initialize and open the I2C Slave HAL Module using the i2c_api_slave_t::open API.
2. Transfer data to the master using the i2c_api_slave_t::masterReadSlaveWrite API.
3. Receive data from the master using the i2c_api_slave_t::masterWriteSlaveRead API.
4. Close the channel using the i2c_api_slave_t::close API.
These steps are illustrated in a typical operational flow diagram in the following figure:
The sequence for using the I2C Slave HAL module (non-blocking mode) in an application is:
These steps above with registered callback are illustrated in a typical operational flow diagram in the following figure: