From 8cc05c79cea62609d02231492c054a0cca2b2289 Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 25 Sep 2023 23:57:36 +0200 Subject: Center firmware WIP --- center_fw/include/global.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 center_fw/include/global.h (limited to 'center_fw/include/global.h') diff --git a/center_fw/include/global.h b/center_fw/include/global.h new file mode 100644 index 0000000..f01b849 --- /dev/null +++ b/center_fw/include/global.h @@ -0,0 +1,66 @@ + +#ifndef __GLOBAL_H__ +#define __GLOBAL_H__ + +#include +#include +#include +#include +#include + +/* The IRQ header must be included before stm32_device.h since ST defines a bunch of messy macros there. */ +#include /* Header generated from stm32***_startup.s in Makefile */ + +#include +#include + +#define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) + +#define AFRL(pin, val) ((val) << ((pin)*4)) +#define AFRH(pin, val) ((val) << (((pin)-8)*4)) +#define AF(pin) (2<<(2*(pin))) +#define OUT(pin) (1<<(2*(pin))) +#define IN(pin) (0) +#define ANALOG(pin) (3<<(2*(pin))) +#define CLEAR(pin) (~(3<<(2*(pin)))) +#define PULLUP(pin) (1<<(2*pin)) +#define PULLDOWN(pin) (2<<(2*pin)) +#define BSRR_CLEAR(pin) ((1<