45 uint32_t u32Cmpr = 0, u32Prescale = 0;
48 if(u32Freq > (u32Clk / 2))
59 u32Cmpr = u32Clk / u32Freq;
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->
CMP = (uint32_t)u64Cmpr;
116 timer->
PRECNT = u32Prescale;
121 for(; delay > 0; delay--)
198 uint32_t u32Src, u32Div;
223 return au32Clk[u32Src] / u32Div;
281 uint32_t u32DropCount,
283 uint32_t u32EnableInt)
288 if(u32DropCount != 0 || u32Timeout >= 2)
291 u32Timeout = 0xFFFFFF;
#define CLK_CLKSEL2_TMR3SEL_Pos
#define TIMER2
Pointer to TIMER2 register structure.
#define TIMER_CTL_INTRTGMD_Msk
#define TIMER_INTEN_CAPIEN_Msk
#define TIMER_CTL_TRGSSEL_Msk
#define CLK_PWRCTL_HIRC0FSEL_Msk
void TIMER_Close(TIMER_T *timer)
This API stops Timer counting and disable the Timer interrupt function.
void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge)
This function is used to enable the Timer counter function with specify detection edge.
#define CLK_CLKSEL1_TMR0SEL_Msk
#define TIMER_CTL_EXTCNTEN_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_CLKSEL1_TMR1SEL_Pos
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.
#define CLK_CLKDIV1_TMR0DIV_Pos
#define TIMER_CTL_CNTEN_Msk
#define CLK_CLKDIV1_TMR2DIV_Msk
void TIMER_DisableEventCounter(TIMER_T *timer)
This API is used to disable the Timer event counter function.
#define TIMER_CTL_CAPEN_Msk
#define TIMER_CTL_CAPEDGE_Msk
#define TIMER1
Pointer to TIMER1 register structure.
void TIMER_ResetCounter(TIMER_T *timer)
This function is used to reset the Timer counter value.
#define TIMER_CTL_INTRTGEN_Msk
#define CLK_CLKDIV1_TMR1DIV_Pos
#define TIMER_CTL_TRGPWM_Msk
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.
#define TIMER_ECTL_EVNTDPCNT_Pos
#define CLK_CLKDIV1_TMR3DIV_Pos
#define CLK_CLKSEL1_TMR0SEL_Pos
#define CLK_CLKDIV1_TMR2DIV_Pos
#define TIMER_CTL_TRGPDMA_Msk
#define TIMER_CTL_CAPCNTMD_Msk
#define TIMER_CTL_ACTSTS_Msk
#define CLK_CLKSEL2_TMR2SEL_Pos
uint32_t TIMER_GetModuleClock(TIMER_T *timer)
This API is used to get the clock frequency of Timer.
#define TIMER_CTL_CNTPHASE_Msk
void TIMER_SetTriggerTarget(TIMER_T *timer, uint32_t u32Mask)
This function is used to set modules trigger by timer interrupt.
uint32_t CLK_GetHCLKFreq(void)
This function get HCLK frequency. The frequency unit is Hz.
#define CLK_CLKSEL2_TMR2SEL_Msk
#define TIMER3
Pointer to TIMER3 register structure.
void TIMER_DisableCapture(TIMER_T *timer)
This API is used to disable the Timer capture function.
NANO103 peripheral access layer header file. This file contains all the peripheral register's definit...
#define TIMER_CTL_CAPFUNCS_Msk
#define CLK_CLKSEL0_HIRCSEL_Msk
#define CLK_CLKSEL1_TMR1SEL_Msk
void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec)
This API is used to create a delay loop for u32usec micro seconds.
#define CLK_CLKSEL2_TMR3SEL_Msk
#define CLK_CLKDIV1_TMR1DIV_Msk
#define CLK
Pointer to CLK register structure.
void TIMER_DisableFreqCounter(TIMER_T *timer)
This function is used to disable the Timer frequency counter function.
#define TIMER0
Pointer to TIMER0 register structure.
#define CLK_CLKDIV1_TMR0DIV_Msk
#define TIMER_CTL_TRGADC_Msk
void TIMER_SetTriggerSource(TIMER_T *timer, uint32_t u32Src)
This function is used to select the interrupt source used to trigger other modules.
#define CLK_CLKDIV1_TMR3DIV_Msk