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_input(uint32_t port, uint16_t pin)
Setup one or more pins of the given GPIO port as inputs.
void gpio_set(uint32_t port, uint16_t pin)
Set a gpio output to high level.
@ GPIO_OUTPUT_LOW
Pin configured for output with low level.
@ GPIO_OUTPUT_HIGH
Pin configured for output with high level.
@ GPIO_INPUT
Pin configured for input.
void gpio_clear(uint32_t port, uint16_t pin)
Clear a gpio output to low level.
void gpio_setup_output(uint32_t port, uint16_t pin)
Setup one or more pins of the given GPIO port as outputs.
uint16_t gpio_get(uint32_t port, uint16_t pin)
Read a gpio value.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.