45 uint32_t u32Cmpr = 0, u32Prescale = 0;
48 if(u32Freq > (u32Clk / 2))
59 u32Cmpr = u32Clk / u32Freq;
61 timer->
CMPR = u32Cmpr;
62 timer->
PRECNT = u32Prescale;
66 return(u32Clk / (u32Cmpr * (u32Prescale + 1)));
99 u32Usec = ((u32Usec + 99) / 100) * 100;
103 u32Usec = ((u32Usec + 9) / 10) * 10;
106 if(u32Clk > 0xFFFFFF)
113 u64Cmpr = (
long long)u32Usec * (
long long)u32Clk / (
long long)1000000;
115 timer->
CMPR = (uint32_t)u64Cmpr;
116 timer->
PRECNT = u32Prescale;
121 for(; delay > 0; delay--)
198 uint32_t u32Src, u32Div;
223 return au32Clk[u32Src] / u32Div;
264 uint32_t u32DropCount,
266 uint32_t u32EnableInt)
271 if(u32DropCount != 0 || u32Timeout >= 2)
274 u32Timeout = 0xFFFFFF;
279 t->
CMPR = u32Timeout;
#define TIMER_CTL_INTR_TRG_MODE_Msk
#define TIMER1
Pointer to TIMER1 register structure.
#define CLK_CLKDIV1_TMR2_N_Pos
#define TIMER_CTL_ADC_TEEN_Msk
#define CLK
Pointer to CLK register structure.
#define CLK_CLKDIV1_TMR2_N_Msk
#define CLK_CLKSEL1_TMR0_S_Pos
#define TIMER_ECTL_EVNT_DROP_CNT_Pos
#define CLK_CLKSEL1_TMR1_S_Msk
#define CLK_CLKDIV1_TMR0_N_Pos
#define CLK_CLKDIV1_TMR3_N_Msk
#define TIMER_CTL_EVENT_EDGE_Msk
#define TIMER_CTL_TCAP_CNT_MODE_Msk
#define CLK_CLKDIV1_TMR3_N_Pos
#define CLK_PWRCTL_HIRC_FSEL_Msk
#define CLK_CLKDIV1_TMR1_N_Pos
#define TIMER_CTL_INTR_TRG_EN_Msk
uint32_t TIMER_GetModuleClock(TIMER_T *timer)
This API is used to get the clock frequency of Timer.
#define CLK_CLKSEL2_TMR2_S_Msk
#define TIMER_CTL_TCAP_MODE_Msk
Nano102/112 peripheral access layer header file. This file contains all the peripheral register's def...
void TIMER_DisableCapture(TIMER_T *timer)
This API is used to disable the Timer capture function.
#define TIMER_CTL_TCAP_EN_Msk
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.
void TIMER_Close(TIMER_T *timer)
This API stops Timer counting and disable the Timer interrupt function.
#define TIMER_CTL_EVENT_EN_Msk
void TIMER_ResetCounter(TIMER_T *timer)
This function is used to reset the Timer counter value.
void TIMER_DisableEventCounter(TIMER_T *timer)
This API is used to disable the Timer event counter function.
#define TIMER_CTL_CAP_TRG_EN_Msk
#define CLK_CLKSEL2_TMR3_S_Msk
#define TIMER0
Pointer to TIMER0 register structure.
#define CLK_CLKSEL2_TMR3_S_Pos
#define TIMER_CTL_TCAP_EDGE_Msk
#define CLK_CLKSEL1_TMR0_S_Msk
#define CLK_CLKSEL2_TMR2_S_Pos
#define CLK_CLKDIV1_TMR0_N_Msk
uint32_t CLK_GetHCLKFreq(void)
This function get HCLK frequency. The frequency unit is Hz.
void TIMER_DisableFreqCounter(TIMER_T *timer)
This function is used to disable the Timer frequency counter function.
#define TIMER3
Pointer to TIMER3 register structure.
#define CLK_CLKSEL1_TMR1_S_Pos
void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec)
This API is used to create a delay loop for u32usec micro seconds.
void TIMER_SetTriggerSource(TIMER_T *timer, uint32_t u32Src)
This function is used to select the interrupt source used to trigger other modules.
void TIMER_SetTriggerTarget(TIMER_T *timer, uint32_t u32Mask)
This function is used to set modules trigger by timer interrupt.
#define TIMER_CTL_TMR_EN_Msk
#define TIMER_CTL_PDMA_TEEN_Msk
#define TIMER2
Pointer to TIMER2 register structure.
void TIMER_EnableCapture(TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge)
This API is used to enable timer capture function with specified mode and capture edge.
void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge)
This function is used to enable the Timer counter function with specify detection edge.
#define TIMER_CTL_TMR_ACT_Msk
#define TIMER_IER_TCAP_IE_Msk
uint32_t TIMER_Open(TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq)
This API is used to configure timer to operate in specified mode and frequency. If timer cannot work ...
#define CLK_CLKDIV1_TMR1_N_Msk