Peripherals¶
The peripheral functions are something like the core of the library. They map and unmap the memory used by all other parts.
Macros¶
-
PERIPHERAL_BASE_BCM2835
¶ This macro holds the value of the peripheral base, when a BCM2835 is used. It has the value
0x20000000
-
PERIPHERAL_BASE_BCM2836_7
¶ This macro holds the value of the peripheral base, when a BCM2836 or BCM2837 is used. It has the value
0x3F000000
Functions¶
-
uint32_t *
peripheral_map
(uint32_t offset, uint32_t size)¶ This function maps a code memory block of size
size
at offsetoffset
from the peripheral base.
Note
The offset
must be a multiple of the page size which is 4096
on the Raspberry Pi.
The function returns a pointer
to the mapped memory on success and NULL
on error.
-
void
peripheral_unmap
(void* map, uint32_t size)¶ This function unmaps the memory mapped to pointer
map
with sizesize
.
-
int
peripheral_ismapped
(void *map, uint32_t size)¶ This function checks if a pointer
map
is already mapped to a memory region with the sizesize
. It returnstrue
if the pointer is already mapped andfalse
if not.