45 uint32_t u32Cmpr = 0, u32Prescale = 0;
48 if(u32Freq > (u32Clk / 2))
59 u32Cmpr = u32Clk / u32Freq;
62 timer->
TCSR = u32Mode | u32Prescale;
63 timer->
TCMPR = u32Cmpr;
65 return(u32Clk / (u32Cmpr * (u32Prescale + 1)));
100 u32Usec = ((u32Usec + 99) / 100) * 100;
104 u32Usec = ((u32Usec + 9) / 10) * 10;
107 if(u32Clk > 0xFFFFFF)
114 fCmpr = ((float)u32Usec * (
float)u32Clk) / 1000000.0;
116 timer->
TCMPR = (uint32_t)fCmpr;
117 timer->
TCSR = TIMER_TCSR_CEN_Msk | u32Prescale;
121 for(; delay > 0; delay--)
127 while((timer->
TCSR & TIMER_TCSR_CACT_Msk) && (delay-- > 0));
149 timer->
TEXCON = (timer->
TEXCON & ~(TIMER_TEXCON_CAP_MODE_Msk |
150 TIMER_TEXCON_RSTCAPSEL_Msk |
151 TIMER_TEXCON_TEX_EDGE_Msk)) |
152 u32CapMode | u32Edge | TIMER_TEXCON_TEXEN_Msk;
162 timer->
TEXCON &= ~TIMER_TEXCON_TEXEN_Msk;
177 timer->
TEXCON = (timer->
TEXCON & ~TIMER_TEXCON_TX_PHASE_Msk) | u32Edge;
178 timer->
TCSR |= TIMER_TCSR_CTB_Msk;
188 timer->
TCSR &= ~TIMER_TCSR_CTB_Msk;
201 u32Src = (
CLK->CLKSEL1 & CLK_CLKSEL1_TMR0_S_Msk) >> CLK_CLKSEL1_TMR0_S_Pos;
203 u32Src = (
CLK->CLKSEL1 & CLK_CLKSEL1_TMR1_S_Msk) >> CLK_CLKSEL1_TMR1_S_Pos;
NUC029FAE peripheral access layer header file. This file contains all the peripheral register's defin...
#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.