mirror of https://github.com/Desuuuu/klipper.git
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 <kevin@koconnor.net>
This commit is contained in:
parent
62f96f0911
commit
8e1c0941b0
|
@ -7,6 +7,7 @@
|
||||||
#include <avr/interrupt.h> // USART0_RX_vect
|
#include <avr/interrupt.h> // USART0_RX_vect
|
||||||
#include <string.h> // memmove
|
#include <string.h> // memmove
|
||||||
#include "autoconf.h" // CONFIG_SERIAL_BAUD
|
#include "autoconf.h" // CONFIG_SERIAL_BAUD
|
||||||
|
#include "board/io.h" // readb
|
||||||
#include "board/misc.h" // console_get_input
|
#include "board/misc.h" // console_get_input
|
||||||
#include "sched.h" // DECL_INIT
|
#include "sched.h" // DECL_INIT
|
||||||
#include "irq.h" // irq_save
|
#include "irq.h" // irq_save
|
||||||
|
|
|
@ -39,23 +39,4 @@
|
||||||
(((x) + ((__divisor) / 2)) / (__divisor)); \
|
(((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
|
#endif // compiler.h
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef __GENERIC_IO_H
|
||||||
|
#define __GENERIC_IO_H
|
||||||
|
|
||||||
|
#include <stdint.h> // 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
|
Loading…
Reference in New Issue