-
Notifications
You must be signed in to change notification settings - Fork 1
gpio.h
This header grants easy access to the Pis GPIOs.
-
uint32_t *gpio_map(void)
: This function maps the peripheral. On success it return a pointer to the mapped memory. When an error accursNULL
is returned. -
void gpio_unmap(void)
: Unmaps the peripheral again. -
void gpio_func(uint32_t pin, pin_functions function)
: With functions makes the GPIO an input, output or one of the alternate functions.pin
specifies the bcm2835 pin andfunction
the function the pin should have. -
extern void gpio_set(uint32_t pin)
: Sets the GPIOpin
. -
extern void gpio_clr(uint32_t pin)
: Clears the GPIOpin
. -
extern bool gpio_tst(uint32_t pin)
: Returns the voltage level of the GPIOpin
. -
void gpio_pud(uint32_t pin, pud val)
: This function activates or disables an pullup or -down on GPIOpin
. -
void gpio_inp(uint32_t pin)
: Makes the GPIOpin
an input. -
void gpio_out(uint32_t pin)
: Makes the GPIOpin
an output. -
void gpio_ca_pud(void)
: Clears all pullup and -downs. Because pullup and -downs are not cleared after a reset this function is called insidegpio_map()
andgpio_unmap
.
Every register is specified by a macro in the header and directly accessible (example: GPFSEL0
). To make life easier there is a pointer to the base register for every number of registers that do the same thing for different pins (example: GPFSEL0
to GPFSEL5
and the pointer GPFSEL
to the base register).
- bcm2835_peripherals.h and bcm2835_peripherals.c are highly inspired by Pieter Jan's "Low Level Programming of the Raspberry Pi in C".
- BCM2835 ARM Peripherals Datasheet
- There are many errors in the BCM2835 ARM Peripherals Datasheet so the BCM2835 datasheet errata by elinux.org is very useful and important.
- Because the BCM2835 ARM Peripherals Datasheet for some reason does not feature the PWM and PCM clocks, there is this very useful datasheet snippet: BCM2835 Audio clocks