![]() |
PDL for FM0+
Version1.0
Peripheral Driverl Library for FM0+
|
Data Structures | |
struct | stc_dt_channel_config |
Dt channel configuration. More... | |
struct | stc_dt_intern_data |
Datatype for holding internal data needed for DT. More... | |
struct | stc_dt_instance_data |
DT instance data type. More... | |
Defines | |
#define | DT0 (*((volatile stc_dtn_t *) FM0P_DTIM_BASE)) |
#define | DT_PRE_TIMER_DIV_1 (0x00) |
#define | DT_PRE_TIMER_DIV_16 (0x01) |
#define | DT_PRE_TIMER_DIV_256 (0x02) |
Typedefs | |
typedef FM0P_DTIM_TypeDef | stc_dtn_t |
Redefinition of DT register structure. | |
typedef enum en_dt_mode | en_dt_mode_t |
Dt mode. | |
typedef enum en_dt_prescaler | en_dt_prescaler_t |
Dt Prescaler. | |
typedef enum en_dt_countersize | en_dt_countersize_t |
Dt Counter Size. | |
typedef enum en_dt_channel | en_dt_channel_t |
Dt channel number. | |
typedef struct stc_dt_channel_config | stc_dt_channel_config_t |
Dt channel configuration. | |
typedef void(* | dt_cb_func_ptr_t )(void) |
DtCallback function prototype. | |
typedef enum en_dt_instance_index | en_dt_instance_index_t |
Enumeration to define an index for each enabled Dual timer instance. | |
typedef struct stc_dt_intern_data | stc_dt_intern_data_t |
Datatype for holding internal data needed for DT. | |
typedef struct stc_dt_instance_data | stc_dt_instance_data_t |
DT instance data type. | |
Enumerations | |
enum | en_dt_mode { DtFreeRun = 0, DtPeriodic = 1, DtOneShot = 2 } |
Dt mode. More... | |
enum | en_dt_prescaler { DtPrescalerDiv1 = 0, DtPrescalerDiv16 = 1, DtPrescalerDiv256 = 2 } |
Dt Prescaler. More... | |
enum | en_dt_countersize { DtCounterSize16 = 0, DtCounterSize32 = 1 } |
Dt Counter Size. More... | |
enum | en_dt_channel { DtChannel0 = 0, DtChannel1 = 1, DtMaxChannels = 2 } |
Dt channel number. More... | |
enum | en_dt_instance_index { DtInstanceIndexDt0 = 0u, DtInstanceIndexMax } |
Enumeration to define an index for each enabled Dual timer instance. More... | |
Functions | |
static stc_dt_intern_data_t * | DtGetInternDataPtr (volatile stc_dtn_t **ppstcDt, uint8_t u8Ch) |
Check pointer to Dual Timer instance and enable channel. | |
static void | Dt_InitIrq (void) |
Device dependent initialization of interrupts according CMSIS with level defined in pdl.h. | |
static void | Dt_DeInitIrq (void) |
Device dependent de-initialization of interrupts according CMSIS. | |
void | DtIrqHandler (uint8_t u8Ch) |
ISR callback for DT (channel 0 and 1) | |
en_result_t | Dt_Init (stc_dt_channel_config_t *pstcConfig, uint8_t u8Ch) |
Initialize DT. | |
en_result_t | Dt_DeInit (uint8_t u8Ch) |
De-Initialize DT. | |
en_result_t | Dt_EnableCount (uint8_t u8Ch) |
Enable Timer Counter. | |
en_result_t | Dt_DisableCount (uint8_t u8Ch) |
Disable Timer Counter. | |
en_result_t | Dt_EnableInt (dt_cb_func_ptr_t pfnIntCallback, uint8_t u8Ch) |
Enable Interrupt. | |
en_result_t | Dt_DisableInt (uint8_t u8Ch) |
Disable Interrupt. | |
boolean_t | Dt_GetIntFlag (uint8_t u8Ch) |
Get interrupt status The Function can return the interrupt status (TimerXRIS) | |
boolean_t | Dt_GetMaskIntFlag (uint8_t u8Ch) |
Get mask interrupt status The Function can return the mask interrupt status (TimerXMIS) | |
en_result_t | Dt_ClrIntFlag (uint8_t u8Ch) |
Clear interrupt status The Function clears the interrupt status. | |
en_result_t | Dt_WriteLoadVal (uint32_t u32LoadVal, uint8_t u8Ch) |
Write load value The Function writes the load value to load register. | |
en_result_t | Dt_WriteBgLoadVal (uint32_t u32BgLoadVal, uint8_t u8Ch) |
Write back-ground load value The Function writes the load value to back-ground load register. | |
uint32_t | Dt_ReadCurCntVal (uint8_t u8Ch) |
Read current count value The Function reads the value from value register. | |
Variables | |
static stc_dt_instance_data_t | m_astcDtInstanceDataLut [DtInstanceIndexMax] |
Look-up table for all enabled DT instances and their internal data. |
Provided functions of DT module:
Dt_Init() must be used for configuration of a Dual Timer (DT) channel a structure with the type stc_dt_channel_config_t.
A DT Channel can be enabled by the function Dt_EnableCount(). Depending on the used mode, it is started in:
A DT interruption can be enabled by the function Dt_EnableInt(). This function can set callback function for each channel too. Before enabling a DT channel by Dt_EnableCount(), it is recommended to call this function.
With Dt_WriteLoadVal() the recent DT counter is set to the value given in the parameter Dt_WriteLoadVal::u32LoadVal. This works in each of the three operation modes.
With Dt_WriteBgLoadVal() the background reload value can be set, which is then set to the load value after the DT counter reaches the next 0.
With Dt_ReadCurCntVal() the current DT counter can be read.
Before deinitialization of the DT by Dt_DeInit(), it is recommended to disable all channels via Dt_DisableCount() and Dt_DisableInt() before, to avoid a possible, unwanted interrupt.
Definition at line 198 of file dt.h.
Referenced by Dt_ClrIntFlag(), Dt_DeInit(), Dt_DisableCount(), Dt_DisableInt(), Dt_EnableCount(), Dt_EnableInt(), Dt_GetIntFlag(), Dt_GetMaskIntFlag(), Dt_Init(), Dt_ReadCurCntVal(), Dt_WriteBgLoadVal(), Dt_WriteLoadVal(), and DtIrqHandler().
#define DT_PRE_TIMER_DIV_1 (0x00) |
#define DT_PRE_TIMER_DIV_16 (0x01) |
#define DT_PRE_TIMER_DIV_256 (0x02) |
typedef void(* dt_cb_func_ptr_t)(void) |
typedef enum en_dt_channel en_dt_channel_t |
Dt channel number.
typedef enum en_dt_countersize en_dt_countersize_t |
Dt Counter Size.
To select the size of the counter
typedef enum en_dt_instance_index en_dt_instance_index_t |
Enumeration to define an index for each enabled Dual timer instance.
typedef enum en_dt_mode en_dt_mode_t |
Dt mode.
To select between Free-run, Periodic, and One-Shot mode
typedef enum en_dt_prescaler en_dt_prescaler_t |
Dt Prescaler.
To select clock divider
typedef struct stc_dt_channel_config stc_dt_channel_config_t |
Dt channel configuration.
The DT configuration is done on a per channel basis
typedef struct stc_dt_instance_data stc_dt_instance_data_t |
DT instance data type.
typedef struct stc_dt_intern_data stc_dt_intern_data_t |
Datatype for holding internal data needed for DT.
typedef FM0P_DTIM_TypeDef stc_dtn_t |
enum en_dt_channel |
enum en_dt_countersize |
enum en_dt_instance_index |
enum en_dt_mode |
enum en_dt_prescaler |
en_result_t Dt_ClrIntFlag | ( | uint8_t | u8Ch | ) |
Clear interrupt status The Function clears the interrupt status.
[in] | u8Ch | Channel number |
Ok | Process successfully done. |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 637 of file dt.c.
References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, and Ok.
en_result_t Dt_DeInit | ( | uint8_t | u8Ch | ) |
De-Initialize DT.
This function de-initializes the specified channel of Dual Timer. Dt-DeInit() accesses the DT hardware register. They are reset.
[in] | u8Ch | Channel number |
Ok | Process successfully done. |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 351 of file dt.c.
References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, Ok, and stc_dt_intern_data::pfnIntCallbackIntern.
static void Dt_DeInitIrq | ( | void | ) | [static] |
Device dependent de-initialization of interrupts according CMSIS.
Definition at line 167 of file dt.c.
References PDL_DEFAULT_INTERRUPT_LEVEL.
Referenced by Dt_DisableInt().
en_result_t Dt_DisableCount | ( | uint8_t | u8Ch | ) |
Disable Timer Counter.
This function disables the timer counter.
[in] | u8Ch | Channel number |
Ok | Process successfully done. |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 439 of file dt.c.
References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, FALSE, and Ok.
en_result_t Dt_DisableInt | ( | uint8_t | u8Ch | ) |
Disable Interrupt.
This function disables the interruption.
[in] | u8Ch | Channel number |
Ok | Process successfully done. |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 526 of file dt.c.
References DT0, Dt_DeInitIrq(), DtGetInternDataPtr(), ErrorInvalidParameter, FALSE, Ok, and stc_dt_intern_data::pfnIntCallbackIntern.
en_result_t Dt_EnableCount | ( | uint8_t | u8Ch | ) |
Enable Timer Counter.
This function enables the timer counter.
[in] | u8Ch | Channel number |
Ok | Process successfully done. |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 400 of file dt.c.
References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, Ok, and TRUE.
en_result_t Dt_EnableInt | ( | dt_cb_func_ptr_t | pfnIntCallback, |
uint8_t | u8Ch | ||
) |
Enable Interrupt.
This function enables the interruption.
[in] | pfnIntCallback | Callback function when interruption is occured. (Can be set NULL) |
[in] | u8Ch | Channel number |
Ok | Process successfully done. |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 481 of file dt.c.
References DT0, Dt_InitIrq(), DtGetInternDataPtr(), ErrorInvalidParameter, Ok, stc_dt_intern_data::pfnIntCallbackIntern, and TRUE.
boolean_t Dt_GetIntFlag | ( | uint8_t | u8Ch | ) |
boolean_t Dt_GetMaskIntFlag | ( | uint8_t | u8Ch | ) |
Get mask interrupt status The Function can return the mask interrupt status (TimerXMIS)
[in] | u8Ch | Channel number |
boolean_t:the | mask interrupt status |
Definition at line 599 of file dt.c.
References DT0, DtGetInternDataPtr(), FALSE, and TRUE.
en_result_t Dt_Init | ( | stc_dt_channel_config_t * | pstcConfig, |
uint8_t | u8Ch | ||
) |
Initialize DT.
This function initializes the specified channel of Dual Timer.
[in] | pstcConfig | Dual timer configuration |
[in] | u8Ch | Channel number |
Ok | Process successfully done. |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 234 of file dt.c.
References DT0, DT_PRE_TIMER_DIV_1, DT_PRE_TIMER_DIV_16, DT_PRE_TIMER_DIV_256, DtCounterSize16, DtCounterSize32, DtFreeRun, DtGetInternDataPtr(), DtOneShot, DtPeriodic, DtPrescalerDiv1, DtPrescalerDiv16, DtPrescalerDiv256, ErrorInvalidParameter, FALSE, Ok, stc_dt_intern_data::pfnIntCallbackIntern, TRUE, stc_dt_channel_config::u8CounterSize, stc_dt_channel_config::u8Mode, and stc_dt_channel_config::u8PrescalerDiv.
static void Dt_InitIrq | ( | void | ) | [static] |
Device dependent initialization of interrupts according CMSIS with level defined in pdl.h.
Definition at line 153 of file dt.c.
References PDL_IRQ_LEVEL_DT_QPRC.
Referenced by Dt_EnableInt().
uint32_t Dt_ReadCurCntVal | ( | uint8_t | u8Ch | ) |
Read current count value The Function reads the value from value register.
[in] | u8Ch | Channel number |
uint32_t:current | counter value |
Definition at line 763 of file dt.c.
References DT0, DtGetInternDataPtr(), and FALSE.
en_result_t Dt_WriteBgLoadVal | ( | uint32_t | u32BgLoadVal, |
uint8_t | u8Ch | ||
) |
Write back-ground load value The Function writes the load value to back-ground load register.
[in] | u32BgLoadVal | Load value to set to back-ground load register |
[in] | u8Ch | Channel number |
Ok | Process successfully done. |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 722 of file dt.c.
References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, FALSE, and Ok.
en_result_t Dt_WriteLoadVal | ( | uint32_t | u32LoadVal, |
uint8_t | u8Ch | ||
) |
Write load value The Function writes the load value to load register.
[in] | u32LoadVal | Load value to set to load register |
[in] | u8Ch | Channel number |
Ok | Process successfully done. |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 676 of file dt.c.
References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, FALSE, and Ok.
static stc_dt_intern_data_t * DtGetInternDataPtr | ( | volatile stc_dtn_t ** | ppstcDt, |
uint8_t | u8Ch | ||
) | [static] |
Check pointer to Dual Timer instance and enable channel.
[in,out] | ppstcDt | Pointer of pointer to Dual Timer instance register area |
[in] | u8Ch | Channel number |
Pointer | to internal data or NULL if instance is not enabled. (or channel is invalid) |
Definition at line 118 of file dt.c.
References DtInstanceIndexMax, DtMaxChannels, and stc_dt_instance_data::stcInternData.
Referenced by Dt_ClrIntFlag(), Dt_DeInit(), Dt_DisableCount(), Dt_DisableInt(), Dt_EnableCount(), Dt_EnableInt(), Dt_GetIntFlag(), Dt_GetMaskIntFlag(), Dt_Init(), Dt_ReadCurCntVal(), Dt_WriteBgLoadVal(), and Dt_WriteLoadVal().
void DtIrqHandler | ( | uint8_t | u8Ch | ) |
ISR callback for DT (channel 0 and 1)
This callbacks are called by the global DT ISR whenever an DT triggers an interrupt (on channel 0 and/or 1). It calls the callback functions that has been given during Dt initialization (see Dt_Init() and stc_dt_channel_config_t) for each channel individually. If the pointer to a callback function is NULL, no call is performed.
The active interrupt request flags are cleared by the ISR
[in] | u8Ch | Channel number |
Definition at line 192 of file dt.c.
References DT0, stc_dt_intern_data::pfnIntCallbackIntern, stc_dt_instance_data::stcInternData, and TRUE.
Referenced by DT_QPRC_Handler().