Skip to content

peripherals.h

Jaslo edited this page Mar 20, 2019 · 2 revisions

peripherals.h

This is the core header of the library which can be used to map and unmap peripherlas directly with the struct peripheral.

Functions

  • uint32_t *peripheral_map(uint32_t addr, uint32_t size): This function takes a address and the size of the peripheral. On success it returns the pointer to the base of the mapped address. When an error accurs the function returns NULL.
  • void peripheral_unmap(void* map, uint32_t size): This functions also takes the returned pointer from map and the size and unmapps it.

Example

gpio_base_ptr = (volatile uint32_t *)peripheral_map(PERIPHERAL_BASE + GPIO_OFFSET, GPIO_SIZE);
return gpio_base_ptr;

peripheral_unmap((void *)gpio_base_ptr, GPIO_SIZE);

Sources and useful documentation

Clone this wiki locally