PDL for FM0+  Version1.0
Peripheral Driverl Library for FM0+
Dual Timer (DT)

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_tDtGetInternDataPtr (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.

Detailed Description

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 Documentation

#define DT_PRE_TIMER_DIV_1   (0x00)

Definition at line 201 of file dt.h.

Referenced by Dt_Init().

#define DT_PRE_TIMER_DIV_16   (0x01)

Definition at line 202 of file dt.h.

Referenced by Dt_Init().

#define DT_PRE_TIMER_DIV_256   (0x02)

Definition at line 203 of file dt.h.

Referenced by Dt_Init().


Typedef Documentation

typedef void(* dt_cb_func_ptr_t)(void)

DtCallback function prototype.

Definition at line 193 of file dt.h.

Dt channel number.

Dt Counter Size.

To select the size of the counter

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

Dt Prescaler.

To select clock divider

Dt channel configuration.

The DT configuration is done on a per channel basis

DT instance data type.

Datatype for holding internal data needed for DT.

typedef FM0P_DTIM_TypeDef stc_dtn_t

Redefinition of DT register structure.

Definition at line 125 of file dt.h.


Enumeration Type Documentation

Dt channel number.

Enumerator:
DtChannel0 

channel 0

DtChannel1 

channel 1

DtMaxChannels 

Number of channels.

Definition at line 169 of file dt.h.

Dt Counter Size.

To select the size of the counter

Enumerator:
DtCounterSize16 

16 Bit counter size

DtCounterSize32 

32 Bit counter size

Definition at line 159 of file dt.h.

Enumeration to define an index for each enabled Dual timer instance.

Enumerator:
DtInstanceIndexDt0 
DtInstanceIndexMax 

Definition at line 210 of file dt.h.

enum en_dt_mode

Dt mode.

To select between Free-run, Periodic, and One-Shot mode

Enumerator:
DtFreeRun 

Free-running mode.

DtPeriodic 

Periodic mode.

DtOneShot 

One-shot mode.

Definition at line 133 of file dt.h.

Dt Prescaler.

To select clock divider

Enumerator:
DtPrescalerDiv1 

Prescaler divisor 1.

DtPrescalerDiv16 

Prescaler divisor 16.

DtPrescalerDiv256 

Prescaler divisor 256.

Definition at line 146 of file dt.h.


Function Documentation

en_result_t Dt_ClrIntFlag ( uint8_t  u8Ch)

Clear interrupt status The Function clears the interrupt status.

Parameters:
[in]u8ChChannel number
Return values:
OkProcess successfully done.
ErrorInvalidParameterIf one of following conditions are met:
  • u8Ch >= DtMaxChannels
  • pstcDtInternData == NULL (invalid or disabled DT unit (PDL_PERIPHERAL_ENABLE_DT))

Definition at line 637 of file dt.c.

References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, and Ok.

Here is the call graph for this function:

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.

Parameters:
[in]u8ChChannel number
Return values:
OkProcess successfully done.
ErrorInvalidParameterIf one of following conditions are met:
  • pstcDt == NULL
  • u8Ch >= DtMaxChannels
  • pstcDtInternData == NULL (invalid or disabled DT unit (PDL_PERIPHERAL_ENABLE_DT))

Definition at line 351 of file dt.c.

References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, Ok, and stc_dt_intern_data::pfnIntCallbackIntern.

Here is the call graph for this function:

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().

Here is the caller graph for this function:

en_result_t Dt_DisableCount ( uint8_t  u8Ch)

Disable Timer Counter.

This function disables the timer counter.

Parameters:
[in]u8ChChannel number
Return values:
OkProcess successfully done.
ErrorInvalidParameterIf one of following conditions are met:
  • u8Ch >= DtMaxChannels
  • pstcDtInternData == NULL (invalid or disabled DT unit (PDL_PERIPHERAL_ENABLE_DT))

Definition at line 439 of file dt.c.

References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, FALSE, and Ok.

Here is the call graph for this function:

en_result_t Dt_DisableInt ( uint8_t  u8Ch)

Disable Interrupt.

This function disables the interruption.

Parameters:
[in]u8ChChannel number
Return values:
OkProcess successfully done.
ErrorInvalidParameterIf one of following conditions are met:
  • u8Ch >= DtMaxChannels
  • pstcDtInternData == NULL (invalid or disabled DT unit (PDL_PERIPHERAL_ENABLE_DT))

Definition at line 526 of file dt.c.

References DT0, Dt_DeInitIrq(), DtGetInternDataPtr(), ErrorInvalidParameter, FALSE, Ok, and stc_dt_intern_data::pfnIntCallbackIntern.

Here is the call graph for this function:

en_result_t Dt_EnableCount ( uint8_t  u8Ch)

Enable Timer Counter.

This function enables the timer counter.

Parameters:
[in]u8ChChannel number
Return values:
OkProcess successfully done.
ErrorInvalidParameterIf one of following conditions are met:
  • u8Ch >= DtMaxChannels
  • pstcDtInternData == NULL (invalid or disabled DT unit (PDL_PERIPHERAL_ENABLE_DT))

Definition at line 400 of file dt.c.

References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, Ok, and TRUE.

Here is the call graph for this function:

en_result_t Dt_EnableInt ( dt_cb_func_ptr_t  pfnIntCallback,
uint8_t  u8Ch 
)

Enable Interrupt.

This function enables the interruption.

Parameters:
[in]pfnIntCallbackCallback function when interruption is occured. (Can be set NULL)
[in]u8ChChannel number
Return values:
OkProcess successfully done.
ErrorInvalidParameterIf one of following conditions are met:
  • u8Ch >= DtMaxChannels
  • pstcDtInternData == NULL (invalid or disabled DT unit (PDL_PERIPHERAL_ENABLE_DT))

Definition at line 481 of file dt.c.

References DT0, Dt_InitIrq(), DtGetInternDataPtr(), ErrorInvalidParameter, Ok, stc_dt_intern_data::pfnIntCallbackIntern, and TRUE.

Here is the call graph for this function:

boolean_t Dt_GetIntFlag ( uint8_t  u8Ch)

Get interrupt status The Function can return the interrupt status (TimerXRIS)

Parameters:
[in]u8ChChannel number
Return values:
boolean_t:theinterrupt status

Definition at line 565 of file dt.c.

References DT0, DtGetInternDataPtr(), FALSE, and TRUE.

Here is the call graph for this function:

boolean_t Dt_GetMaskIntFlag ( uint8_t  u8Ch)

Get mask interrupt status The Function can return the mask interrupt status (TimerXMIS)

Parameters:
[in]u8ChChannel number
Return values:
boolean_t:themask interrupt status

Definition at line 599 of file dt.c.

References DT0, DtGetInternDataPtr(), FALSE, and TRUE.

Here is the call graph for this function:

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.

Parameters:
[in]pstcConfigDual timer configuration
[in]u8ChChannel number
Return values:
OkProcess successfully done.
ErrorInvalidParameterIf one of following conditions are met:
  • pstcConfig == NULL
  • u8Ch >= DtMaxChannels
  • pstcDtInternData == NULL (invalid or disabled DT unit (PDL_PERIPHERAL_ENABLE_DT))
  • one or more enumerated values in pstcDt out of enumaration

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.

Here is the call graph for this function:

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().

Here is the caller graph for this function:

uint32_t Dt_ReadCurCntVal ( uint8_t  u8Ch)

Read current count value The Function reads the value from value register.

Parameters:
[in]u8ChChannel number
Return values:
uint32_t:currentcounter value

Definition at line 763 of file dt.c.

References DT0, DtGetInternDataPtr(), and FALSE.

Here is the call graph for this function:

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.

Parameters:
[in]u32BgLoadValLoad value to set to back-ground load register
[in]u8ChChannel number
Return values:
OkProcess successfully done.
ErrorInvalidParameterIf one of following conditions are met:
  • u8Ch >= DtMaxChannels
  • pstcDtInternData == NULL (invalid or disabled DT unit (PDL_PERIPHERAL_ENABLE_DT))

Definition at line 722 of file dt.c.

References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, FALSE, and Ok.

Here is the call graph for this function:

en_result_t Dt_WriteLoadVal ( uint32_t  u32LoadVal,
uint8_t  u8Ch 
)

Write load value The Function writes the load value to load register.

Parameters:
[in]u32LoadValLoad value to set to load register
[in]u8ChChannel number
Return values:
OkProcess successfully done.
ErrorInvalidParameterIf one of following conditions are met:
  • u8Ch >= DtMaxChannels
  • pstcDtInternData == NULL (invalid or disabled DT unit (PDL_PERIPHERAL_ENABLE_DT))

Definition at line 676 of file dt.c.

References DT0, DtGetInternDataPtr(), ErrorInvalidParameter, FALSE, and Ok.

Here is the call graph for this function:

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.

Parameters:
[in,out]ppstcDtPointer of pointer to Dual Timer instance register area
[in]u8ChChannel number
Return values:
Pointerto 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().

Here is the caller graph for this function:

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

Parameters:
[in]u8ChChannel 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().

Here is the caller graph for this function:


Variable Documentation

Initial value:
{

    {
        & (*((volatile stc_dtn_t *) FM0P_DTIM_BASE)) ,   
        {NULL}  
    }

}

Look-up table for all enabled DT instances and their internal data.

Definition at line 74 of file dt.c.