summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kerkmann <[email protected]>2021-08-07 11:24:40 +0200
committerStefan Kerkmann <[email protected]>2021-08-07 11:33:36 +0200
commit60d03110f73830fd468a957e0f14467e9c900174 (patch)
tree1881bd91821cfe7d376aea6dbe7ebcda86410e92
parent1d2a57a9e17e0a2bd1f315a17a092363ef79bab2 (diff)
Correctly initialize and handle the system tick
Forgot to reload the systick timer in the irq handler
-rw-r--r--hw/bsp/gd32vf103_longan_nano/gd32vf103_longan_nano.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/hw/bsp/gd32vf103_longan_nano/gd32vf103_longan_nano.c b/hw/bsp/gd32vf103_longan_nano/gd32vf103_longan_nano.c
index d832503b1..99eb3d6b6 100644
--- a/hw/bsp/gd32vf103_longan_nano/gd32vf103_longan_nano.c
+++ b/hw/bsp/gd32vf103_longan_nano/gd32vf103_longan_nano.c
@@ -67,12 +67,7 @@ void board_init(void) {
SystemCoreClockUpdate();
#if CFG_TUSB_OS == OPT_OS_NONE
- SysTimer_SetLoadValue(0);
- SysTimer_SetCompareValue(SystemCoreClock / 1000);
- ECLIC_SetLevelIRQ(SysTimer_IRQn, 3);
- ECLIC_SetTrigIRQ(SysTimer_IRQn, ECLIC_POSTIVE_EDGE_TRIGGER);
- ECLIC_EnableIRQ(SysTimer_IRQn);
- SysTimer_Start();
+ SysTick_Config(TIMER_TICKS);
#endif
rcu_periph_clock_enable(RCU_GPIOA);
@@ -188,7 +183,10 @@ int board_uart_write(void const* buf, int len) {
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
-void eclic_mtip_handler(void) { system_ticks++; }
+void eclic_mtip_handler(void) {
+ system_ticks++;
+ SysTick_Reload(TIMER_TICKS);
+}
uint32_t board_millis(void) { return system_ticks; }
#endif
@@ -209,7 +207,3 @@ void assert_failed(char* file, uint32_t line) {
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
-
-// Required by __libc_init_array in startup code if we are compiling using
-// -nostdlib/-nostartfiles.
-// void _init(void) {}