| //timer.c 
 /*************************************************************************************************************
 * 文件名:                        timer.c
 * 功能:                        NUC970 定时器支持
 * 作者:                        cp1300@139.com
 * 创建时间:                2020-08-31
 * 最后修改时间:        2020-08-31
 * 详细:                        定时器支持
 *************************************************************************************************************/
 #include "nuc970_system.h"
 #include "timer.h"
 #include "typedef.h"
 #include "irq_aic.h"
 
 
 static void TIM0_IRQHandler(void);        //定时器0中断服务程序
 static void TIM1_IRQHandler(void);        //定时器1中断服务程序
 static void TIM2_IRQHandler(void);        //定时器2中断服务程序
 static void TIM3_IRQHandler(void);        //定时器3中断服务程序
 static void TIM4_IRQHandler(void);        //定时器4中断服务程序
 
 static const u32 scg_TIMx_BASE[TIMER_ChMax] = {TIMER0_BASE, TIMER1_BASE, TIMER2_BASE, TIMER3_BASE, TIMER4_BASE};                                        //定时器基址
 static const SYS_DEV_CLOCK scg_TIMx_Clock[TIMER_ChMax] = {DEV_TIMER0, DEV_TIMER1, DEV_TIMER2, DEV_TIMER3, DEV_TIMER4};                                //定时器时钟使能
 static const AIC_IRQ_Typedef scg_TIMx_IntIRQ[TIMER_ChMax] = {AIC_TMR0_INT, AIC_TMR1_INT, AIC_TMR2_INT, AIC_TMR3_INT, AIC_TMR4_INT};        //定时器中断号
 static const void* sg_TIMx_IRQHandler[TIMER_ChMax] = {TIM0_IRQHandler, TIM1_IRQHandler, TIM2_IRQHandler, TIM3_IRQHandler, TIM4_IRQHandler};//定时器中断服务程序地址
 static void * sg_TIMx_CallBack[TIMER_ChMax] = {NULL, NULL, NULL, NULL, NULL};                                                                                                                //定时器中断用户回调函数
 
 
 /*************************************************************************************************************************
 *函数                :        void TIMERx_Start(TIMER_CH_Type ch)
 *功能                :        定时器开始计数
 *参数                :        ch:定时器通道号
 *返回                :        无
 *依赖                        :         底层宏定义
 *作者               :        cp1300@139.com
 *时间                     :        2020-08-31
 *最后修改时间        :        2020-08-31
 *说明                :        请提前配置好串口
 *************************************************************************************************************************/
 void TIMERx_Start(TIMER_CH_Type ch)
 {
 TIM_TypeDef *TIMx;
 
 if(ch > (TIMER_ChMax-1)) return;                        //定时器通道超出范围
 TIMx = (TIM_TypeDef *)scg_TIMx_BASE[ch];        //获取定时器寄存器
 
 TIMx->CSP |= BIT30;                                                        //使能定时器
 }
 
 
 
 
 |