27 #include <sys/ioctl.h>
31 #define GPIO_MAGIC 'p'
32 #define GPIO_DIRECTION _IOW(GPIO_MAGIC, 0, struct gpio_direction)
33 #define GPIO_READ _IOWR(GPIO_MAGIC, 1, struct gpio_data)
34 #define GPIO_WRITE _IOW(GPIO_MAGIC, 2, struct gpio_data)
56 if (port != 0x32524) {
return; }
60 gpiofp = open(
"/dev/gpio", O_RDWR);
72 if (port != 0x32524) {
return; }
76 gpiofp = open(
"/dev/gpio", O_RDWR);
88 if (port != 0x32524) {
return; }
92 gpiofp = open(
"/dev/gpio", O_RDWR);
122 if (port != 0x32524) {
return 0; }
126 gpiofp = open(
"/dev/gpio", O_RDWR);
Some architecture independent helper functions for GPIOs.
void gpio_setup_output(uint32_t port, uint16_t pin)
Setup one or more pins of the given GPIO port as outputs.
void gpio_setup_input(uint32_t port, uint16_t pin)
Setup one or more pins of the given GPIO port as inputs.
uint16_t gpio_get(uint32_t port, uint16_t pin)
Read a gpio value.
Pin configured for input.
Pin configured for output with low level.
void gpio_clear(uint32_t port, uint16_t pin)
Clear a gpio output to low level.
Pin configured for output with high level.
void gpio_set(uint32_t port, uint16_t pin)
Set a gpio output to high level.