start firmware: Function definitions for ADC
This commit is contained in:
40
stm-firmware/systick.c
Normal file
40
stm-firmware/systick.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <systick.h>
|
||||
#include <stm32f4xx.h>
|
||||
#include <core_cm4.h>
|
||||
|
||||
volatile uint32_t wait_tick_ms;
|
||||
volatile uint64_t global_tick_ms;
|
||||
|
||||
void systick_setup(void)
|
||||
{
|
||||
/* Setup Systick for 1ms tick @ 168 MHz Clock Speed */
|
||||
SysTick_Config(SYSTICK_RELOAD);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Wait for x milliseconds
|
||||
*
|
||||
* This function is not reentrant and must not be called from an interrupt
|
||||
*
|
||||
* @warning Do not use in interrupt context
|
||||
* @param ms wait time in ms
|
||||
*/
|
||||
void systick_wait_ms(uint32_t ms)
|
||||
{
|
||||
wait_tick_ms = 0UL;
|
||||
while (wait_tick_ms < ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Interrupt Handler for SysTick
|
||||
*
|
||||
* This handler is called every millisecond
|
||||
*
|
||||
* @warning For calling cyclic functions use separate timers/flags and don't spoil this function
|
||||
*/
|
||||
void SysTick_Handler()
|
||||
{
|
||||
/* Increase tick counters */
|
||||
wait_tick_ms++;
|
||||
global_tick_ms++;
|
||||
}
|
Reference in New Issue
Block a user