diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2020-12-04 23:16:31 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2020-12-04 23:16:31 -0700 |
commit | 7002cb8380406173407c9e8c8d16ebd670fff55c (patch) | |
tree | b6ba377167ce193879347d692f087084f130c561 /include/kern/common.h | |
parent | 83deae717de8b940b0cb04d1d1989b0a4c250e35 (diff) | |
download | stm32l4-7002cb8380406173407c9e8c8d16ebd670fff55c.tar.gz stm32l4-7002cb8380406173407c9e8c8d16ebd670fff55c.tar.bz2 stm32l4-7002cb8380406173407c9e8c8d16ebd670fff55c.zip |
Added kernel-level abstraction over the spi interface.
Diffstat (limited to 'include/kern/common.h')
-rw-r--r-- | include/kern/common.h | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/include/kern/common.h b/include/kern/common.h index c5afe3f..021229b 100644 --- a/include/kern/common.h +++ b/include/kern/common.h @@ -1,9 +1,11 @@ #ifndef COMMON__H #define COMMON__H -#include <stdint.h> -#include <stddef.h> #include <assert.h> +#include <stddef.h> +#include <stdint.h> + +typedef enum { ENDIANNESS_LITTLE, ENDIANNESS_BIG } endianness_t; #define WEAK __attribute__((weak)) #define NORETURN __attribute__((noreturn)) @@ -28,23 +30,18 @@ #define PACKED __attribute__((packed)) #define BIT(n) (1 << (n)) -#define RESERVED_CONCAT_IMPL(x, y) x ## y +#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__) +#define RESERVED(n) bits_t RESERVED_MACRO_CONCAT(_r, __COUNTER__) : n + +#define RESERVE(type) __IO type RESERVED_MACRO_CONCAT(_r, __COUNTER__) -#define ptr2reg(ptr) \ - ((uint32_t) (ptrdiff_t) (ptr)) +#define ptr2reg(ptr) ((uint32_t)(ptrdiff_t)(ptr)) typedef __IO uint32_t bits_t; -#define regset(reg, mask, val) \ - ((reg) = ((reg) & ~mask) | (val << CTZ(mask))) +#define regset(reg, mask, val) ((reg) = ((reg) & ~mask) | (val << CTZ(mask))) -#define regget(reg, mask) \ - (((reg) & mask) >> (CTZ(mask))) +#define regget(reg, mask) (((reg)&mask) >> (CTZ(mask))) #endif /* COMMON_H */ |