2022-05-01 13:45:10 +00:00
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#include "task.h"
|
|
|
|
|
|
|
|
#include "ch32v30x.h"
|
|
|
|
#include "system_ch32v30x.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialize SysTick interrupt.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void vPortSetupTimerInterrupt(void) {
|
|
|
|
/* Configure SysTick and interrupts. */
|
|
|
|
SysTick->SR = 0UL;
|
|
|
|
SysTick->CTLR = 0UL;
|
|
|
|
SysTick->CNT = 0UL;
|
|
|
|
|
|
|
|
NVIC_EnableIRQ(SysTicK_IRQn);
|
|
|
|
|
2022-05-02 14:13:35 +00:00
|
|
|
SysTick->CMP = (uint64_t)((SystemCoreClock / (configTICK_RATE_HZ * 8)) - 1);
|
|
|
|
SysTick->CTLR = 0x1A; /* COUNTDOWN | AUTO RELOAD | HCLK/8 | INT */
|
2022-05-01 13:45:10 +00:00
|
|
|
SysTick->CTLR |= 0x20; /* INIT */
|
|
|
|
|
|
|
|
SysTick->CTLR |= 0x01; /* EN */
|
|
|
|
}
|