![]() |
RA Flexible Software Package Documentation
Release v5.9.0
|
|
Interface for timer functions.
The general timer interface provides standard timer functionality including periodic mode, one-shot mode, PWM output, and free-running timer mode. After each timer cycle (overflow or underflow), an interrupt can be triggered.
If an instance supports output compare mode, it is provided in the extension configuration timer_on_<instance>_cfg_t defined in r_<instance>.h.
Data Structures | |
struct | timer_callback_args_t |
struct | timer_info_t |
struct | timer_status_t |
struct | timer_cfg_t |
struct | timer_api_t |
struct | timer_instance_t |
Typedefs | |
typedef void | timer_ctrl_t |
Enumerations | |
enum | timer_event_t |
enum | timer_variant_t |
enum | timer_compare_match_t |
enum | timer_state_t |
enum | timer_mode_t |
enum | timer_direction_t |
enum | timer_source_div_t |
struct timer_callback_args_t |
Callback function parameter data
Data Fields | ||
---|---|---|
void const * | p_context |
Placeholder for user data. Set in timer_api_t::open function in timer_cfg_t. |
timer_event_t | event | The event can be used to identify what caused the callback. |
uint32_t | capture |
Most recent capture, only valid if event is TIMER_EVENT_CAPTURE_A or TIMER_EVENT_CAPTURE_B. |
struct timer_info_t |
Timer information structure to store various information for a timer resource
Data Fields | ||
---|---|---|
timer_direction_t | count_direction | Clock counting direction of the timer. |
uint32_t | clock_frequency | Clock frequency of the timer counter. |
uint32_t | period_counts |
Period in raw timer counts.
|
struct timer_status_t |
Current timer status.
Data Fields | ||
---|---|---|
uint32_t | counter | Current counter value. |
timer_state_t | state | Current timer state (running or stopped) |
struct timer_cfg_t |
User configuration structure, used in open function
Data Fields | |
timer_mode_t | mode |
Select enumerated value from timer_mode_t. | |
uint32_t | period_counts |
Period in raw timer counts. | |
timer_source_div_t | source_div |
Source clock divider. | |
uint32_t | duty_cycle_counts |
Duty cycle in counts. | |
uint8_t | channel |
uint8_t | cycle_end_ipl |
Cycle end interrupt priority. | |
IRQn_Type | cycle_end_irq |
Cycle end interrupt. | |
void(* | p_callback )(timer_callback_args_t *p_args) |
void const * | p_context |
void const * | p_extend |
Extension parameter for hardware specific settings. | |
uint8_t timer_cfg_t::channel |
Select a channel corresponding to the channel number of the hardware.
void(* timer_cfg_t::p_callback) (timer_callback_args_t *p_args) |
Callback provided when a timer ISR occurs. Set to NULL for no CPU interrupt.
void const* timer_cfg_t::p_context |
Placeholder for user data. Passed to the user callback in timer_callback_args_t.
struct timer_api_t |
Timer API structure. General timer functions implemented at the HAL layer follow this API.
Data Fields | |
fsp_err_t(* | open )(timer_ctrl_t *const p_ctrl, timer_cfg_t const *const p_cfg) |
fsp_err_t(* | start )(timer_ctrl_t *const p_ctrl) |
fsp_err_t(* | stop )(timer_ctrl_t *const p_ctrl) |
fsp_err_t(* | reset )(timer_ctrl_t *const p_ctrl) |
fsp_err_t(* | enable )(timer_ctrl_t *const p_ctrl) |
fsp_err_t(* | disable )(timer_ctrl_t *const p_ctrl) |
fsp_err_t(* | periodSet )(timer_ctrl_t *const p_ctrl, uint32_t const period) |
fsp_err_t(* | dutyCycleSet )(timer_ctrl_t *const p_ctrl, uint32_t const duty_cycle_counts, uint32_t const pin) |
fsp_err_t(* | compareMatchSet )(timer_ctrl_t *const p_ctrl, uint32_t const compare_match_value, timer_compare_match_t const match_channel) |
fsp_err_t(* | infoGet )(timer_ctrl_t *const p_ctrl, timer_info_t *const p_info) |
fsp_err_t(* | statusGet )(timer_ctrl_t *const p_ctrl, timer_status_t *const p_status) |
fsp_err_t(* | callbackSet )(timer_ctrl_t *const p_ctrl, void(*p_callback)(timer_callback_args_t *), void const *const p_context, timer_callback_args_t *const p_callback_memory) |
fsp_err_t(* | close )(timer_ctrl_t *const p_ctrl) |
fsp_err_t(* timer_api_t::open) (timer_ctrl_t *const p_ctrl, timer_cfg_t const *const p_cfg) |
Initial configuration.
[in] | p_ctrl | Pointer to control block. Must be declared by user. Elements set here. |
[in] | p_cfg | Pointer to configuration structure. All elements of this structure must be set by user. |
fsp_err_t(* timer_api_t::start) (timer_ctrl_t *const p_ctrl) |
Start the counter.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
fsp_err_t(* timer_api_t::stop) (timer_ctrl_t *const p_ctrl) |
Stop the counter.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
fsp_err_t(* timer_api_t::reset) (timer_ctrl_t *const p_ctrl) |
Reset the counter to the initial value.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
fsp_err_t(* timer_api_t::enable) (timer_ctrl_t *const p_ctrl) |
Enables input capture.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
fsp_err_t(* timer_api_t::disable) (timer_ctrl_t *const p_ctrl) |
Disables input capture.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
fsp_err_t(* timer_api_t::periodSet) (timer_ctrl_t *const p_ctrl, uint32_t const period) |
Set the time until the timer expires. See implementation for details of period update timing.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
[in] | period | Time until timer should expire. |
fsp_err_t(* timer_api_t::dutyCycleSet) (timer_ctrl_t *const p_ctrl, uint32_t const duty_cycle_counts, uint32_t const pin) |
Sets the number of counts for the pin level to be high. If the timer is counting, the updated duty cycle is reflected after the next timer expiration.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
[in] | duty_cycle_counts | Time until duty cycle should expire. |
[in] | pin | Which output pin to update. See implementation for details. |
fsp_err_t(* timer_api_t::compareMatchSet) (timer_ctrl_t *const p_ctrl, uint32_t const compare_match_value, timer_compare_match_t const match_channel) |
Set a compare match value in raw counts.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
[in] | compare_match_value | Timer value to trigger a compare match event. |
[in] | match_channel | Which channel to update. |
fsp_err_t(* timer_api_t::infoGet) (timer_ctrl_t *const p_ctrl, timer_info_t *const p_info) |
Stores timer information in p_info.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
[out] | p_info | Collection of information for this timer. |
fsp_err_t(* timer_api_t::statusGet) (timer_ctrl_t *const p_ctrl, timer_status_t *const p_status) |
Get the current counter value and timer state and store it in p_status.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
[out] | p_status | Current status of this timer. |
fsp_err_t(* timer_api_t::callbackSet) (timer_ctrl_t *const p_ctrl, void(*p_callback)(timer_callback_args_t *), void const *const p_context, timer_callback_args_t *const p_callback_memory) |
Specify callback function and optional context pointer and working memory pointer.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
[in] | p_callback | Callback function to register |
[in] | p_context | Pointer to send to callback function |
[in] | p_working_memory | Pointer to volatile memory where callback structure can be allocated. Callback arguments allocated here are only valid during the callback. |
fsp_err_t(* timer_api_t::close) (timer_ctrl_t *const p_ctrl) |
Allows driver to be reconfigured and may reduce power consumption.
[in] | p_ctrl | Control block set in timer_api_t::open call for this timer. |
struct timer_instance_t |
This structure encompasses everything that is needed to use an instance of this interface.
Data Fields | ||
---|---|---|
timer_ctrl_t * | p_ctrl | Pointer to the control structure for this instance. |
timer_cfg_t const * | p_cfg | Pointer to the configuration structure for this instance. |
timer_api_t const * | p_api | Pointer to the API structure for this instance. |
typedef void timer_ctrl_t |
Timer control block. Allocate an instance specific control block to pass into the timer API calls.
enum timer_event_t |
Events that can trigger a callback function
enum timer_variant_t |
Options for storing compare match value
enum timer_state_t |
Possible status values returned by timer_api_t::statusGet.
Enumerator | |
---|---|
TIMER_STATE_STOPPED | Timer is stopped. |
TIMER_STATE_COUNTING | Timer is running. |
TIMER_STATE_UNKNOWN | Timer state could not be defined. |
enum timer_mode_t |
Timer operational modes
enum timer_direction_t |
enum timer_source_div_t |
Clock source divisors