mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
systick timer module
This commit is contained in:
parent
8968c08392
commit
c6f7ed40d1
@ -1,5 +1,5 @@
|
|||||||
BIN = "openmv"
|
BIN = "openmv"
|
||||||
OBJ = main.o ov9650.o sccb.o rgb_led.o usart.o imlib.o
|
OBJ = main.o ov9650.o sccb.o rgb_led.o usart.o imlib.o systick.o
|
||||||
LIB = -lc -lcm4
|
LIB = -lc -lcm4
|
||||||
FLAGS = -mcpu=cortex-m4 -mthumb -mcpu=cortex-m4 -mthumb -mthumb-interwork -mlittle-endian -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
FLAGS = -mcpu=cortex-m4 -mthumb -mcpu=cortex-m4 -mthumb -mthumb-interwork -mlittle-endian -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
AFLAGS = $(FLAGS)
|
AFLAGS = $(FLAGS)
|
||||||
|
29
src/systick.c
Normal file
29
src/systick.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <stm32f4xx.h>
|
||||||
|
#include "systick.h"
|
||||||
|
static volatile uint32_t sys_ticks;
|
||||||
|
|
||||||
|
void SysTick_Handler(void)
|
||||||
|
{
|
||||||
|
++sys_ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
int systick_init()
|
||||||
|
{
|
||||||
|
/* configure systick to interrupt every 1ms */
|
||||||
|
if (SysTick_Config(SystemCoreClock / 1000)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void systick_sleep(uint32_t ms)
|
||||||
|
{
|
||||||
|
uint32_t curr_ticks = sys_ticks;
|
||||||
|
while ((sys_ticks - curr_ticks) < ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t systick_current_millis()
|
||||||
|
{
|
||||||
|
return sys_ticks;
|
||||||
|
}
|
6
src/systick.h
Normal file
6
src/systick.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __SYSTICK_H__
|
||||||
|
#define __SYSTICK_H__
|
||||||
|
int systick_init();
|
||||||
|
void systick_sleep(uint32_t ms);
|
||||||
|
uint32_t systick_current_millis();
|
||||||
|
#endif /* __SYSTICK_H__ */
|
Loading…
Reference in New Issue
Block a user