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
0x20000000

This macro holds the value of the peripheral base, when a BCM2835 is used.

PERIPHERAL_BASE_BCM2836_7
0x3F000000

This macro holds the value of the peripheral base, when a BCM2836 or BCM2837 is used.

Functions

int peripheral_map(volatile uint32_t **map, uint32_t offset, uint32_t size)

This function maps a code memory block of size size at offset offset 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 0 on success and -1 on error.

void peripheral_unmap(void* map, uint32_t size)

This function unmaps the memory mapped to pointer map with size size.

int peripheral_ismapped(void *map, uint32_t size)

This function checks if a pointer map is already mapped to a memory region with the size size. It returns true if the pointer is already mapped and false if not.