aboutsummaryrefslogtreecommitdiff
path: root/include/zeta.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/zeta.h')
-rw-r--r--include/zeta.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/include/zeta.h b/include/zeta.h
new file mode 100644
index 0000000..291a2ff
--- /dev/null
+++ b/include/zeta.h
@@ -0,0 +1,67 @@
+#ifndef ZETA_H
+#define ZETA_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef int8_t s8;
+typedef int16_t s16;
+typedef int32_t s32;
+typedef int64_t s64;
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+
+#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
+
+// Corrent version, but the compiler does not recognize this as a constant
+// expression
+// #define ISR_ADDRESS(x) (((u16)&x) & 0xFF)
+#define ISR_ADDRESS(x) ((u16)&x)
+
+extern void *rx_isr_ptr;
+extern void *ctc0_isr_ptr;
+extern void *ctc1_isr_ptr;
+extern void *ctc2_isr_ptr;
+extern void *ctc3_isr_ptr;
+extern void *port_a_isr_ptr;
+extern void *port_b_isr_ptr;
+
+void
+bootloader(void);
+
+uint16_t
+crc16(const void *buf, size_t len);
+
+void
+_menu(void);
+
+static inline int
+max(int a, int b)
+{
+ return a > b ? a : b;
+}
+
+static inline int
+min(int a, int b)
+{
+ return a < b ? a : b;
+}
+
+static inline int
+clamp(int v, int low, int high)
+{
+ return min(max(v, low), high);
+}
+
+static inline uint8_t
+bcd(uint8_t x)
+{
+ return ((x / 10) << 4) | (x % 10);
+}
+
+#endif // ZETA_H