![]() |
PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
|
How to use DT module. More...
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... | |
Macros | |
| #define | DT0 (*((volatile stc_dtn_t *) FM4_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 FM4_DTIM_TypeDef | stc_dtn_t |
| Redefinition of DT register structure. More... | |
| typedef enum en_dt_mode | en_dt_mode_t |
| Dt mode. More... | |
| typedef enum en_dt_prescaler | en_dt_prescaler_t |
| Dt Prescaler. More... | |
| typedef enum en_dt_countersize | en_dt_countersize_t |
| Dt Counter Size. More... | |
| typedef enum en_dt_channel | en_dt_channel_t |
| Dt channel number. More... | |
| typedef struct stc_dt_channel_config | stc_dt_channel_config_t |
| Dt channel configuration. More... | |
| typedef void(* | dt_cb_func_ptr_t )(void) |
| DtCallback function prototype. More... | |
| typedef enum en_dt_instance_index | en_dt_instance_index_t |
| Enumeration to define an index for each enabled Dual timer instance. More... | |
| typedef struct stc_dt_intern_data | stc_dt_intern_data_t |
| Datatype for holding internal data needed for DT. More... | |
| typedef struct stc_dt_instance_data | stc_dt_instance_data_t |
| DT instance data type. More... | |
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, 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. More... | |
| static void | Dt_InitIrq (void) |
| Device dependent initialization of interrupts according CMSIS with level defined in l3.h. More... | |
| static void | Dt_DeInitIrq (void) |
| Device dependent de-initialization of interrupts according CMSIS. More... | |
| void | DtIrqHandler (uint8_t u8Ch) |
| ISR callback for DT (channel 0 and 1) More... | |
| en_result_t | Dt_Init (stc_dt_channel_config_t *pstcConfig, uint8_t u8Ch) |
| Initialize DT. More... | |
| en_result_t | Dt_DeInit (uint8_t u8Ch) |
| De-Initialize DT. More... | |
| en_result_t | Dt_EnableCount (uint8_t u8Ch) |
| Enable Timer Counter. More... | |
| en_result_t | Dt_DisableCount (uint8_t u8Ch) |
| Disable Timer Counter. More... | |
| en_result_t | Dt_EnableInt (dt_cb_func_ptr_t pfnIntCallback, uint8_t u8Ch) |
| Enable Interrupt. More... | |
| en_result_t | Dt_DisableInt (uint8_t u8Ch) |
| Disable Interrupt. More... | |
| boolean_t | Dt_GetIntFlag (uint8_t u8Ch) |
| Get interrupt status The Function can return the interrupt status (TimerXRIS) More... | |
| boolean_t | Dt_GetMaskIntFlag (uint8_t u8Ch) |
| Get mask interrupt status The Function can return the mask interrupt status (TimerXMIS) More... | |
| en_result_t | Dt_ClrIntFlag (uint8_t u8Ch) |
| Clear interrupt status The Function clears the interrupt status. More... | |
| en_result_t | Dt_WriteLoadVal (uint32_t u32LoadVal, uint8_t u8Ch) |
| Write load value The Function writes the load value to load register. More... | |
| 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. More... | |
| uint32_t | Dt_ReadCurCntVal (uint8_t u8Ch) |
| Read current count value The Function reads the value from value register. More... | |
Variables | |
| static stc_dt_instance_data_t | m_astcDtInstanceDataLut [DtInstanceIndexMax] |
| Look-up table for all enabled DT instances and their internal data. More... | |
How to use DT module.
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.
| #define DT0 (*((volatile stc_dtn_t *) FM4_DTIM_BASE)) |
Definition at line 199 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().
| 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 FM4_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 632 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 345 of file dt.c.
References DT0, Dt_DeInitIrq(), DtGetInternDataPtr(), ErrorInvalidParameter, Ok, and stc_dt_intern_data::pfnIntCallbackIntern.

|
static |
Device dependent de-initialization of interrupts according CMSIS.
Definition at line 164 of file dt.c.
References PDL_DEFAULT_INTERRUPT_LEVEL.
Referenced by Dt_DeInit(), and 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 436 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 522 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 397 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 477 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 594 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 228 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 |
Device dependent initialization of interrupts according CMSIS with level defined in l3.h.
Definition at line 150 of file dt.c.
References PDL_IRQ_LEVEL_DT0.
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 758 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 717 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 671 of file dt.c.
References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, FALSE, and Ok.

|
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 116 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 188 of file dt.c.
References DT0, stc_dt_intern_data::pfnIntCallbackIntern, stc_dt_instance_data::stcInternData, and TRUE.
|
static |