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;
66 timer->
CMPR = u32Cmpr;
67 timer->
PRECNT = u32Prescale;
71 return(u32Clk / (u32Cmpr * (u32Prescale + 1)));
104 u32Usec = ((u32Usec + 99) / 100) * 100;
108 u32Usec = ((u32Usec + 9) / 10) * 10;
111 if(u32Clk >= 0x2000000)
116 else if(u32Clk >= 0x1000000)
123 u64Cmpr = ((
long long)u32Usec * (
long long)u32Clk) / (
long long)1000000;
125 timer->
CMPR = (uint32_t)u64Cmpr;
126 timer->
PRECNT = u32Prescale;
131 for(; delay > 0; delay--)
172 timer->
CTL &= ~TIMER_CTL_TCAP_EN_Msk;
187 timer->
CTL = (timer->
CTL & ~TIMER_CTL_EVENT_EDGE_Msk) | u32Edge;
198 timer->
CTL &= ~TIMER_CTL_EVENT_EN_Msk;
222 return au32Clk[u32Src];
242 uint32_t u32DropCount,
244 uint32_t u32EnableInt)
263 timer->
CTL &= ~TIMER_CTL_INTR_TRG_EN_Msk;
276 timer->
CTL = (timer->
CTL & ~TIMER_CTL_CAP_TRG_EN_Msk) | u32Src;
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
#define TIMER_CTL_TCAP_MODE_Msk
#define TIMER_CTL_TCAP_CNT_MODE_Msk
#define TIMER_CTL_INTR_TRG_EN_Msk
#define TIMER_CTL_EVENT_EN_Msk
#define TIMER_CTL_TMR_EN_Msk
#define TIMER_IER_TCAP_IE_Msk
#define TIMER_CTL_PDMA_TEEN_Msk
#define TIMER_CTL_TMR_ACT_Msk
#define TIMER_CTL_DAC_TEEN_Msk
#define TIMER_CTL_ADC_TEEN_Msk
#define TIMER_CTL_TCAP_EN_Msk
#define TIMER_CTL_TCAP_EDGE_Msk
#define CLK_CLKSEL2_TMR2_S_Pos
#define CLK_CLKSEL2_TMR3_S_Pos
#define CLK_CLKSEL2_TMR2_S_Msk
#define CLK_CLKSEL2_TMR3_S_Msk
#define CLK_CLKSEL1_TMR1_S_Msk
#define CLK_CLKSEL1_TMR0_S_Pos
#define CLK_CLKSEL1_TMR0_S_Msk
#define CLK_CLKSEL1_TMR1_S_Pos
#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.
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_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_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.
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.