T-Box Basic dev
Loading...
Searching...
No Matches
icc_config.h
Go to the documentation of this file.
1
10
11#ifndef ICC_CONFIG_H
12#define ICC_CONFIG_H
13
14#ifdef __cplusplus
15extern "C"
16{
17#endif
18
19#include <pthread.h>
20#include <stdbool.h>
21#include <stddef.h>
22#include <stdint.h>
23#include <time.h>
24
31#define ICC_SOF0 0xA5
32#define ICC_SOF1 0x5A
33#define ICC_DATA_FRAME_HEAD_SIZE 10
34#define ICC_ACK_FRAME_SIZE 6
35#define ICC_RX_FRAME_DATA_MAX (1024)
36#define ICC_TX_FRAME_DATA_MAX (1024 * 5)
37#define ICC_RX_FRAME_MAX (ICC_DATA_FRAME_HEAD_SIZE + ICC_RX_FRAME_DATA_MAX)
38#define ICC_TX_FRAME_MAX (ICC_DATA_FRAME_HEAD_SIZE + ICC_TX_FRAME_DATA_MAX)
40
47#define ICC_CRC8_DATA_THRESHOLD 256
49
58#define ICC_ACK_TABLE_DEPTH 5
59#define ICC_ACK_TIMEOUT_MS 1000
60#define ICC_RETRY_MAX 3
61#define ICC_ACK_DATA_MAX 512
63
70#define ICC_HEARTBEAT_INTERVAL_MS 3000
71#define ICC_HEARTBEAT_INTERVAL_FAST_MS 500
72#define ICC_HEARTBEAT_TIMEOUT_MS 60000
73#define ICC_HANDSHAKE_TIMEOUT_MS 600000
75
83#ifndef ICC_GET_TICK
84#define ICC_GET_TICK() \
85 ({ \
86 struct timespec ts; \
87 clock_gettime(CLOCK_MONOTONIC, &ts); \
88 ((uint64_t)ts.tv_sec * 1000ULL) + ((uint64_t)ts.tv_nsec / 1000000ULL); \
89 })
90#endif
92
100#ifndef ICC_PROTO_LOCK_T
101#define ICC_PROTO_LOCK_T pthread_mutex_t
102#endif
103
104#ifndef ICC_PROTO_LOCK_INIT
105#define ICC_PROTO_LOCK_INIT(mutex) \
106 do \
107 { \
108 if ((mutex) != NULL) \
109 { \
110 pthread_mutex_init((mutex), NULL); \
111 } \
112 } while (0)
113#endif
114
115#ifndef ICC_PROTO_LOCK_DESTROY
116#define ICC_PROTO_LOCK_DESTROY(mutex) \
117 do \
118 { \
119 if ((mutex) != NULL) \
120 { \
121 pthread_mutex_destroy((mutex)); \
122 } \
123 } while (0)
124#endif
125
126#ifndef ICC_PROTO_LOCK_ENTER
127#define ICC_PROTO_LOCK_ENTER(mutex) \
128 do \
129 { \
130 if ((mutex) != NULL) \
131 { \
132 pthread_mutex_lock((mutex)); \
133 } \
134 } while (0)
135#endif
136
137#ifndef ICC_PROTO_LOCK_EXIT
138#define ICC_PROTO_LOCK_EXIT(mutex) \
139 do \
140 { \
141 if ((mutex) != NULL) \
142 { \
143 pthread_mutex_unlock((mutex)); \
144 } \
145 } while (0)
146#endif
148
149#ifdef __cplusplus
150}
151#endif
152
153#endif
T-Box 时间工具接口