Driver for the POEG peripheral on RZ MPUs. This module implements the POEG Interface.
Overview
The POEG module can be used to configure events to disable GPT GTIOC output pins.
Features
The POEG module has the following features:
- Supports disabling GPT output pins based on GTETRG input pin level.
- Supports disabling GPT output pins when GTIOC pins are the same level (configurable in the General PWM Timer (r_gpt) driver).
- Supports disabling GPT output pins by software API.
- Supports notifying the application when GPT output pins are disabled by POEG.
- Supports resetting POEG status.
Configuration
Build Time Configurations for r_poeg
The following build time configurations are defined in fsp_cfg/r_poeg_cfg.h:
Configuration | Options | Default | Description |
Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configurations for Timers > Port Output Enable for GPT (r_poeg)
Configuration | Options | Default | Description |
General > Name | Name must be a valid C symbol | g_poeg0 | Module name. |
General > Channel | Channel number must be a positive integer | 0 | Specify the hardware channel. |
General > Trigger | MCU Specific Options | | Select the trigger sources that will enable POEG. Software disable is always supported. This configuration can only be set once after reset. It cannot be modified after the initial setting. |
Input > GTETRG Polarity |
| Active High | Select the polarity of the GTETRG pin. Only applicable if GTETRG pin is selected under Trigger. |
Input > GTETRG Noise Filter |
-
Disabled
-
Clock source / 1
-
Clock source / 8
-
Clock source / 32
-
Clock source / 128
| module.driver.poeg.noise_filter.gtetrg_noise_filter_p0_div_1 | Configure the noise filter for the GTETRG pin. Only applicable if GTETRG pin is selected under Trigger. |
Interrupts > Callback | Name must be a valid C symbol | NULL | A user callback function can be specified here. If this callback function is provided, it will be called from the interrupt service routine (ISR) when GPT output pins are disabled by POEG. |
Interrupts > POEG Interrupt Enable | MCU Specific Options | | Enable the POEG interrupt. |
Interrupts > Interrupt Priority | Value must be an integer between 0 and 255 | 4 | Select the POEG interrupt priority. |
Clock Configuration
The POEG clock is based on the P0 clock frequency.
Pin Configuration
This module can use GTETRGA, GTETRGB, GTETRGC, or GTETRGD as an input signal to disable GPT output pins.
Usage Notes
POEG GTETRG Pin and Channel
The POEG channel number corresponds to the GTETRG input pin that can be used with the channel. GTETRGA must be used with POEG channel 0, GTETRGB must be used with POEG channel 1, etc.
Limitations
The user should be aware of the following limitations when using POEG:
- The POEG trigger source can only be set once per channel. Modifying the POEG trigger source after it is set is not allowed by the hardware.
- The POEG cannot be disabled using this API. The interrupt is disabled in R_POEG_Close(), but the POEG will still disable the GPT output pins if a trigger is detected even if the module is closed.
Examples
POEG Basic Example
This is a basic example of minimal use of the POEG in an application.
void poeg_basic_example (void)
{
assert(FSP_SUCCESS == err);
}
POEG Callback Example
This is an example of a using the POEG callback to restore GPT output operation.
{
do
{
NVIC_DisableIRQ(BSP_VECTOR_IRQ_POEG_GROUP0);
}
◆ poeg_instance_ctrl_t
struct poeg_instance_ctrl_t |
Channel control block. DO NOT INITIALIZE. Initialization occurs when poeg_api_t::open is called.
◆ R_POEG_Open()
Initializes the POEG module and applies configurations. Implements poeg_api_t::open.
- Note
- The poeg_cfg_t::trigger setting can only be configured once after reset. Reopening with a different trigger configuration is not possible.
- Return values
-
FSP_SUCCESS | Initialization was successful. |
FSP_ERR_ASSERTION | A required input pointer is NULL or the source divider is invalid. |
FSP_ERR_ALREADY_OPEN | Module is already open. |
FSP_ERR_IRQ_BSP_DISABLED | poeg_cfg_t::p_callback is not NULL, but ISR is not enabled. ISR must be enabled to use callback. |
FSP_ERR_IP_CHANNEL_NOT_PRESENT | The channel requested in the p_cfg parameter is not available on this device. |
◆ R_POEG_StatusGet()
Get current POEG status and store it in provided pointer p_status. Implements poeg_api_t::statusGet.
- Return values
-
FSP_SUCCESS | Current POEG state stored successfully. |
FSP_ERR_ASSERTION | p_ctrl or p_status was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
◆ R_POEG_CallbackSet()
Updates the user callback with the option to provide memory for the callback argument structure. Implements poeg_api_t::callbackSet.
- Return values
-
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. |
◆ R_POEG_OutputDisable()
Disables GPT output pins. Implements poeg_api_t::outputDisable.
- Return values
-
FSP_SUCCESS | GPT output pins successfully disabled. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
◆ R_POEG_Reset()
Resets status flags. Implements poeg_api_t::reset.
- Note
- Status flags are only reset if the original POEG trigger is resolved. Check the status using R_POEG_StatusGet after calling this function to verify the status is cleared.
- Return values
-
FSP_SUCCESS | Function clear status flags successfully. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
FSP_ERR_NOT_INITIALIZED | The GPT status flags was not clear before the attempt to clear IOCF flag. |
◆ R_POEG_Close()
Disables POEG interrupt. Implements poeg_api_t::close.
- Note
- This function does not disable the POEG.
- Return values
-
FSP_SUCCESS | Successful close. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |