| Nano100AN Series BSP V3.02.002 The Board Support Package for Nano100AN Series

Macros | Functions
TIMER Exported Functions
NANO100 Device Driver » TIMER Driver

## Macros
#define | TIMER_SET_CMP_VALUE(timer, u32Value)
| This macro is used to set new Timer compared value. More...
#define | TIMER_SET_PRESCALE_VALUE(timer, u32Value)
| This macro is used to set new Timer prescale value. More...
#define | TIMER_IS_ACTIVE(timer)
| This macro is used to check if specify Timer is inactive or active. More...

## Functions
__STATIC_INLINE void | TIMER_Start (TIMER_T *timer)
| This function is used to start Timer counting. More...
__STATIC_INLINE void | TIMER_Stop (TIMER_T *timer)
| This function is used to stop Timer counting. More...
__STATIC_INLINE void | TIMER_EnableWakeup (TIMER_T *timer)
| This function is used to enable the Timer wake-up function. More...
__STATIC_INLINE void | TIMER_DisableWakeup (TIMER_T *timer)
| This function is used to disable the Timer wake-up function. More...
__STATIC_INLINE void | TIMER_EnableCaptureDebounce (TIMER_T *timer)
| This function is used to enable the capture pin detection de-bounce function. More...
__STATIC_INLINE void | TIMER_DisableCaptureDebounce (TIMER_T *timer)
| This function is used to disable the capture pin detection de-bounce function. More...
__STATIC_INLINE void | TIMER_EnableEventCounterDebounce (TIMER_T *timer)
| This function is used to enable the counter pin detection de-bounce function. More...
__STATIC_INLINE void | TIMER_DisableEventCounterDebounce (TIMER_T *timer)
| This function is used to disable the counter pin detection de-bounce function. More...
__STATIC_INLINE void | TIMER_EnableInt (TIMER_T *timer)
| This function is used to enable the Timer time-out interrupt function. More...
__STATIC_INLINE void | TIMER_DisableInt (TIMER_T *timer)
| This function is used to disable the Timer time-out interrupt function. More...
__STATIC_INLINE void | TIMER_EnableCaptureInt (TIMER_T *timer)
| This function is used to enable the Timer capture trigger interrupt function. More...
__STATIC_INLINE void | TIMER_DisableCaptureInt (TIMER_T *timer)
| This function is used to disable the Timer capture trigger interrupt function. More...
__STATIC_INLINE uint32_t | TIMER_GetIntFlag (TIMER_T *timer)
| This function indicates Timer time-out interrupt occurred or not. More...
__STATIC_INLINE void | TIMER_ClearIntFlag (TIMER_T *timer)
| This function clears the Timer time-out interrupt flag. More...
__STATIC_INLINE uint32_t | TIMER_GetCaptureIntFlag (TIMER_T *timer)
| This function indicates Timer capture interrupt occurred or not. More...
__STATIC_INLINE void | TIMER_ClearCaptureIntFlag (TIMER_T *timer)
| This function clears the Timer capture interrupt flag. More...
__STATIC_INLINE uint32_t | TIMER_GetWakeupFlag (TIMER_T *timer)
| This function indicates Timer has waked up system or not. More...
__STATIC_INLINE void | TIMER_ClearWakeupFlag (TIMER_T *timer)
| This function clears the Timer wakeup interrupt flag. More...
__STATIC_INLINE uint32_t | TIMER_GetCaptureData (TIMER_T *timer)
| This function gets the Timer capture data. More...
__STATIC_INLINE uint32_t | TIMER_GetCounter (TIMER_T *timer)
| This function reports the current timer counter value. More...
uint32_t | TIMER_Open (TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq)
| This function is used to configure timer to operate in specified mode and frequency. If timer cannot work in target frequency, a closest frequency will be chose and returned. More...
void | TIMER_Close (TIMER_T *timer)
| This function stops Timer counting and disable the Timer interrupt function. More...
void | TIMER_Delay (TIMER_T *timer, uint32_t u32Usec)
| This function is used to create a delay loop for u32usec micro seconds. More...
void | TIMER_EnableCapture (TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge)
| This function is used to enable timer capture function with specified mode and capture edge. More...
void | TIMER_DisableCapture (TIMER_T *timer)
| This function is used to disable the Timer capture function. More...
void | TIMER_EnableEventCounter (TIMER_T *timer, uint32_t u32Edge)
| This function is used to enable the Timer counter function with specify detection edge. More...
void | TIMER_DisableEventCounter (TIMER_T *timer)
| This function is used to disable the Timer event counter function. More...
uint32_t | TIMER_GetModuleClock (TIMER_T *timer)
| This function is used to get the clock frequency of Timer. More...
void | TIMER_EnableFreqCounter (TIMER_T *timer, uint32_t u32DropCount, uint32_t u32Timeout, uint32_t u32EnableInt)
| This function is used to enable the Timer frequency counter function. More...
void | TIMER_DisableFreqCounter (TIMER_T *timer)
| This function is used to disable the Timer frequency counter function. More...
void | TIMER_SetTriggerSource (TIMER_T *timer, uint32_t u32Src)
| This function is used to select the interrupt source used to trigger other modules. More...
void | TIMER_SetTriggerTarget (TIMER_T *timer, uint32_t u32Mask)
| This function is used to set modules trigger by timer interrupt. More...

## Detailed Description

## Macro Definition Documentation

## ◆ TIMER_IS_ACTIVE

#define TIMER_IS_ACTIVE | ( |  | timer | ) |

This macro is used to check if specify Timer is inactive or active.

Returns
  timer is activate or inactivate

Return values

  0 | Timer 24-bit up counter is inactive
  1 | Timer 24-bit up counter is active

Definition at line 85 of file timer.h.

## ◆ TIMER_SET_CMP_VALUE

#define TIMER_SET_CMP_VALUE | ( |  | timer,
|  |  | u32Value
| ) |  |

This macro is used to set new Timer compared value.

Parameters

  [in] | timer | The base address of Timer module
  [in] | u32Value | Timer compare value. Valid values are between 2 to 0xFFFFFF

Returns
  None

Definition at line 66 of file timer.h.

## ◆ TIMER_SET_PRESCALE_VALUE

#define TIMER_SET_PRESCALE_VALUE | ( |  | timer,
|  |  | u32Value
| ) |  |

This macro is used to set new Timer prescale value.

Parameters

  [in] | timer | The base address of Timer module
  [in] | u32Value | Timer prescale value. Valid values are between 0 to 0xFF

Returns
  None

Note
  Clock input is divided by (prescale + 1) before it is fed into timer

Definition at line 76 of file timer.h.

## Function Documentation

## ◆ TIMER_ClearCaptureIntFlag()

__STATIC_INLINE void TIMER_ClearCaptureIntFlag | ( | TIMER_T * | timer | ) |

This function clears the Timer capture interrupt flag.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 250 of file timer.h.

## ◆ TIMER_ClearIntFlag()

__STATIC_INLINE void TIMER_ClearIntFlag | ( | TIMER_T * | timer | ) |

This function clears the Timer time-out interrupt flag.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 228 of file timer.h.

## ◆ TIMER_ClearWakeupFlag()

__STATIC_INLINE void TIMER_ClearWakeupFlag | ( | TIMER_T * | timer | ) |

This function clears the Timer wakeup interrupt flag.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 272 of file timer.h.

## ◆ TIMER_Close()

void TIMER_Close | ( | TIMER_T * | timer | ) |

This function stops Timer counting and disable the Timer interrupt function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 73 of file timer.c.

## ◆ TIMER_Delay()

void TIMER_Delay | ( | TIMER_T * | timer,
|  | uint32_t | u32Usec
| ) |  |

This function is used to create a delay loop for u32usec micro seconds.

Parameters

  [in] | timer | The base address of Timer module
  [in] | u32Usec | Delay period in micro seconds with 10 usec every step. Valid values are between 10~1000000 (10 micro second ~ 1 second)

Returns
  None

Note
  This function overwrites the register setting of the timer used to count the delay time.
  This function use polling mode. So there is no need to enable interrupt for the timer module used to generate delay

Definition at line 87 of file timer.c.

## ◆ TIMER_DisableCapture()

void TIMER_DisableCapture | ( | TIMER_T * | timer | ) |

This function is used to disable the Timer capture function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 158 of file timer.c.

## ◆ TIMER_DisableCaptureDebounce()

__STATIC_INLINE void TIMER_DisableCaptureDebounce | ( | TIMER_T * | timer | ) |

This function is used to disable the capture pin detection de-bounce function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 145 of file timer.h.

## ◆ TIMER_DisableCaptureInt()

__STATIC_INLINE void TIMER_DisableCaptureInt | ( | TIMER_T * | timer | ) |

This function is used to disable the Timer capture trigger interrupt function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 206 of file timer.h.

## ◆ TIMER_DisableEventCounter()

void TIMER_DisableEventCounter | ( | TIMER_T * | timer | ) |

This function is used to disable the Timer event counter function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 184 of file timer.c.

## ◆ TIMER_DisableEventCounterDebounce()

__STATIC_INLINE void TIMER_DisableEventCounterDebounce | ( | TIMER_T * | timer | ) |

This function is used to disable the counter pin detection de-bounce function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 166 of file timer.h.

## ◆ TIMER_DisableFreqCounter()

void TIMER_DisableFreqCounter | ( | TIMER_T * | timer | ) |

This function is used to disable the Timer frequency counter function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 249 of file timer.c.

## ◆ TIMER_DisableInt()

__STATIC_INLINE void TIMER_DisableInt | ( | TIMER_T * | timer | ) |

This function is used to disable the Timer time-out interrupt function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 186 of file timer.h.

## ◆ TIMER_DisableWakeup()

__STATIC_INLINE void TIMER_DisableWakeup | ( | TIMER_T * | timer | ) |

This function is used to disable the Timer wake-up function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 124 of file timer.h.

## ◆ TIMER_EnableCapture()

void TIMER_EnableCapture | ( | TIMER_T * | timer,
|  | uint32_t | u32CapMode,
|  | uint32_t | u32Edge
| ) |  |

This function is used to enable timer capture function with specified mode and capture edge.

Parameters

  [in] | timer | The base address of Timer module
  [in] | u32CapMode | Timer capture mode. Could be TIMER_CAPTURE_FREE_COUNTING_MODE TIMER_CAPTURE_TRIGGER_COUNTING_MODE TIMER_CAPTURE_COUNTER_RESET_MODE
  [in] | u32Edge | Timer capture edge. Possible values are TIMER_CAPTURE_FALLING_EDGE TIMER_CAPTURE_RISING_EDGE TIMER_CAPTURE_FALLING_THEN_RISING_EDGE TIMER_CAPTURE_RISING_THEN_FALLING_EDGE

Returns
  None

Note
  Timer frequency should be configured separately by using TIMER_Open function, or program registers directly

Definition at line 144 of file timer.c.

## ◆ TIMER_EnableCaptureDebounce()

__STATIC_INLINE void TIMER_EnableCaptureDebounce | ( | TIMER_T * | timer | ) |

This function is used to enable the capture pin detection de-bounce function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 135 of file timer.h.

## ◆ TIMER_EnableCaptureInt()

__STATIC_INLINE void TIMER_EnableCaptureInt | ( | TIMER_T * | timer | ) |

This function is used to enable the Timer capture trigger interrupt function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 196 of file timer.h.

## ◆ TIMER_EnableEventCounter()

void TIMER_EnableEventCounter | ( | TIMER_T * | timer,
|  | uint32_t | u32Edge
| ) |  |

This function is used to enable the Timer counter function with specify detection edge.

Parameters

  [in] | timer | The base address of Timer module
  [in] | u32Edge | Detection edge of counter pin. Could be ether TIMER_COUNTER_RISING_EDGE, or TIMER_COUNTER_FALLING_EDGE

Returns
  None

Note
  Timer compare value should be configured separately by using TIMER_SET_CMP_VALUE macro or program registers directly

Definition at line 173 of file timer.c.

## ◆ TIMER_EnableEventCounterDebounce()

__STATIC_INLINE void TIMER_EnableEventCounterDebounce | ( | TIMER_T * | timer | ) |

This function is used to enable the counter pin detection de-bounce function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 156 of file timer.h.

## ◆ TIMER_EnableFreqCounter()

void TIMER_EnableFreqCounter | ( | TIMER_T * | timer,
|  | uint32_t | u32DropCount,
|  | uint32_t | u32Timeout,
|  | uint32_t | u32EnableInt
| ) |  |

This function is used to enable the Timer frequency counter function.

Parameters

  [in] | timer | The base address of Timer module. Can be TIMER0 or TIMER2
  [in] | u32DropCount | This parameter has no effect in Nano100 series BSP
  [in] | u32Timeout | This parameter has no effect in Nano100 series BSP
  [in] | u32EnableInt | Enable interrupt assertion after capture complete or not. Valid values are TRUE and FALSE

Returns
  None

This function is used to calculate input event frequency. After enable this function, a pair of timers, TIMER0 and TIMER1, or TIMER2 and TIMER3 will be configured for this function. The mode used to calculate input event frequency is mentioned as "Inter Timer Trigger Mode" in Technical Reference Manual

Definition at line 229 of file timer.c.

## ◆ TIMER_EnableInt()

__STATIC_INLINE void TIMER_EnableInt | ( | TIMER_T * | timer | ) |

This function is used to enable the Timer time-out interrupt function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 176 of file timer.h.

## ◆ TIMER_EnableWakeup()

__STATIC_INLINE void TIMER_EnableWakeup | ( | TIMER_T * | timer | ) |

This function is used to enable the Timer wake-up function.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Note
  To wake the system from power down mode, timer clock source must be ether LXT or LIRC

Definition at line 114 of file timer.h.

## ◆ TIMER_GetCaptureData()

