generated from Embedded_Projects/CH32V307_Template
38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
|
|
#include "ch32v30x.h"
|
|
#include "system_ch32v30x.h"
|
|
|
|
void SysTick_Handler(void) __attribute__((interrupt()));
|
|
void Ecall_M_Mode_Handler(void) __attribute__((interrupt()));
|
|
|
|
extern void freertos_risc_v_mtimer_interrupt_handler(void);
|
|
|
|
/**
|
|
* Notes on FreeRTOS:
|
|
* Current FreeRTOS supports both vectored and Non-Vectored exception model,
|
|
* handled in portASM.h. WCH, however, has an unique exception model which
|
|
* vectors both exceptions and interrupts to a fixed vector table, making trap handler
|
|
* useless while handling ECALL exceptions, since they have their own entry point in IVT.
|
|
*/
|
|
|
|
/**
|
|
* @brief Initialize SysTick interrupt.
|
|
*
|
|
*/
|
|
void vPortSetupTimerInterrupt(void) {
|
|
/* Configure SysTick and interrupts. */
|
|
SysTick->SR = 0UL;
|
|
SysTick->CTLR = 0UL;
|
|
SysTick->CNT = 0UL;
|
|
|
|
NVIC_EnableIRQ(SysTicK_IRQn);
|
|
|
|
SysTick->CMP = (uint64_t)((SystemCoreClock / configTICK_RATE_HZ) - 1);
|
|
SysTick->CTLR = 0x1E; /* COUNTDOWN | AUTO RELOAD | HCLK | INT */
|
|
SysTick->CTLR |= 0x20; /* INIT */
|
|
|
|
SysTick->CTLR |= 0x01; /* EN */
|
|
}
|