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)));
98 uint32_t u32Cntr, i = 0UL;
106 u32Usec = ((u32Usec + 99) / 100) * 100;
110 u32Usec = ((u32Usec + 9) / 10) * 10;
113 if(u32Clk >= 0x2000000)
118 else if(u32Clk >= 0x1000000)
125 u64Cmpr = ((
long long)u32Usec * (
long long)u32Clk) / (
long long)1000000;
127 timer->
CMP = (uint32_t)u64Cmpr;
132 for(; delay > 0; delay--)
141 u32Cntr = timer->
CNT;
145 if(u32Cntr == timer->
CNT)
155 u32Cntr = timer->
CNT;
193 timer->
EXTCTL &= ~TIMER_EXTCTL_CAPEN_Msk;
208 timer->
EXTCTL = (timer->
EXTCTL & ~TIMER_EXTCTL_CNTPHASE_Msk) | u32Edge;
219 timer->
CTL &= ~TIMER_CTL_EXTCNTEN_Msk;
Mini55 series peripheral access layer header file. This file contains all the peripheral register's d...
#define TIMER_EXTCTL_CAPFUNCS_Msk
#define TIMER_EXTCTL_CAPMODE_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
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.
int32_t TIMER_Delay(TIMER_T *timer, uint32_t u32Usec)
This API is used to create a delay loop for u32usec micro seconds.
#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.