add time
This commit is contained in:
16
Core/Src/time.c
Normal file
16
Core/Src/time.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <stdint.h>
|
||||
#include "time.h"
|
||||
#include "main.h"
|
||||
|
||||
int32_t ticks_ms() {
|
||||
return HAL_GetTick() & INT32_MAX;
|
||||
}
|
||||
|
||||
int32_t ticks_add(int32_t t1, int32_t delta) {
|
||||
return (t1 + delta) & INT32_MAX;
|
||||
}
|
||||
|
||||
int32_t ticks_diff(int32_t t1, int32_t t2) {
|
||||
int32_t half = (INT32_MAX / 2) + 1;
|
||||
return ((t1 - t2 + half) & INT32_MAX) - half;
|
||||
}
|
Reference in New Issue
Block a user