int 节点、pin0Val、ret; 节点= FDT_NODE_OFFSET_BY_compatible (gd->FDT_BLOB、0、"GPIO-test"); RET = GPIO_REQUEST_BY_NAME_NODEV (OFFSET_TO_ofnode)、"pintest-GPIO"、0、PIN_GPIO、GPIOD_is_OUT); IF (dm_gpio_is_valid (&pin_gpio)) { pin0Val = dm_gpio_get_value (&p...
};intof_get_named_gpio_flags(structdevice_node*np,constchar*propname,intindex,enumof_gpio_flags*flags);intgpio_is_valid(intgpio);intgpio_request(unsignedgpio,constchar*label);voidgpio_free(unsignedgpio);intgpio_direction_input(intgpio);intgpio_direction_output(intgpio,intv);...
下面是常用的 GPIO API 定义: #include<linux/gpio.h>#include<linux/of_gpio.h>enumof_gpio_flags{OF_GPIO_ACTIVE_LOW=0x1,};intof_get_named_gpio_flags(structdevice_node*np,constchar*propname,intindex,enumof_gpio_flags*flags);intgpio_is_valid(intgpio);intgpio_request(unsignedgpio,constchar*...
int gpio_request(unsigned gpio, const char *label) gpio:要申请的 gpio 标号,使用 of_get_named_gpio 函数从设备树获取指定 GPIO 属性信息,此函数会返回这个 GPIO 的标号。 label:给 gpio 设置个名字。 2.2.2 gpio_free 对申请的gpio进行释放 void gpio_free(unsigned gpio) 2.2.3 gpio_direction_input...
2.2.1 gpio_request/free gpio_request 用于申请一个GPIO管脚 代码语言:javascript 复制 /** * gpio: 要申请的gpio标号(使用of_get_named_gpio函数从设备树获取指定GPIO属性信息时返回的标号) * label: 给gpio设置个名字 * return: 0-申请成功 其他值-申请失败 ...
static int pctrltest_request_all_resource(void) { struct device *dev; struct device_node *node; struct pinctrl *pinctrl; struct sunxi_gpio_config *gpio_list = NULL; struct sunxi_gpio_config *gpio_cfg; unsigned gpio_count = 0; unsigned gpio_index; unsigned long config; int ret; dev = ...
• dev_name: 指向 pinctrl 设备。 • name: 指向 pin 名称。 • config:pin 的配置信息。 • 返回: • 成功,返回 0。 • 失败,返回错误码。 !警告 该接口在linux-5.4已经移除。 4.2 gpio 接口说明 4.2.1 gpio_request • 函数原型:int gpio_request(unsigned gpio, const char *label) ...
1、gpio_request函数 gpio_request函数用于申请一个GPIO管脚,在使用一个GPIO之前一定要使用gpio_request进行申请,函数原型如下: int gpio_request(unsigned gpio, const char *label) 函数参数和返回值含义如下: gpio:要申请的gpio标号,使用of_get_named_gpio函数从设备树获取指定GPIO属性信息,此函数会返回这个GPIO的标...
struct GpioMethod { int32_t (*request)(struct GpioCntlr *cntlr, uint16_t local); // 【预留】 int32_t (*release)(struct GpioCntlr *cntlr, uint16_t local); // 【预留】 int32_t (*write)(struct GpioCntlr *cntlr, uint16_t local, uint16_t val); int32_t (*read)(struct GpioCnt...
int (*request)(struct gpio_chip *gc, unsigned int offset); // 释放GPIO,gpio_free调用该函数 void (*free)(struct gpio_chip *gc, unsigned int offset); // 获取GPIO方向,gpiod_get_direction调用该函数 int (*get_direction)(struct gpio_chip *gc, unsigned int offset); ...