aboutsummaryrefslogtreecommitdiffstats
path: root/boards/base/RaspberryPi/FreeRTOS/mmio.h
blob: 1a7fb5c28754c06bddf73479f6061f3d9f47900e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* mmio.h - access to MMIO registers */
 
#ifndef MMIO_H
#define MMIO_H
 
#include <stdint.h>
 
// write to MMIO register
static GFXINLINE void mmio_write(uint32_t reg, uint32_t data) {
    uint32_t *ptr = (uint32_t*)reg;
    asm volatile("str %[data], [%[reg]]"
	     : : [reg]"r"(ptr), [data]"r"(data));
}
 
// read from MMIO register
static GFXINLINE uint32_t mmio_read(uint32_t reg) {
    uint32_t *ptr = (uint32_t*)reg;
    uint32_t data;
    asm volatile("ldr %[data], [%[reg]]"
		 : [data]"=r"(data) : [reg]"r"(ptr));
    return data;
}
 
#endif // #ifndef MMIO_H