Driver for the GTM peripherals on RZ MPUs. This module implements the Timer Interface.
Overview
The GTM module can be used to count events, generate a periodic interrupt.
Features
The General timer has the following features:
- Two operating modes
- Interval timer mode
- Free-running comparison mode
◆ gtm_instance_ctrl_t
struct gtm_instance_ctrl_t |
Channel control block. DO NOT INITIALIZE. Initialization occurs when timer_api_t::open is called.
◆ gtm_extended_cfg_t
struct gtm_extended_cfg_t |
Optional GTM extension data structure.
◆ gtm_giws_type_t
Optional GTM interrupt setting
Enumerator |
---|
GTM_GIWS_TYPE_DISABLED | Do not generate interrupt when timer started.
|
GTM_GIWS_TYPE_ENABLED | Generates interrupt when timer started.
|
◆ gtm_timer_mode_t
Optional GTM timer mode setting
Enumerator |
---|
GTM_TIMER_MODE_INTERVAL | Use interval timer mode.
|
GTM_TIMER_MODE_FREERUN | Use free-running comparison mode.
|
◆ R_GTM_Close()
Stops counter, disables interrupts, disables output pins, and clears internal driver data. Implements timer_api_t::close.
- Return values
-
FSP_SUCCESS | Timer closed. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | The instance control structure is not opened. |
◆ R_GTM_PeriodSet()
Updates period. The new period is updated immediately and the counter is reset to the maximum value. Implements timer_api_t::periodSet.
- Warning
- If periodic output is used, the duty cycle buffer registers are updated after the period buffer register. If this function is called while the timer is running and an GTM underflow occurs during processing, the duty cycle will not be the desired 50% duty cycle until the counter underflow after processing completes.
-
Stop the timer before calling this function if one-shot output is used.
- Return values
-
FSP_SUCCESS | Period value updated. |
FSP_ERR_ASSERTION | A required pointer was NULL, or the period was not in the valid range of 1 to 0xFFFF. |
FSP_ERR_NOT_OPEN | The instance control structure is not opened. |
◆ R_GTM_DutyCycleSet()
fsp_err_t R_GTM_DutyCycleSet |
( |
timer_ctrl_t *const |
p_ctrl, |
|
|
uint32_t const |
duty_cycle_counts, |
|
|
uint32_t const |
pin |
|
) |
| |
Updates duty cycle. If the timer is counting, the new duty cycle is reflected after the next counter underflow. Implements timer_api_t::dutyCycleSet.
- Return values
-
◆ R_GTM_Reset()
Resets the counter value to the period minus one. Implements timer_api_t::reset.
- Return values
-
FSP_ERR_UNSUPPORTED | Selected function not supported by this module. |
◆ R_GTM_Start()
Starts timer. Implements timer_api_t::start.
- Return values
-
FSP_SUCCESS | Timer started. |
FSP_ERR_ASSERTION | p_ctrl is null. |
FSP_ERR_NOT_OPEN | The instance control structure is not opened. |
◆ R_GTM_Enable()
Enables external event triggers that start, stop, clear, or capture the counter. Implements timer_api_t::enable.
- Return values
-
FSP_ERR_UNSUPPORTED | Selected function not supported by this module. |
◆ R_GTM_Disable()
Disables external event triggers that start, stop, clear, or capture the counter. Implements timer_api_t::disable.
- Return values
-
FSP_ERR_UNSUPPORTED | Selected function not supported by this module. |
◆ R_GTM_InfoGet()
Gets timer information and store it in provided pointer p_info. Implements timer_api_t::infoGet.
- Return values
-
FSP_SUCCESS | Period, count direction, and frequency stored in p_info. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | The instance control structure is not opened. |
◆ R_GTM_StatusGet()
Retrieves the current state and counter value stores them in p_status. Implements timer_api_t::statusGet.
- Return values
-
FSP_SUCCESS | Current status and counter value provided in p_status. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | The instance control structure is not opened. |
◆ R_GTM_Stop()
Stops the timer. Implements timer_api_t::stop.
- Return values
-
FSP_SUCCESS | Timer stopped. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance control structure is not opened. |
◆ R_GTM_Open()
Initializes the GTM module instance. Implements timer_api_t::open.
The GTM hardware does not support one-shot functionality natively. The one-shot feature is therefore implemented in the GTM HAL layer. For a timer configured as a one-shot timer, the timer is stopped upon the first timer expiration.
The GTM implementation of the general timer can accept an optional gtm_extended_cfg_t extension parameter. For GTM, the extension specifies the clock to be used as timer source and the output pin configurations. If the extension parameter is not specified (NULL), the default clock P0CLK is used and the output pins are disabled.
- Return values
-
FSP_SUCCESS | Initialization was successful and timer has started. |
FSP_ERR_ASSERTION | A required input pointer is NULL or the period is not in the valid range of 1 to 0xFFFF. |
FSP_ERR_ALREADY_OPEN | R_GTM_Open has already been called for this p_ctrl. |
FSP_ERR_IRQ_BSP_DISABLED | A required interrupt has not been enabled in the vector table. |
FSP_ERR_IP_CHANNEL_NOT_PRESENT | Requested channel number is not available on GTM. |
◆ R_GTM_CallbackSet()
Updates the user callback with the option to provide memory for the callback argument structure. Implements timer_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. |