From 2545ae2d57e5b70975e3fd3b3e570da13dbf62f0 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 23 Jan 2018 23:24:53 -0700 Subject: start refactor process. Change rcc->c_r to bitfield. --- 03-refactor/include/common.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 03-refactor/include/common.h (limited to '03-refactor/include/common.h') diff --git a/03-refactor/include/common.h b/03-refactor/include/common.h new file mode 100644 index 0000000..9d5c7cd --- /dev/null +++ b/03-refactor/include/common.h @@ -0,0 +1,30 @@ +#ifndef COMMON__H +#define COMMON__H + +#include + +/* Define __IO to be volatile if it's not already. */ +#ifndef __IO +#define __IO volatile +#endif + +#define bool int +#ifndef __cplusplus +#define true 1 +#define false 0 +#endif + +#define PACKED __attribute__((packed)) +#define BIT(n) (1 << (n)) + +#define RESERVED_CONCAT_IMPL(x, y) x ## y +#define RESERVED_MACRO_CONCAT(x, y) RESERVED_CONCAT_IMPL(x, y) +#define RESERVED(n) \ + bits_t RESERVED_MACRO_CONCAT(_r, __COUNTER__) :n + +#define RESERVE(type) \ + __IO type RESERVED_MACRO_CONCAT(_r, __COUNTER__) + +typedef uint32_t bits_t; + +#endif /* COMMON_H */ -- cgit