![]() |
Synergy Software Package User's Manual
|
The I/O Port HAL module implements a high-level API for controlling I/O pins, configuring the board's pins and manipulating I/O pins. The operating state of an I/O pin can be set via the Synergy configurator. When the Synergy project is built, a pin configuration file is created. When the application runs, the BSP will configure the MCU IO port accordingly, using the same API functions described in this document.
The I/O PORT HAL module can perform the following functions:
The following hardware features are, or are not, supported by SSP for GPIO.
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | Port Direction Setting | Input Data Read function | Output Port Write function | Pin Mode Control | Ethernet Mode Configuration | ELC_PORTn Event Input Read function* | ELC_PORTn Event Output Setting * |
|---|---|---|---|---|---|---|---|
| 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 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
The I/O Port HAL module defines APIs for reading and writing from particular pins and ports. 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.
I/O PORT HAL Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| init | g_ioport.p_api->init(g_ioport.p_cfg);Initialize configuration of multiple pins. |
| pinCfg | g_ioport.p_api->pinCfg(IOPORT_PORT_00_PIN_00, IOPORT_CFG_IRQ_ENABLE | IOPORT_CFG_PORT_DIRECTION_INPUT);Configure settings for an individual pin. |
| pinDirectionSet | g_ioport.p_api->pinDirectionSet(IOPORT_PORT_00_PIN_00, IOPORT_DIRECTION_INPUT);Set the pin direction of a pin. |
| pinEventInputRead | g_ioport.p_api->pinEventInputRead(IOPORT_PORT_00_PIN_00, &pin_level);Read the event (ELC) input data of the specified pin and return the level. |
| pinEventOutputWrite | g_ioport.p_api->pinEventOutputWrite(IOPORT_PORT_00_PIN_00, IOPORT_PIN_LEVEL_HIGH);Write pin event (ELC) data. |
| pinEthernetModeCfg | g_ioport.p_api->pinEthernetModeCfg(IOPORT_ETHERNET_CHANNEL_0, IOPORT_ETHERNET_MODE_MII);Configure the PHY mode of the Ethernet channels. |
| pinRead | g_ioport.p_api->pinRead(IOPORT_PORT_00_PIN_00, &pin_level);Read level of a pin. |
| pinWrite | g_ioport.p_api->pinWrite(IOPORT_PORT_00_PIN_00, IOPORT_PIN_LEVEL_HIGH);Write specified level to a pin. |
| portDirectionSet | g_ioport.p_api->portDirectionSet(IOPORT_PORT_00, direction_values, mask);Set the direction of one or more pins on a port. |
| portEventInputRead | g_ioport.p_api->portEventInputRead(IOPORT_PORT_00, &pin_levels);Read captured event (ELC) data for a port. |
| portEventOutputWrite | g_ioport.p_api->portEventOutputWrite(IOPORT_PORT_00, pin_levels, mask);Write event (ELC) output data for a port. |
| portRead | g_ioport.p_api->portRead(IOPORT_PORT_00, &pin_levels);Read states of pins on the specified port. |
| portWrite | g_ioport.p_api->portWrite(IOPORT_PORT_00, pin_levels, mask);Write to multiple pins on a port. |
| versionGet | g_ioport.p_api->versionGet(&version);Retrieve version information using the version pointer. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | API Call Successful. |
| SSP_ERR_INVALID_ARGUMENT | The port/pin/mask/direction/level (and so forth) not valid. |
| SSP_ERR_ASSERTION | Unexpected null pointer. |
| SSP_ERR_UNSUPPORTED | Feature not supported – for instance Ethernet configuration not supported on the device. |
The I/O Port HAL module provides the ability to access the I/O ports of a device at both bit and port level; both port and pin direction can be changed. In addition, a number of configuration APIs are provided to change the functionality of individual pins.
The I/O Port HAL module provides the following operations for configuring pins:
pin, VBATT support).pin).port).pin and written level level).port and pin mask mask).port and pin mask mask).pin and written direction direction).port).pin).port and pin mask mask_value).pin and written level ioport_api_t::pinRead).channel and mode mode).This section describes how to include the I/O PORT HAL Module in an application using the SSP configurator.
To add the I/O Port 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 I/O Port Driver is g_ioport0. This name can be changed in the associated Properties window.)
I/O PORT HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_ioport I/O Port driver on r_ioport | Threads | Highlight HAL/Common and select New> Driver> System> I/O Port Driver on r_ioport |
When the I/O Port Driver on r_ioport 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 Gray band 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 I/O PORT 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 I/O PORT HAL Module on r_ioport
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enable or disable the parameter error checking. |
| Name | g_ioport | Module name. |
The I/O PORT HAL module does not require a specific clock configuration.
There are no pins associated directly with the I/O PORT HAL Module that require configuration.
The typical steps in using the I/O PORT HAL module in an application are:
These common steps are illustrated in a typical operational flow diagram in the following figure: