20 void (*systick_handler)(void);
26 nvic_set_priority(NVIC_SYSTICK_IRQ,16);
39 systick_counter_disable();
44 systick_set_clocksource(STK_CSR_CLKSOURCE_AHB);
45 systick_set_reload((uint32_t)(timeout * (
float)((
float)(
CLOCK_getSpeed())/1000000.0f)));
50 systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
51 reload = (uint32_t)(timeout * (
float)((float)(
CLOCK_getSpeed()>>3)/1000000.0f));
54 if(reload > 0xFFFFFF){
56 systick_set_reload(0xFFFFFF);
68 systick_set_reload(reload);
73 systick_counter_enable();
81 systick_interrupt_disable();
84 systick_handler = handler;
87 systick_interrupt_enable();
93 return systick_get_value();
96 void sys_tick_handler(
void){
104 systick_counter_enable();
110 systick_counter_disable();
void SYSTICK_start(void)
Start the systick counter.
void MCU_printError(mcu_error errorNum)
Print a given error number as a character stream.
uint8_t MCU_debugIsEnabled(void)
Checks if debug is enabled.
void SYSTICK_handler(void(*handler)(void))
Sets the handler called on interrupt event.
mcu_error SYSTICK_timeout(uint32_t timeout)
Change the systick timeout value.
void SYSTICK_stop(void)
Stop the systick counter.
uint32_t CLOCK_getSpeed(void)
Get the current clock speed of the device.
uint32_t SYSTICK_count(void)
Get the current clock value.
Header file for stm32f103cb SYSTICK.
Error systick: Timeout value is too short.
mcu_error SYSTICK_setup(uint32_t timeout, void(*handler)(void))
Sets up systick and handler.
mcu_error
Error enumerators for the Debug peripheral.