1 /* 2 * Copyright (c) 2021, Shenzhen Academy of Aerospace Technology 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2021-11-16 Dystopia the first version 9 */ 10 11 #include "drv_timer.h" 12 #include "interrupt.h" 13 #include "common.h" 14 15 #include <rthw.h> 16 #include <rtthread.h> 17 18 /** 19 * This is the timer interrupt service routine. 20 * 21 */ rt_hw_systick_isr(void)22void rt_hw_systick_isr(void) 23 { 24 /* enter interrupt */ 25 rt_interrupt_enter(); 26 27 rt_tick_increase(); 28 29 /* leave interrupt */ 30 rt_interrupt_leave(); 31 } 32 33 /** 34 * The function initial system timer interrupt. 35 */ rt_hw_system_timer_init(void)36void rt_hw_system_timer_init(void) 37 { 38 // initial system timer interrupt, map local timer interrupt to INT14 39 gp_cgem_regs->INTMUX3 = (CSL_GEM_TINTLN << CSL_CGEM_INTMUX3_INTSEL14_SHIFT); 40 // enable CPU INT14 41 rt_hw_interrupt_umask(1 << 14); 42 43 return ; 44 } 45 46 /** 47 * The function initial system timer. 48 * Use local timer (== DNUM of a core) to generate a clock on TIMO0,interrupts are generated as well 49 * 50 */ rt_hw_system_timer_start(void)51void rt_hw_system_timer_start(void) 52 { 53 Timer64_Config tmrCfg; 54 55 // select output on TIMO0 from local timer. 56 gp_bootcfg_regs->TOUTSEL = (DNUM*2) << CSL_BOOTCFG_TOUTSEL_TOUTSEL0_SHIFT; 57 58 // configure the timer to generate clocks and interrupts 59 tmrCfg.timer_num = DNUM; 60 tmrCfg.timerMode = TIMER_PERIODIC_CLOCK; 61 tmrCfg.period = (unsigned long long) RT_TICK_PER_SECOND * DSP_CORE_SPEED_HZ / 6000; 62 tmrCfg.reload_period = 0; 63 64 // initial timer 65 timer64_init(&tmrCfg); 66 } 67