-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.h
43 lines (30 loc) · 950 Bytes
/
utils.h
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
/* (C) András Wiesner, 2020 */
#ifndef SRC_UTILS_H_
#define SRC_UTILS_H_
#include <stdbool.h>
#include "driverlib/sysctl.h"
#include "utils/uartstdio.h"
#define EnableWaitPeripheral(x) { if(!SysCtlPeripheralReady(x)) { SysCtlPeripheralEnable(x); \
while (!SysCtlPeripheralReady(x)) {}; }}
#ifndef htonl
#define htonl(a) \
((((a) >> 24) & 0x000000ff) | \
(((a) >> 8) & 0x0000ff00) | \
(((a) << 8) & 0x00ff0000) | \
(((a) << 24) & 0xff000000))
#endif
#ifndef ntohl
#define ntohl(a) htonl((a))
#endif
#ifndef htons
#define htons(a) \
((((a) >> 8) & 0x00ff) | \
(((a) << 8) & 0xff00))
#endif
#ifndef ntohs
#define ntohs(a) htons((a))
#endif
#define MSG(...) UARTprintf(__VA_ARGS__)
#define CLILOG(en, ...) { if (en) UARTprintf(__VA_ARGS__); }
#define LIMIT(x,l) (x < -l ? -l : (x > l ? l : x))
#endif /* SRC_UTILS_H_ */