i broke it
This commit is contained in:
@@ -1,32 +1,22 @@
|
||||
#include "systick.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ch32v003fun.h"
|
||||
#include "debug.h"
|
||||
|
||||
// ms counter
|
||||
volatile uint32_t systick_millis = 0;
|
||||
|
||||
void systick_init(void) {
|
||||
// Reset any pre-existing configuration
|
||||
SysTick->CTLR = 0x0000;
|
||||
|
||||
// Set the compare register to trigger once per millisecond
|
||||
void init_systick(void) {
|
||||
SysTick->CTLR = 0;
|
||||
SysTick->CMP = SYSTICK_ONE_MILLISECOND - 1;
|
||||
|
||||
// Reset the Count Register and variables
|
||||
SysTick->CNT = 0x00000000;
|
||||
systick_millis = 0x00000000;
|
||||
|
||||
// Set the SysTick Configuration
|
||||
// NOTE: By not setting SYSTICK_CTLR_STRE, we maintain compatibility with
|
||||
// busywait delay funtions used by ch32v003_fun.
|
||||
SysTick->CTLR |= SYSTICK_CTLR_STE | // Enable Counter
|
||||
SYSTICK_CTLR_STIE | // Enable Interrupts
|
||||
SYSTICK_CTLR_STCLK; // Set Clock Source to HCLK/1
|
||||
SysTick->CNT = 0;
|
||||
systick_millis = 0;
|
||||
|
||||
// Enable the SysTick IRQ
|
||||
NVIC_SetPriority(SysTicK_IRQn, 0xf0);
|
||||
NVIC_EnableIRQ(SysTicK_IRQn);
|
||||
/* Enable SysTick counter, IRQ, HCLK/1 */
|
||||
SysTick->CTLR = SYSTICK_CTLR_STE | SYSTICK_CTLR_STIE | SYSTICK_CTLR_STCLK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -42,9 +32,7 @@ void SysTick_Handler(void) {
|
||||
// (Make sure the IQR is lightweight and CMP value is reasonable)
|
||||
SysTick->CMP += SYSTICK_ONE_MILLISECOND;
|
||||
|
||||
// Clear the trigger state for the next IRQ
|
||||
SysTick->SR = 0x00000000;
|
||||
|
||||
// Increment the milliseconds count
|
||||
// clear irq
|
||||
SysTick->SR = 0;
|
||||
systick_millis++;
|
||||
}
|
||||
Reference in New Issue
Block a user