![]() |
RAFW Flexible Software Package Documentation
Release v2.0.1
|
|
Driver for the I/O Ports peripheral on RAFW MCUs. This module implements the I/O Port Interface.
The I/O port pins operate as general I/O port pins, I/O pins for peripheral modules, interrupt input pins, analog I/O, response pins for the ELC, or bus control pins.
The GPIO_W HAL module can configure the following pin settings:
| --—Features-------------— | RA6B1 | RA6U1 | RA6B2 | RA6W1 | RA6W3 |
|---|---|---|---|---|---|
| Peripheral event assignment | Supported | Supported | Supported | Not Supported | Supported |
| Response task assignment | Supported | Supported | Supported | Not Supported | Supported |
The module also provides the following functionality:
The I/O PORT HAL module must be configured by the user for the desired operation. The operating state of an I/O pin can be set via the RA Configuraton tool. When the project is built a pin configuration file is created. The BSP will automatically configure the MCU IO ports accordingly at startup using the same API functions mentioned in this document.
| Configuration | Options | Default | Description |
|---|---|---|---|
| Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
| Configuration | Options | Default | Description |
|---|---|---|---|
| Name | Name must be a valid C symbol | g_gpio_w | Module name. |
| Pin Configuration Name | Name must be a valid C symbol | g_bsp_pin_cfg | Name for pin configuration structure |
The GPIO_W HAL module does not require a specific clock configuration.
The GPIO_W module is used for configuring pins.
This is a basic example of minimal use of the GPIO_W in an application.
This example uses GPIO_W to configure and toggle a pin to blink an LED.
ELC Example is available only in supported devices:
| RA6B1 | RA6U1 | RA6B2 | RA6W1 | RA6W3 |
|---|---|---|---|---|
| Supported | Supported | Supported | Not Supported | Supported |
This is an example of using GPIO_W with ELC events. Any pin can be assigned to 1) a peripheral event which can be linked to any event via ELC. 2) a response task performed when the linked event occurs. SET,RESET or TOGGLE. The response can be found by simply reading the corresponding data register.
Data Structures | |
| struct | gpio_w_instance_ctrl_t |
| struct | pad_power_t |
| struct | pad_weak_t |
| struct | sel_pin_clk_out_t |
| struct | gpio_w_extended_cfg_t |
Enumerations | |
| enum | gpio_w_peripheral_t |
| struct gpio_w_instance_ctrl_t |
GPIO_W private control block. DO NOT MODIFY. Initialization occurs when R_GPIO_W_Open() is called.
| struct pad_power_t |
| struct pad_weak_t |
Pins driving strength configuration structure
| struct sel_pin_clk_out_t |
Map clock output to selectable pin structure
| Data Fields | ||
|---|---|---|
| bsp_io_clk_func_t | clk_sel |
Select which clock to map |
| bool | clk_en |
Enable mapping of the selected clock signal |
| struct gpio_w_extended_cfg_t |
Extended configuration struct
| Data Fields | ||
|---|---|---|
| pad_power_t | power |
Pins power configuration |
| pad_weak_t | weak_pad_power |
Pins driving strength configuration |
| bsp_io_clk_output_t | fixed_pin_clk_out |
Map clock output to fixed pin |
| sel_pin_clk_out_t | sel_pin_clk_out |
Map clock output to selectable pin |
| enum gpio_w_peripheral_t |
Superset of all peripheral functions.
| fsp_err_t R_GPIO_W_Open | ( | ioport_ctrl_t *const | p_ctrl, |
| const ioport_cfg_t * | p_cfg | ||
| ) |
Initializes internal driver data, then calls pin configuration function to configure pins.
| FSP_SUCCESS | Pin configuration data written to MODE, Set port pins and Reset port pins register(s) |
| FSP_ERR_ASSERTION | NULL pointer |
| FSP_ERR_ALREADY_OPEN | Module is already open. |
| fsp_err_t R_GPIO_W_Close | ( | ioport_ctrl_t *const | p_ctrl | ) |
Resets GPIO_W registers. Implements ioport_api_t::close
| FSP_SUCCESS | The GPIO_W was successfully uninitialized |
| FSP_ERR_ASSERTION | p_ctrl was NULL |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| fsp_err_t R_GPIO_W_PinsCfg | ( | ioport_ctrl_t *const | p_ctrl, |
| const ioport_cfg_t * | p_cfg | ||
| ) |
Configures the functions of multiple pins by loading configuration data into pin MODE,Set port pins and Reset port pins registers. Implements ioport_api_t::pinsCfg.
This function initializes the supplied list of MODE, Set port pins and Reset port pins registers with the supplied values. This data can be generated by the Pins tab of the RAFW Configuration editor or manually by the developer. Different pin configurations can be loaded for different situations such as low power modes and testing.
| FSP_SUCCESS | Pin configuration data written to MODE,Set port pins and Reset port pins register(s) |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| FSP_ERR_ASSERTION | NULL pointer |
| fsp_err_t R_GPIO_W_PinCfg | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_pin_t | pin, | ||
| uint32_t | cfg | ||
| ) |
Configures the settings of a pin. Implements ioport_api_t::pinCfg.
| FSP_SUCCESS | Pin configured |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| FSP_ERR_ASSERTION | NULL pointer |
| fsp_err_t R_GPIO_W_PinRead | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_pin_t | pin, | ||
| bsp_io_level_t * | p_pin_value | ||
| ) |
Reads the level on a pin. Implements ioport_api_t::pinRead.
| FSP_SUCCESS | Pin read |
| FSP_ERR_ASSERTION | NULL pointer |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| fsp_err_t R_GPIO_W_PortRead | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_t | port, | ||
| ioport_size_t * | p_port_value | ||
| ) |
Reads the value on an IO port. Implements ioport_api_t::portRead.
The specified port will be read, and the levels for all the pins will be returned. Each bit in the returned value corresponds to a pin on the port. For example, bit 7 corresponds to pin 7, bit 6 to pin 6, and so on.
| FSP_SUCCESS | Port read |
| FSP_ERR_ASSERTION | NULL pointer |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| fsp_err_t R_GPIO_W_PortWrite | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_t | port, | ||
| ioport_size_t | value, | ||
| ioport_size_t | mask | ||
| ) |
Writes to multiple pins on a port. Implements ioport_api_t::portWrite.
The input value will be written to the specified port. Each bit in the value parameter corresponds to a bit on the port. For example, bit 7 corresponds to pin 7, bit 6 to pin 6, and so on. Each bit in the mask parameter corresponds to a pin on the port.
Only the bits with the corresponding bit in the mask value set will be updated. For example, value = 0xFFFF, mask = 0x0003 results in only bits 0 and 1 being updated.
| FSP_SUCCESS | Port written to |
| FSP_ERR_INVALID_ARGUMENT | The port and/or mask not valid |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| FSP_ERR_ASSERTION | NULL pointerd |
| fsp_err_t R_GPIO_W_PinWrite | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_pin_t | pin, | ||
| bsp_io_level_t | level | ||
| ) |
Sets a pin's output either high or low. Implements ioport_api_t::pinWrite.
| FSP_SUCCESS | Pin written to |
| FSP_ERR_INVALID_ARGUMENT | The pin and/or level not valid |
| FSP_ERR_NOT_OPEN | The module has not been opene |
| FSP_ERR_ASSERTION | NULL pointerd |
| fsp_err_t R_GPIO_W_PortDirectionSet | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_t | port, | ||
| ioport_size_t | direction_values, | ||
| ioport_size_t | mask | ||
| ) |
Sets the direction of individual pins on a port. Implements ioport_api_t::portDirectionSet().
Multiple pins on a port can be set to inputs or outputs at once. Each bit in the mask parameter corresponds to a pin on the port. For example, bit 7 corresponds to pin 7, bit 6 to pin 6, and so on. If a bit is set to 1 then the corresponding pin will be changed to an input or an output as specified by the direction values. If a mask bit is set to 0 then the direction of the pin will not be changed.
| FSP_SUCCESS | Port direction updated |
| FSP_ERR_INVALID_ARGUMENT | The port and/or mask not valid |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| FSP_ERR_ASSERTION | NULL pointer |
| fsp_err_t R_GPIO_W_PortEventInputRead | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_t | port, | ||
| ioport_size_t * | p_event_data | ||
| ) |
Reads the value of the event input data. Implements ioport_api_t::portEventInputRead().
The event input data for the port will be read. Each bit in the returned value corresponds to a pin on the port. For example, bit 7 corresponds to pin 7, bit 6 to pin 6, and so on.
The port event data is captured in response to a trigger from the ELC. This function enables this data to be read. Using the event system allows the captured data to be stored when it occurs and then read back at a later time.
| FSP_SUCCESS | Port read |
| FSP_ERR_INVALID_ARGUMENT | Port not a valid ELC port |
| FSP_ERR_ASSERTION | NULL pointer |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| FSP_ERR_UNSUPPORTED | Function not supported. |
| fsp_err_t R_GPIO_W_PinEventInputRead | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_pin_t | pin, | ||
| bsp_io_level_t * | p_pin_event | ||
| ) |
Reads the value of the event input data of a specific pin. Implements ioport_api_t::pinEventInputRead.
The pin event data is captured in response to a trigger from the ELC. This function enables this data to be read. Using the event system allows the captured data to be stored when it occurs and then read back at a later time.
| FSP_SUCCESS | Pin read |
| FSP_ERR_ASSERTION | NULL pointer |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| FSP_ERR_INVALID_ARGUMENT | Port is not valid ELC PORT. |
| FSP_ERR_UNSUPPORTED | Function not supported. |
| fsp_err_t R_GPIO_W_PortEventOutputWrite | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_t | port, | ||
| ioport_size_t | event_data, | ||
| ioport_size_t | mask_value | ||
| ) |
This function writes the set and reset event output data for a port. Implements ioport_api_t::portEventOutputWrite.
Using the event system enables a port state to be stored by this function in advance of being output on the port. The output to the port will occur when the ELC event occurs.
The input value will be written to the specified port when an ELC event configured for that port occurs. Each bit in the value parameter corresponds to a bit on the port. For example, bit 7 corresponds to pin 7, bit 6 to pin 6, and so on. Each bit in the mask parameter corresponds to a pin on the port.
| FSP_SUCCESS | Port event data written |
| FSP_ERR_INVALID_ARGUMENT | Port or Mask not valid |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| FSP_ERR_ASSERTION | NULL pointer |
| fsp_err_t R_GPIO_W_PinEventOutputWrite | ( | ioport_ctrl_t *const | p_ctrl, |
| bsp_io_port_pin_t | pin, | ||
| bsp_io_level_t | pin_value | ||
| ) |
This function writes the event output data value to a pin. Implements ioport_api_t::pinEventOutputWrite.
Using the event system enables a pin state to be stored by this function in advance of being output on the pin. The output to the pin will occur when the ELC event occurs.
| FSP_SUCCESS | Pin event data written |
| FSP_ERR_INVALID_ARGUMENT | Port or Pin or value not valid |
| FSP_ERR_NOT_OPEN | The module has not been opened |
| FSP_ERR_ASSERTION | NULL pointer |