4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-30 21:30:24 +08:00
2021-11-17 18:44:00 +08:00

66 lines
1.4 KiB
C

/*
* Copyright (c) 2021, Shenzhen Academy of Aerospace Technology
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-11-16 Dystopia the first version
*/
#include "drv_timer.h"
#include "KeyStone_common.h"
#include <rthw.h>
#include <rtthread.h>
/**
* This is the timer interrupt service routine.
*
*/
void rt_hw_systick_isr(void)
{
/* enter interrupt */
rt_interrupt_enter();
rt_tick_increase();
/* leave interrupt */
rt_interrupt_leave();
}
/**
* The function initial system timer interrupt.
*/
void rt_hw_system_timer_init(void)
{
// initial system timer interrupt, map local timer interrupt to INT14
gpCGEM_regs->INTMUX3 = (CSL_GEM_TINTLN<<CSL_CGEM_INTMUX3_INTSEL14_SHIFT);
// enable CPU INT14
CPU_interrupt_enable(1<<14);
return ;
}
/**
* The function initial system timer.
* Use local timer (==DNUM of a core) to generate a clock on TIMO0,interrupts are generated as well
*
*/
void rt_hw_system_timer_start(void)
{
Timer64_Config tmrCfg;
// select output on TIMO0 from local timer.
gpBootCfgRegs->TOUTSEL = (DNUM*2)<<CSL_BOOTCFG_TOUTSEL_TOUTSEL0_SHIFT;
// configure the timer to generate clocks and interrupts
tmrCfg.timer_num= DNUM;
tmrCfg.timerMode= TIMER_PERIODIC_CLOCK;
tmrCfg.period= (unsigned long long) RT_TICK_PER_SECOND*gDSP_Core_Speed_Hz/6000;
tmrCfg.reload_period= 0;
// initial timer
Timer64_Init(&tmrCfg);
}