__STATIC_INLINE uint32_t TIMER_GetCaptureData | ( | TIMER_T * | timer | ) |

This function gets the Timer capture data.

Parameters

  [in] | timer | The base address of Timer module

Returns
  Timer capture data value

Definition at line 282 of file timer.h.

## ◆ TIMER_GetCaptureIntFlag()

__STATIC_INLINE uint32_t TIMER_GetCaptureIntFlag | ( | TIMER_T * | timer | ) |

This function indicates Timer capture interrupt occurred or not.

Parameters

  [in] | timer | The base address of Timer module

Returns
  Timer capture interrupt occurred or not

Return values

  0 | Timer capture interrupt did not occur
  1 | Timer capture interrupt occurred

Definition at line 240 of file timer.h.

## ◆ TIMER_GetCounter()

__STATIC_INLINE uint32_t TIMER_GetCounter | ( | TIMER_T * | timer | ) |

This function reports the current timer counter value.

Parameters

  [in] | timer | The base address of Timer module

Returns
  Timer counter value

Definition at line 292 of file timer.h.

## ◆ TIMER_GetIntFlag()

__STATIC_INLINE uint32_t TIMER_GetIntFlag | ( | TIMER_T * | timer | ) |

This function indicates Timer time-out interrupt occurred or not.

Parameters

  [in] | timer | The base address of Timer module

Returns
  Timer time-out interrupt occurred or not

Return values

  0 | Timer time-out interrupt did not occur
  1 | Timer time-out interrupt occurred

Definition at line 218 of file timer.h.

## ◆ TIMER_GetModuleClock()

uint32_t TIMER_GetModuleClock | ( | TIMER_T * | timer | ) |

This function is used to get the clock frequency of Timer.

Parameters

  [in] | timer | The base address of Timer module

Returns
  Timer clock frequency

Note
  This function cannot return correct clock rate if timer source is external clock input.

Definition at line 195 of file timer.c.

## ◆ TIMER_GetWakeupFlag()

__STATIC_INLINE uint32_t TIMER_GetWakeupFlag | ( | TIMER_T * | timer | ) |

This function indicates Timer has waked up system or not.

Parameters

  [in] | timer | The base address of Timer module

Returns
  Timer has waked up system or not

Return values

  0 | Timer did not wake up system
  1 | Timer wake up system

Definition at line 262 of file timer.h.

## ◆ TIMER_Open()

uint32_t TIMER_Open | ( | TIMER_T * | timer,
|  | uint32_t | u32Mode,
|  | uint32_t | u32Freq
| ) |  |

This function is used to configure timer to operate in specified mode and frequency. If timer cannot work in target frequency, a closest frequency will be chose and returned.

Parameters

  [in] | timer | The base address of Timer module
  [in] | u32Mode | Operation mode. Possible options are TIMER_ONESHOT_MODE TIMER_PERIODIC_MODE TIMER_TOGGLE_MODE
  [in] | u32Freq | Target working frequency

Returns
  Real Timer working frequency

Note
  After calling this function, Timer is NOT running yet. But could start timer running be calling TIMER_Start macro or program registers directly

Definition at line 41 of file timer.c.

## ◆ TIMER_SetTriggerSource()

void TIMER_SetTriggerSource | ( | TIMER_T * | timer,
|  | uint32_t | u32Src
| ) |  |

This function is used to select the interrupt source used to trigger other modules.

Parameters

  [in] | timer | The base address of Timer module
  [in] | u32Src | Selects the interrupt source to trigger other modules. Could be: TIMER_TIMEOUT_TRIGGER TIMER_CAPTURE_TRIGGER

Returns
  None

Definition at line 262 of file timer.c.

## ◆ TIMER_SetTriggerTarget()

void TIMER_SetTriggerTarget | ( | TIMER_T * | timer,
|  | uint32_t | u32Mask
| ) |  |

This function is used to set modules trigger by timer interrupt.

Parameters

  [in] | timer | The base address of Timer module
  [in] | u32Mask | The mask of modules (ADC, DAC and PDMA) trigger by timer. Is the combination of TIMER_CTL_PDMA_TEEN_Msk, and TIMER_CTL_ADC_TEEN_Msk,

Returns
  None

Definition at line 275 of file timer.c.

## ◆ TIMER_Start()

__STATIC_INLINE void TIMER_Start | ( | TIMER_T * | timer | ) |

This function is used to start Timer counting.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 93 of file timer.h.

## ◆ TIMER_Stop()

__STATIC_INLINE void TIMER_Stop | ( | TIMER_T * | timer | ) |

This function is used to stop Timer counting.

Parameters

  [in] | timer | The base address of Timer module

Returns
  None

Definition at line 103 of file timer.h.