#include <linux/gpio.h>
bool gpio_is_valid(int gpio_number);
功能:判断 gpio 引脚是否合法。
int gpio_request(unsigned gpio, const char* label);
功能:请求指定的 gpio 引脚。
其他请求函数:
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); – Request one GPIO.
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); – Request one GPIO.
int gpio_export(unsigned int gpio, bool direction_may_change);
int gpio_unexport(unsigned int gpio);
int gpio_direction_input(unsigned gpio)
int gpio_direction_output(unsiged gpio, int value)
gpio_set_value(unsigned int gpio, int value);
value: value to set to the GPIO. 0 - Low, 1 - High.
int gpio_get_value(unsigned gpio);
void gpio_free(unsigned int gpio);
void gpio_free_array(struct gpio *array, size_t num); – Release multiple GPIOs.
1. https://embetronicx.com/tutorials/linux/device-drivers/gpio-driver-basic-using-raspberry-pi/