From 8e1c0941b0664b102ec18a60ac61719aa9d7f9bc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 10 Jun 2016 21:04:27 -0400 Subject: [PATCH] generic: Add new file generic/io.h and move read/writeb() to it Move the definitions of the readb() style functions to a new header generic/io.h. This eliminates the dependency of stdint.h on compiler.h. Signed-off-by: Kevin O'Connor --- src/avr/serial.c | 1 + src/compiler.h | 19 ------------------- src/generic/io.h | 25 +++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 src/generic/io.h diff --git a/src/avr/serial.c b/src/avr/serial.c index fc71cf0e..33b42fc6 100644 --- a/src/avr/serial.c +++ b/src/avr/serial.c @@ -7,6 +7,7 @@ #include // USART0_RX_vect #include // memmove #include "autoconf.h" // CONFIG_SERIAL_BAUD +#include "board/io.h" // readb #include "board/misc.h" // console_get_input #include "sched.h" // DECL_INIT #include "irq.h" // irq_save diff --git a/src/compiler.h b/src/compiler.h index 7085f864..e414d093 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -39,23 +39,4 @@ (((x) + ((__divisor) / 2)) / (__divisor)); \ }) -static inline void writel(void *addr, uint32_t val) { - *(volatile uint32_t *)addr = val; -} -static inline void writew(void *addr, uint16_t val) { - *(volatile uint16_t *)addr = val; -} -static inline void writeb(void *addr, uint8_t val) { - *(volatile uint8_t *)addr = val; -} -static inline uint32_t readl(const void *addr) { - return *(volatile const uint32_t *)addr; -} -static inline uint16_t readw(const void *addr) { - return *(volatile const uint16_t *)addr; -} -static inline uint8_t readb(const void *addr) { - return *(volatile const uint8_t *)addr; -} - #endif // compiler.h diff --git a/src/generic/io.h b/src/generic/io.h new file mode 100644 index 00000000..2a16cf20 --- /dev/null +++ b/src/generic/io.h @@ -0,0 +1,25 @@ +#ifndef __GENERIC_IO_H +#define __GENERIC_IO_H + +#include // uint32_t + +static inline void writel(void *addr, uint32_t val) { + *(volatile uint32_t *)addr = val; +} +static inline void writew(void *addr, uint16_t val) { + *(volatile uint16_t *)addr = val; +} +static inline void writeb(void *addr, uint8_t val) { + *(volatile uint8_t *)addr = val; +} +static inline uint32_t readl(const void *addr) { + return *(volatile const uint32_t *)addr; +} +static inline uint16_t readw(const void *addr) { + return *(volatile const uint16_t *)addr; +} +static inline uint8_t readb(const void *addr) { + return *(volatile const uint8_t *)addr; +} + +#endif // io.h