45 uint32_t u32Cmpr = 0, u32Prescale = 0;
48 if(u32Freq > (u32Clk / 2))
54 if(u32Clk >= 0x4000000)
59 else if(u32Clk >= 0x2000000)
64 else if(u32Clk >= 0x1000000)
70 u32Cmpr = u32Clk / u32Freq;
73 timer->
CTL = u32Mode | u32Prescale;
76 return(u32Clk / (u32Cmpr * (u32Prescale + 1)));
106 uint32_t u32Cntr, u32Delay, u32Prescale = 0, delay =
SystemCoreClock / u32Clk + 1;
115 u32Usec = ((u32Usec + 99) / 100) * 100;
119 u32Usec = ((u32Usec + 9) / 10) * 10;
122 if(u32Clk >= 0x4000000)
127 else if(u32Clk >= 0x2000000)
132 else if(u32Clk >= 0x1000000)
139 fCmpr = ((double)u32Usec * (
double)u32Clk) / 1000000.0;
141 timer->
CMP = (uint32_t)fCmpr;
146 for(; delay > 0; delay--)
155 u32Cntr = timer->
CNT;
159 if(u32Cntr == timer->
CNT)
169 u32Cntr = timer->
CNT;
203 timer->
EXTCTL &= ~TIMER_EXTCTL_CAPEN_Msk;
219 timer->
EXTCTL = (timer->
EXTCTL & ~TIMER_EXTCTL_CNTPHASE_Msk) | u32Edge;
230 timer->
CTL &= ~TIMER_CTL_EXTCNTEN_Msk;
261 return(au32Clk[u32Src]);
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
#define CLK_CLKSEL1_TMR1SEL_Msk
#define CLK_CLKSEL1_TMR0SEL_Msk
#define TIMER_EXTCTL_CAPFUNCS_Msk
#define CLK_CLKSEL1_TMR2SEL_Pos
#define TIMER_EXTCTL_CAPEDGE_Msk
#define CLK_CLKSEL1_TMR1SEL_Pos
#define TIMER_CTL_EXTCNTEN_Msk
#define CLK_CLKSEL1_TMR3SEL_Msk
#define CLK_CLKSEL0_PCLKSEL_Msk
#define TIMER_CTL_ACTSTS_Msk
#define TIMER_CTL_CNTEN_Msk
#define CLK_CLKSEL1_TMR3SEL_Pos
#define TIMER_EXTCTL_CAPEN_Msk
#define CLK_CLKSEL1_TMR0SEL_Pos
#define CLK_CLKSEL1_TMR2SEL_Msk
#define TIMER_TIMEOUT_ERR
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.