-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathradar01_utils.c
47 lines (42 loc) · 988 Bytes
/
radar01_utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "radar01_utils.h"
void debug_hex_dump(char *str, uint8_t *pSrcBufVA, int SrcBufLen)
{
if (RADAR01_HEX_DEBUG_ENABLE == 0)
return;
uint8_t *pt;
int x;
pt = pSrcBufVA;
debug_print("%s: %p, len = %d\n", str, pSrcBufVA, SrcBufLen);
for (x = 0; x < SrcBufLen; x++) {
if (x % 16 == 0) {
debug_print("0x%04x : ", x);
}
debug_print("%02x ", ((uint8_t) pt[x]));
if (x % 16 == 15) {
debug_print("\n");
}
}
debug_print("\n");
}
static struct timespec g_timestamp;
void clock_get_hw_time(struct timespec *ts)
{
clock_gettime(CLOCK_MONOTONIC, ts);
}
double get_curr_time(void)
{
clock_get_hw_time(&g_timestamp);
return g_timestamp.tv_sec + (double) g_timestamp.tv_nsec / (double) BILLION;
}
void *radar01_alloc_mem(size_t size)
{
return calloc(1, size);
}
void radar01_free_mem(void **ptr)
{
if (*ptr) {
free(*ptr);
*ptr = NULL;
}
return;
}