45 uint32_t u32Cmpr = 0, u32Prescale = 0;
48 if(u32Freq > (u32Clk / 2))
54 if(u32Clk >= 0x2000000)
59 else if(u32Clk >= 0x1000000)
64 u32Cmpr = u32Clk / u32Freq;
67 timer->
CTL = u32Mode | u32Prescale;
70 return(u32Clk / (u32Cmpr * (u32Prescale + 1)));
105 u32Usec = ((u32Usec + 99) / 100) * 100;
109 u32Usec = ((u32Usec + 9) / 10) * 10;
112 if(u32Clk >= 0x2000000)
117 else if(u32Clk >= 0x1000000)
124 fCmpr = ((float)u32Usec * (
float)u32Clk) / 1000000.0;
126 timer->
CMP = (uint32_t)fCmpr;
131 for(; delay > 0; delay--)
172 timer->
EXTCTL &= ~TIMER_EXTCTL_CAPEN_Msk;
187 timer->
EXTCTL = (timer->
EXTCTL & ~TIMER_EXTCTL_CNTPHASE_Msk) | u32Edge;
198 timer->
CTL &= ~TIMER_CTL_EXTCNTEN_Msk;
Mini58 series peripheral access layer header file. This file contains all the peripheral register's d...
#define TIMER_EXTCTL_CAPSEL_Msk
#define TIMER_EXTCTL_CAPFUNCS_Msk
#define TIMER_EXTCTL_CAPEDGE_Msk
#define TIMER_CTL_EXTCNTEN_Msk
#define TIMER_CTL_ACTSTS_Msk
#define TIMER_CTL_CNTEN_Msk
#define TIMER_EXTCTL_CAPEN_Msk
#define CLK_CLKSEL1_TMR1SEL_Msk
#define CLK_CLKSEL1_TMR0SEL_Msk
#define CLK_CLKSEL1_TMR1SEL_Pos
#define CLK_PWRCTL_XTLEN_Msk
#define CLK_CLKSEL1_TMR0SEL_Pos
#define CLK
Pointer to CLK register structure.
#define TIMER0
Pointer to Timer 0 register structure.
void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec)
This API is used to create a delay loop for u32usec micro seconds.
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.
uint32_t TIMER_GetModuleClock(TIMER_T *timer)
This API is used to get the clock frequency of Timer.
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.