44 uint32_t u32Cmpr = 0UL, u32Prescale = 0UL;
47 if(u32Freq > (u32Clk / 2UL))
53 u32Cmpr = u32Clk / u32Freq;
54 u32Prescale = (u32Cmpr >> 24);
55 if (u32Prescale > 0UL)
56 u32Cmpr = u32Cmpr / (u32Prescale + 1UL);
59 timer->
CTL = u32Mode | u32Prescale;
62 return(u32Clk / (u32Cmpr * (u32Prescale + 1UL)));
96 uint32_t u32Cmpr, u32NsecPerTick;
102 if(u32Clk <= 1000000UL)
108 if(u32Usec > 1000000UL)
119 if(u32Usec > 1000000UL)
125 if(u32Clk <= 1000000UL)
128 u32NsecPerTick = 1000000000UL / u32Clk;
129 u32Cmpr = (u32Usec * 1000UL) / u32NsecPerTick;
133 u32Cmpr = u32Usec * (u32Clk / 1000000UL);
134 u32Prescale = (u32Cmpr >> 24);
135 if (u32Prescale > 0UL)
136 u32Cmpr = u32Cmpr / (u32Prescale + 1UL);
139 timer->
CMP = u32Cmpr;
144 for(; delay > 0UL; delay--)
240 uint32_t u32Src, u32Clk;
273 u32Clk = au32Clk[u32Src];
295 uint32_t u32DropCount,
297 uint32_t u32EnableInt)
#define TIMER_EXTCTL_CAPIEN_Msk
#define CLK_CLKSEL1_TMR3SEL_Msk
void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge)
Enable Timer Counter Function.
void TIMER_SetTriggerSource(TIMER_T *timer, uint32_t u32Src)
This function is used to select the interrupt source used to trigger other modules.
#define TIMER_CTL_INTRGEN_Msk
void TIMER_SetTriggerTarget(TIMER_T *timer, uint32_t u32Mask)
This function is used to set modules trigger by timer interrupt.
#define TIMER_CTL_EXTCNTEN_Msk
uint32_t TIMER_Open(TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq)
Open Timer with Operate Mode and Frequency.
uint32_t TIMER_GetModuleClock(TIMER_T *timer)
Get Timer Clock Frequency.
#define CLK_CLKSEL1_TMR2SEL_Msk
void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec)
Create a specify Delay Time.
#define TIMER_CTL_ACTSTS_Msk
NuMicro peripheral access layer header file.
#define TIMER_TRGCTL_TRGSSEL_Msk
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.
void TIMER_DisableFreqCounter(TIMER_T *timer)
This function is used to disable the Timer frequency counter function.
#define TIMER_ONESHOT_MODE
void TIMER_EnableCapture(TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge)
Enable Timer Capture Function.
uint32_t CLK_GetPCLK1Freq(void)
Get PCLK1 frequency.
#define TIMER_EXTCTL_CAPFUNCS_Msk
#define CLK_CLKSEL1_TMR2SEL_Pos
uint32_t CLK_GetPCLK0Freq(void)
Get PCLK0 frequency.
#define CLK_CLKSEL1_TMR1SEL_Msk
void TIMER_DisableEventCounter(TIMER_T *timer)
Disable Timer Counter Function.
#define CLK_CLKSEL1_TMR3SEL_Pos
#define TIMER_EXTCTL_CAPEN_Msk
void TIMER_DisableCapture(TIMER_T *timer)
Disable Timer Capture Function.
#define CLK_CLKSEL1_TMR0SEL_Msk
void TIMER_Close(TIMER_T *timer)
Stop Timer Counting.
#define TIMER_TRGCTL_TRGPDMA_Msk
#define TIMER_EXTCTL_CNTPHASE_Msk
#define CLK_CLKSEL1_TMR0SEL_Pos
#define TIMER_TRGCTL_TRGEADC_Msk
#define TIMER_TRGCTL_TRGEPWM_Msk
#define TIMER_TRGCTL_TRGDAC_Msk
#define TIMER_CTL_CNTEN_Msk
#define CLK_CLKSEL1_TMR1SEL_Pos
#define TIMER_EXTCTL_CAPEDGE_Msk