From 75f8523f3a70558788186f8f2d7ca5a6f9f71194 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 18 Nov 2020 22:46:11 -0700 Subject: Change dma.h over to a regset() strategy. Apparently people really don't like bitfields in practice, so I have devised a compromise to retain some readability while using bitmasks instead by writing a regset() macro. --- 02-usart/include/common.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to '02-usart/include/common.h') diff --git a/02-usart/include/common.h b/02-usart/include/common.h index f9cbe06..394dc62 100644 --- a/02-usart/include/common.h +++ b/02-usart/include/common.h @@ -17,6 +17,8 @@ #define __IO volatile #endif +#define CTZ(n) __builtin_ctz(n) + #define bool int #ifndef __cplusplus #define true 1 @@ -39,4 +41,7 @@ typedef __IO uint32_t bits_t; +#define regset(reg, mask, val) \ + (reg = (reg & ~mask) | (val << CTZ(mask))) + #endif /* COMMON_H */ -- cgit