aboutsummaryrefslogtreecommitdiff
path: root/robot/bin.h
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-17 21:21:00 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-17 21:21:00 +0200
commit365dcc18fbd98645585cdbe009f537ecdaa90c1a (patch)
tree078c14da20867e177d658ae4cc517b81ab9ad1aa /robot/bin.h
parentf00fca5f6f9751b16d868f52bda908c7b4704457 (diff)
WIP sercomm implementation
- moved some module-specific constants to their respective header files - changed .clang-tidy to ignore global private global constants (starting with `_`) - suppressed some GCC warnings in bin.c and all pololu library warnings - added function signatures for sercomm protocol data generators - added endianness check in setup.c
Diffstat (limited to 'robot/bin.h')
-rw-r--r--robot/bin.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/robot/bin.h b/robot/bin.h
new file mode 100644
index 0000000..1f21f64
--- /dev/null
+++ b/robot/bin.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <stdint.h>
+
+typedef struct {
+ uint16_t bytes;
+ uint8_t data[];
+} w2_s_bin;
+
+extern uint8_t g_w2_endianness;
+
+
+/**
+ * helper file for binary data
+ *
+ * - fix endianness with functions inspired by UNIX arpa/inet.h
+ */
+
+/** convert 32-bit value from host endian to network (big-endian) */
+uint32_t w2_bin_hton32(uint32_t h32);
+/** convert 16-bit value from host endian to network (big-endian) */
+uint16_t w2_bin_hton16(uint16_t h16);
+/** convert 32-bit value from network (big-endian) to host endian */
+uint32_t w2_bin_ntoh32(uint32_t n32);
+/** convert 16-bit value from network (big-endian) to host endian */
+uint16_t w2_bin_ntoh16(uint16_t n16);
+