From 6d4ad089c5b758ad8af4f68bf385a26ec4e9653a Mon Sep 17 00:00:00 2001 From: Thomas Albers Raviola Date: Thu, 21 Nov 2024 15:55:03 +0100 Subject: Initial commit --- include/zeta.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 include/zeta.h (limited to 'include/zeta.h') 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 +#include + +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 -- cgit v1.2.3