19#include <piduino/global.h>
78 volatile uint32_t *
io (
size_t offset = 0)
const {
80 return static_cast<volatile uint32_t *
> (
_map) + offset;
101 inline uint32_t
read (
size_t offset)
const {
110 inline void write (
size_t offset, uint32_t value) {
111 *
io (offset) = value;
123 volatile uint32_t *reg =
io (offset);
124 return __atomic_load_n (reg, __ATOMIC_SEQ_CST);
138 volatile uint32_t *reg =
io (offset);
139 __atomic_store_n (reg, value, __ATOMIC_SEQ_CST);
void close()
Close a memory mapping.
bool open(off_t base, size_t size)
Open a memory mapping on /dev/mem.
volatile uint32_t * operator[](size_t offset) const
Pointer to access registers.
volatile uint32_t * io(size_t offset=0) const
Pointer to access registers.
bool open(const char *device, size_t size, off_t base=0)
void atomicWrite(size_t offset, uint32_t value)
Atomic write to a register.
virtual ~IoMap()
Destructor.
uint32_t atomicRead(size_t offset) const
Atomic read of a register.
uint32_t read(size_t offset) const
Read a register.
bool isOpen() const
Indicates if a memory mapping is open.
void write(size_t offset, uint32_t value)
Write a value to a register.
off_t base() const
Base address of the mapped area.
static size_t pageSize()
Size of a mapping page.
bool openGpioMem(int gpio_bank, size_t size)
Open a GPIO memory mapping for RP1.
size_t size() const
Size of the mapped area.
Global namespace for Piduino.