// ============================================================================= // 函数功能:module_init_timer // SHARC21469的GP timer初始化 // 输入参数: // 输出参数: // 返回值 : // 说明 : // ============================================================================= void GPTimer_ModuleInit(void) { struct tagTimerChip Sharc21469GPtimer; Int_IsrConnect(cn_int_line_GPTMR0I,__GPTimer0_ISR); Int_SettoAsynSignal(cn_int_line_GPTMR0I); Int_ClearLine(cn_int_line_GPTMR0I); //清掉初始化产生的发送fifo空的中断 Int_RestoreAsynLine(cn_int_line_GPTMR0I); Int_IsrConnect(cn_int_line_GPTMR1I,__GPTimer1_ISR); Int_SettoAsynSignal(cn_int_line_GPTMR1I); Int_ClearLine(cn_int_line_GPTMR1I); //清掉初始化产生的发送fifo空的中断 Int_RestoreAsynLine(cn_int_line_GPTMR1I); *pTM0CTL = TIMODEPWM | PRDCNT | IRQEN; // configure the timer0 *pTM0W = 1; // timer0 width *pTM1CTL = TIMODEPWM | PRDCNT | IRQEN; // configure the timer1 *pTM1W = 1; // timer1 width register Sharc21469GPtimer.chipname = "SHARC21469GPTimer"; Sharc21469GPtimer.timerhardalloc = __GPTimer_Alloc; Sharc21469GPtimer.timerhardfree = __GPTimer_Free; Sharc21469GPtimer.timerhardctrl = __GPTimer_Ctrl; TimerHard_RegisterChip(&Sharc21469GPtimer); // =============下面代码仅做测试使用=================================== /* struct tagGPTimerHandle *testTimer; //step1:分配一个定时器 testTimer=__GPTimer_Alloc(30000000, __GPTimer0_ISR); //step2:设置定时周期 // __GPTimer_SetCycle(testTimer, 30000000); //step3:使能中断 __GPTimer_EnInt(testTimer); //开始计数 __GPTimer_StartCount(testTimer); */ }
// ============================================================================= // 函数功能:module_init_timer // P1020的PICtimer初始化 // 输入参数: // 输出参数: // 返回值 : // 说明 : // ============================================================================= void module_init_pictimer(void) { struct tagTimerChip p1020pictimer; u32 temp; //做基本的初始化 *((u32 *)cn_pic_timer_tcra) = cn_pic_timer_tcr_set; temp = *((u32 *)cn_pic_timer_tcra);//sync *((u32 *)cn_pic_timer_tcrb) = cn_pic_timer_tcr_set; temp = *((u32 *)cn_pic_timer_tcrb);//sync *((u32 *)cn_pic_timer_tfrra) = cfg_core_tb_clk; //same as the tb temp = *((u32 *)cn_pic_timer_tfrra); *((u32 *)cn_pic_timer_tfrrb) = cfg_core_tb_clk; //same as the tb temp = *((u32 *)cn_pic_timer_tfrra); //all the timers are disabled,not count //initial the group a for(temp =0; temp < cn_pic_timer_gnumber; temp++) { *((u32 *)(cn_pic_timer_gtbcra_base + temp * cn_pic_timer_gt_step)) = cn_pic_timer_msk; } //all the timers are disabled,not count //initial the group b for(temp =0; temp < cn_pic_timer_gnumber; temp++) { *((u32 *)(cn_pic_timer_gtbcrb_base + temp * cn_pic_timer_gt_step)) = cn_pic_timer_msk; } p1020pictimer.chipname = "P1020PICTIMER"; p1020pictimer.timerhardalloc = __P1020PicTimer_Alloc; p1020pictimer.timerhardfree = __P1020PicTimer_Free; p1020pictimer.timerhardctrl = __P1020PicTimer_Ctrl; TimerHard_RegisterChip(&p1020pictimer); return ; }
// ============================================================================= // 函数功能:module_init_timer // P1020的PICtimer初始化,timer时钟源为APB2 = CN_CFG_PCLK1 = 36M(timer234567) // 输入参数: // 输出参数: // 返回值 : // 说明 : // ============================================================================= void ModuleInstall_HardTimer(void) { struct tagTimerChip STM32timer; u32 temp; pg_rcc_reg->APB1ENR |= (1<<4)|(1<<5);//时钟使能,timer6/7的使能位为比特4/5 //定时器TIM234567时钟源为低速外设时钟PCLK1,速度为36M for(temp = 0; temp < CN_STM32TIMER_NUM; temp++) { tg_TIMER_Reg[temp]->CR1 &= ~(TIM_CR1_CEN_MASK); //禁止TIMER tg_TIMER_Reg[temp]->CR1 |= TIM_CR1_ARPE_MASK; tg_TIMER_Reg[temp]->DIER |= TIM_DIER_UIE_MASK; tg_TIMER_Reg[temp]->PSC = 0x23;//配置为36,则一个时钟为1uS tg_TIMER_Reg[temp]->ARR = 0xFFFF; } STM32timer.chipname = "STM32TIMER"; STM32timer.timerhardalloc = __STM32Timer_Alloc; STM32timer.timerhardfree = __STM32Timer_Free; STM32timer.timerhardctrl = __STM32Timer_Ctrl; TimerHard_RegisterChip(&STM32timer); return ; }