RZV Flexible Software Package Documentation
Release v3.0.0
|
|
Driver for the I/O Ports peripheral on RZ MPUs. 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, port group function for the ELC, or bus control pins.
The IOPORT HAL module can configure the following pin settings:
The module also provides the following functionality:
The I/O PORT HAL module must be configured by the user for the desired operation.
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
General > Name | Name must be a valid C symbol | g_ioport | Module name. |
General > Pin Configuration Name | Name must be a valid C symbol | g_bsp_pin_cfg | Name for pin configuration structure |
ELC Output Port Group 1 > Trigger Source | MCU Specific Options | ELC source that will trigger Output port group 1 | |
ELC Output Port Group 1 > Port Selection | MCU Specific Options | Select multiple port number that specify in Ouput port group 1 | |
ELC Output Port Group 1 > Output Operation | MCU Specific Options | Select output operation for Output port group 1. When select toggle output, the target Port m Mode register should be set to 11b: Output (Output data is input to input buffer) | |
ELC Output Port Group 2 > Trigger Source | MCU Specific Options | ELC source that will trigger Output port group 2 | |
ELC Output Port Group 2 > Port Selection | MCU Specific Options | Select multiple port number that specify in Ouput port group 2 | |
ELC Output Port Group 2 > Output Operation | MCU Specific Options | Select output operation for Output port group 2. When select toggle output, the target Port m Mode register should be set to 11b: Output (Output data is input to input buffer) | |
ELC Input Port Group 1 > Buffer Initial Value > P60 | MCU Specific Options | Set initial input state for P60 | |
ELC Input Port Group 1 > Buffer Initial Value > P61 | MCU Specific Options | Set initial input state for P61 | |
ELC Input Port Group 1 > Buffer Initial Value > P62 | MCU Specific Options | Set initial input state for P62 | |
ELC Input Port Group 1 > Buffer Initial Value > P63 | MCU Specific Options | Set initial input state for P63 | |
ELC Input Port Group 1 > Buffer Initial Value > P64 | MCU Specific Options | Set initial input state for P64 | |
ELC Input Port Group 1 > Buffer Initial Value > P65 | MCU Specific Options | Set initial input state for P65 | |
ELC Input Port Group 1 > Buffer Initial Value > P66 | MCU Specific Options | Set initial input state for P66 | |
ELC Input Port Group 1 > Buffer Initial Value > P67 | MCU Specific Options | Set initial input state for P67 | |
ELC Input Port Group 1 > Trigger Source | MCU Specific Options | ELC source that will trigger Input port group 1 | |
ELC Input Port Group 1 > Event Link Control | MCU Specific Options | Set input port group 1 enablement | |
ELC Input Port Group 1 > Port Selection | MCU Specific Options | Select multiple port number that specify in Input port group 1 | |
ELC Input Port Group 1 > Edge Detection | MCU Specific Options | Select edge detection that will trigger Input port group 1 | |
ELC Input Port Group 1 > Buffer Overwrite | MCU Specific Options | Set whether preventing overwriting ELC Port Buffer Register before reading it | |
ELC Input Port Group 2 > Buffer Initial Value > P80 | MCU Specific Options | Set initial input state for P80 | |
ELC Input Port Group 2 > Buffer Initial Value > P81 | MCU Specific Options | Set initial input state for P81 | |
ELC Input Port Group 2 > Buffer Initial Value > P82 | MCU Specific Options | Set initial input state for P82 | |
ELC Input Port Group 2 > Buffer Initial Value > P83 | MCU Specific Options | Set initial input state for P83 | |
ELC Input Port Group 2 > Buffer Initial Value > P84 | MCU Specific Options | Set initial input state for P84 | |
ELC Input Port Group 2 > Buffer Initial Value > P85 | MCU Specific Options | Set initial input state for P85 | |
ELC Input Port Group 2 > Buffer Initial Value > P86 | MCU Specific Options | Set initial input state for P86 | |
ELC Input Port Group 2 > Buffer Initial Value > P87 | MCU Specific Options | Set initial input state for P87 | |
ELC Input Port Group 2 > Trigger Source | MCU Specific Options | ELC source that will trigger Input port group 2 | |
ELC Input Port Group 2 > Event Link Control | MCU Specific Options | Set input port group 2 enablement | |
ELC Input Port Group 2 > Port Selection | MCU Specific Options | Select multiple port number that specify in Input port group 2 | |
ELC Input Port Group 2 > Edge Detection | MCU Specific Options | Select edge detection that will trigger Input port group 2 | |
ELC Input Port Group 2 > Buffer Overwrite | MCU Specific Options | Set whether preventing overwriting ELC Port Buffer Register before reading it | |
ELC Single Port 0 > Common > Event Link Control | MCU Specific Options | Set single port 0 enablement | |
ELC Single Port 0 > Common > Event Direction | MCU Specific Options | Select event direction for Single port 0 | |
ELC Single Port 0 > Common > Port selection | MCU Specific Options | Select port number for Single port 0 | |
ELC Single Port 0 > Output Direction Setting > Trigger Source | MCU Specific Options | ELC source that will trigger Single output port 0 | |
ELC Single Port 0 > Output Direction Setting > Output Operation | MCU Specific Options | Select output operation for Single output port 0. When select toggle output, the target Port m Mode register should be set to 11b: Output (Output data is input to input buffer) | |
ELC Single Port 0 > Input Direction Setting > Edge Detection | MCU Specific Options | Select edge detection that will trigger Single input port 0 | |
ELC Single Port 1 > Common > Event Link Control | MCU Specific Options | Set single port 1 enablement | |
ELC Single Port 1 > Common > Event Direction | MCU Specific Options | Select event direction for Single port 1 | |
ELC Single Port 1 > Common > Port selection | MCU Specific Options | Select port number for Single port 1 | |
ELC Single Port 1 > Output Direction Setting > Trigger Source | MCU Specific Options | ELC source that will trigger Single output port 1 | |
ELC Single Port 1 > Output Direction Setting > Output Operation | MCU Specific Options | Select output operation for Single output port 1. When select toggle output, the target Port m Mode register should be set to 11b: Output (Output data is input to input buffer) | |
ELC Single Port 1 > Input Direction Setting > Edge Detection | MCU Specific Options | Select edge detection that will trigger Single input port 1 | |
ELC Single Port 2 > Common > Event Link Control | MCU Specific Options | Set single port 2 enablement | |
ELC Single Port 2 > Common > Event Direction | MCU Specific Options | Select event direction for Single port 2 | |
ELC Single Port 2 > Common > Port selection | MCU Specific Options | Select port number for Single port 2 | |
ELC Single Port 2 > Output Direction Setting > Trigger Source | MCU Specific Options | ELC source that will trigger Single output port 2 | |
ELC Single Port 2 > Output Direction Setting > Output Operation | MCU Specific Options | Select output operation for Single output port 2. When select toggle output, the target Port m Mode register should be set to 11b: Output (Output data is input to input buffer) | |
ELC Single Port 2 > Input Direction Setting > Edge Detection | MCU Specific Options | Select edge detection that will trigger Single input port 2 | |
ELC Single Port 3 > Common > Event Link Control | MCU Specific Options | Set single port 3 enablement | |
ELC Single Port 3 > Common > Event Direction | MCU Specific Options | Select event direction for Single port 3 | |
ELC Single Port 3 > Common > Port selection | MCU Specific Options | Select port number for Single port 3 | |
ELC Single Port 3 > Output Direction Setting > Trigger Source | MCU Specific Options | ELC source that will trigger Single output port 3 | |
ELC Single Port 3 > Output Direction Setting > Output Operation | MCU Specific Options | Select output operation for Single output port 3. When select toggle output, the target Port m Mode register should be set to 11b: Output (Output data is input to input buffer) | |
ELC Single Port 3 > Input Direction Setting > Edge Detection | MCU Specific Options | Select edge detection that will trigger Single input port 3 |
The I/O PORT HAL module does not require a specific clock configuration.
The IOPORT module is used for configuring pins.
Depending on pin configuration, the IOPORT module can perform automatic reads or writes on ports 6 or 8 on receipt of an ELC event. Multiple pins can be specified from ports 6 or 8 as port group function by the user.
In the input port group function, when an event is received by a port, the state of the input pins on the port is saved in a hardware register. The functions R_IOPORT_PinEventInputRead and R_IOPORT_PortEventInputRead allow reading the last event input state of pins specified to the input port group. In addition, the function can be configured to trigger an ELC event on rising, falling or both edges. This event can be used to activate other modules when the pin changes state.
In the output port group function, when an event is received by a port, the state of output pins on the port is set high, low, toggle or buffer value based on settings configured by the user. The event-triggered pin output can be configured to high or low output through R_IOPORT_PortEventOutputWrite.
Depending on pin configuration, the IOPORT module can perform automatic writes or links to other module on single pin of ports 6 or 8 on receipt of an ELC event. Pins on ports 6 or 8 can be configured to four single port function by the user.
When the single port function is received an event from other modules, the state of an output pin specified as the single port function is set high, low or toggle output based on settings configured by the user. The event-triggered pin output can be configured to high or low output through R_IOPORT_PinEventOutputWrite.
In addition, a pin specified as the single port function can be configured to trigger an ELC event on rising, falling or both edges. This event can be used to activate other modules when the pin changes state.
This is a basic example of minimal use of the IOPORT in an application.
This example uses IOPORT to configure and toggle a pin to blink an LED.
This is an example of using IOPORT with ELC events. The ELC event system allows the captured data to be stored when it occurs and then read back at a later time.
Data Structures | |
struct | ioport_instance_ctrl_t |
struct | ioport_event_single_t |
struct | ioport_event_group_output_t |
struct | ioport_event_group_input_t |
struct | ioport_extend_cfg_t |
Enumerations | |
enum | ioport_peripheral_t |
enum | ioport_cfg_options_t |
enum | ioport_event_pin_selection_t |
enum | ioport_event_output_operation_t |
enum | ioport_event_control_t |
enum | ioport_event_direction_t |
enum | ioport_event_detection_t |
enum | ioport_event_initial_buffer_value_t |
enum | ioport_noise_filter_irq_port_offset_t |
enum | ioport_noise_filter_dreq_port_offset_t |
struct ioport_instance_ctrl_t |
IOPORT private control block. DO NOT MODIFY. Initialization occurs when R_IOPORT_Open() is called.
struct ioport_event_single_t |
Single port configuration
Data Fields | ||
---|---|---|
ioport_event_control_t | event_control | Event link control for single port. |
ioport_event_direction_t | direction | Event direction for single port. |
uint16_t | port_num | Port number specified to single port. |
ioport_event_output_operation_t | operation | Single port operation select. |
ioport_event_detection_t | edge_detection | Edge detection select. |
struct ioport_event_group_output_t |
Output port group configuration
Data Fields | ||
---|---|---|
uint8_t | pin_select | Port number specified to output port group. |
ioport_event_output_operation_t | operation | Port group operation select. |
struct ioport_event_group_input_t |
Input port group configuration
Data Fields | ||
---|---|---|
ioport_event_control_t | event_control | Event link control for input port group. |
ioport_event_detection_t | edge_detection | Edge detection select. |
ioport_event_control_t | overwrite_control | Buffer register overwrite control. |
uint8_t | pin_select | Port number specified to input port group. |
uint8_t | buffer_init_value | Buffer register initial value. |
struct ioport_extend_cfg_t |
IOPORT extended configuration for event link function
Data Fields | ||
---|---|---|
ioport_event_group_output_t const * |
p_port_group_output_cfg | Pointer to output port group configuration. |
ioport_event_group_input_t const * | p_port_group_input_cfg | Pointer to input port group configuration. |
ioport_event_single_t const * | p_single_port_cfg | Pointer to single input port configuration. |
enum ioport_peripheral_t |
Superset of all peripheral functions.
enum ioport_cfg_options_t |
Options to configure pin functions
Pin selection for port group
Port group operation
Input event edge detection
Superset of offset for all IRQ functions.
Superset of offset for all DREQ functions.
fsp_err_t R_IOPORT_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 PFS register(s) |
FSP_ERR_ASSERTION | NULL pointer |
FSP_ERR_ALREADY_OPEN | Module is already open. |
fsp_err_t R_IOPORT_Close | ( | ioport_ctrl_t *const | p_ctrl | ) |
Resets IOPORT registers. Implements ioport_api_t::close
FSP_SUCCESS | The IOPORT was successfully uninitialized |
FSP_ERR_ASSERTION | p_ctrl was NULL |
FSP_ERR_NOT_OPEN | The module has not been opened |
fsp_err_t R_IOPORT_PinsCfg | ( | ioport_ctrl_t *const | p_ctrl, |
const ioport_cfg_t * | p_cfg | ||
) |
Configures the functions of multiple pins by loading configuration data into each registers. Implements ioport_api_t::pinsCfg.
This function initializes the supplied list of each registers with the supplied values. This data define in pin_data.c. Different pin configurations can be loaded for different situations such as low power modes and testing.
FSP_SUCCESS | Pin configuration data written to each registers |
FSP_ERR_NOT_OPEN | The module has not been opened |
FSP_ERR_ASSERTION | NULL pointer |
fsp_err_t R_IOPORT_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_IOPORT_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 | The function is not supported on the device which doesn't support ELC. |
fsp_err_t R_IOPORT_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 |
FSP_ERR_UNSUPPORTED | The function is not supported on the device which doesn't support ELC. |
fsp_err_t R_IOPORT_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_IOPORT_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 opened |
FSP_ERR_ASSERTION | NULL pointer |
fsp_err_t R_IOPORT_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[9:8] corresponds to pin 4, bit[7:6] to pin 3, and so on. If bits are set to b'11 then the corresponding pin will be changed to an input or an output or Hi-Z as specified by the direction values. If a mask bits are set to b'00 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_IOPORT_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 | The function is not supported on the device which doesn't support ELC. |
fsp_err_t R_IOPORT_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_UNSUPPORTED | The function is not supported on the device which doesn't support ELC. |
fsp_err_t R_IOPORT_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 4 corresponds to pin 4, bit 3 to pin 3, 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_IOPORT_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 4 corresponds to pin 4, bit 3 to pin 3, 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 pointer |