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)));
96 uint32_t u32Cntr, i = 0UL;
103 u32Usec = ((u32Usec + 99) / 100) * 100;
107 u32Usec = ((u32Usec + 9) / 10) * 10;
110 if(u32Clk > 0xFFFFFF)
117 u64Cmpr = (
long long)u32Usec * (
long long)u32Clk / (
long long)1000000;
119 timer->
CMP = (uint32_t)u64Cmpr;
120 timer->
PRECNT = u32Prescale;
125 for(u32Delay = (
SystemCoreClock / u32Clk) + 1UL; u32Delay > 0UL; u32Delay--)
134 u32Cntr = timer->
CNT;
138 if(u32Cntr == timer->
CNT)
148 u32Cntr = timer->
CNT;
185 timer->
CTL &= ~TIMER_CTL_CAPEN_Msk;
200 timer->
CTL = (timer->
CTL & ~TIMER_CTL_CNTPHASE_Msk) | u32Edge;
211 timer->
CTL &= ~TIMER_CTL_EXTCNTEN_Msk;
222 uint32_t u32Src, u32Div;
247 return au32Clk[u32Src] / u32Div;
305 uint32_t u32DropCount,
307 uint32_t u32EnableInt)
312 if(u32DropCount != 0 || u32Timeout >= 2)
315 u32Timeout = 0xFFFFFF;
346 timer->
CTL = (timer->
CTL & ~TIMER_CTL_TRGSSEL_Msk) | u32Src;
NANO103 peripheral access layer header file. This file contains all the peripheral register's definit...
#define TIMER_CTL_INTRTGEN_Msk
#define TIMER_INTEN_CAPIEN_Msk
#define TIMER_CTL_CAPCNTMD_Msk
#define TIMER_ECTL_EVNTDPCNT_Pos
#define TIMER_CTL_CAPFUNCS_Msk
#define TIMER_CTL_TRGADC_Msk
#define TIMER_CTL_EXTCNTEN_Msk
#define TIMER_CTL_TRGPDMA_Msk
#define TIMER_CTL_CAPEDGE_Msk
#define TIMER_CTL_INTRTGMD_Msk
#define TIMER_CTL_ACTSTS_Msk
#define TIMER_CTL_CNTEN_Msk
#define TIMER_CTL_CAPEN_Msk
#define TIMER_CTL_TRGPWM_Msk
uint32_t CLK_GetHCLKFreq(void)
This function get HCLK frequency. The frequency unit is Hz.
#define CLK_CLKSEL1_TMR1SEL_Msk
#define CLK_CLKSEL1_TMR0SEL_Msk
#define CLK_CLKSEL2_TMR2SEL_Msk
#define CLK_CLKDIV1_TMR3DIV_Msk
#define CLK_CLKSEL2_TMR3SEL_Msk
#define CLK_CLKSEL1_TMR1SEL_Pos
#define CLK_CLKDIV1_TMR1DIV_Msk
#define CLK_CLKSEL2_TMR2SEL_Pos
#define CLK_PWRCTL_HIRC0FSEL_Msk
#define CLK_CLKDIV1_TMR2DIV_Pos
#define CLK_CLKDIV1_TMR0DIV_Pos
#define CLK_CLKDIV1_TMR2DIV_Msk
#define CLK_CLKDIV1_TMR0DIV_Msk
#define CLK_CLKDIV1_TMR3DIV_Pos
#define CLK_CLKSEL2_TMR3SEL_Pos
#define CLK_CLKSEL1_TMR0SEL_Pos
#define CLK_CLKDIV1_TMR1DIV_Pos
#define CLK_CLKSEL0_HIRCSEL_Msk
#define CLK
Pointer to CLK register structure.
#define TIMER1
Pointer to TIMER1 register structure.
#define TIMER3
Pointer to TIMER3 register structure.
#define TIMER2
Pointer to TIMER2 register structure.
#define TIMER0
Pointer to TIMER0 register structure.
#define TIMER_TIMEOUT_ERR
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_DisableCapture(TIMER_T *timer)
This API is used to disable the Timer capture function.
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 ...
void TIMER_DisableEventCounter(TIMER_T *timer)
This API is used to disable the Timer event counter function.
void TIMER_ResetCounter(TIMER_T *timer)
This function is used to reset the Timer counter value.
uint32_t TIMER_GetModuleClock(TIMER_T *timer)
This API is used to get the clock frequency of Timer.
void TIMER_DisableFreqCounter(TIMER_T *timer)
This function is used to disable the Timer frequency counter function.
void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge)
This function is used to enable the Timer counter function with specify detection edge.
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_Close(TIMER_T *timer)
This API stops Timer counting and disable the Timer interrupt function.
void TIMER_SetTriggerTarget(TIMER_T *timer, uint32_t u32Mask)
This function is used to set modules trigger by timer interrupt.
int32_t TIMER_Delay(TIMER_T *timer, uint32_t u32Usec)
This API is used to create a delay loop for u32usec micro seconds.
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.