From e9f1bdf2dac4dbeeed479e8256dd0449ba39a38c Mon Sep 17 00:00:00 2001 From: zhangjun <2281979437@qq.com> Date: Mon, 31 Jul 2017 11:12:28 +0800 Subject: new file: ../../libcpu/risc-v/e310/trap.c add file that forget to submit before auto change timer mtimercmp register on the base of RT_TICK_PER_SECOND in rtconfig.h no flashing led new file: ../../src/idle.c recover old file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libcpu/risc-v/e310/trap.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 libcpu/risc-v/e310/trap.c (limited to 'libcpu') diff --git a/libcpu/risc-v/e310/trap.c b/libcpu/risc-v/e310/trap.c new file mode 100644 index 0000000000..7429e1a5f3 --- /dev/null +++ b/libcpu/risc-v/e310/trap.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include "interrupt.h" +extern struct rt_irq_desc irq_desc[]; +extern rt_uint32_t rt_hw_interrupt_get_active(rt_uint32_t fiq_irq); +void rt_hw_trap_irq() +{ + rt_isr_handler_t isr_func; + rt_uint32_t irq; + void *param; + + /* get irq number */ + irq = rt_hw_interrupt_get_active(0); + + /* get interrupt service routine */ + isr_func = irq_desc[irq].handler; + param = irq_desc[irq].param; + + /* turn to interrupt service routine */ + isr_func(irq, param); + rt_hw_interrupt_ack(0, irq); + +#ifdef RT_USING_INTERRUPT_INFO + irq_desc[irq].counter ++; +#endif +} +void handle_m_ext_interrupt() +{ +} +void rt_systick_handler(void) +{ + clear_csr(mie, MIP_MTIP); + + // Reset the timer for 3s in the future. + // This also clears the existing timer interrupt. + + volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME); + volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP); + uint64_t now = *mtime; + uint64_t then = now + 2 * RTC_FREQ/RT_TICK_PER_SECOND; + *mtimecmp = then; + rt_tick_increase(); + + // read the current value of the LEDS and invert them. +/* + GPIO_REG(GPIO_OUTPUT_VAL) ^= ((0x1 << RED_LED_OFFSET) | + (0x1 << GREEN_LED_OFFSET) | + (0x1 << BLUE_LED_OFFSET)); + */ + + // Re-enable the timer interrupt. + set_csr(mie, MIP_MTIP); +} -- cgit v1.3.1