如果配置为低电平有效则为GPIO_ACTIVE_LOW。然后在 probe 函数中对 DTS 所添加的资源进行解析,代码如下...
GPIOD_ACTIVE_LOW:指示GPIO的默认电平为低电平(激活低电平)。 GPIOD_OPEN_DRAIN:将GPIO配置为开漏输出模式。 GPIOD_OPEN_SOURCE:将GPIO配置为开源输出模式。 函数功能: 获取与给定设备和连接标识符(con_id)相关联的GPIO描述符。 返回值: 如果成功获取到 GPIO 描述符,则返回指向 struct gpio_desc 的指针;如果获...
可以看到gpio15文件夹下分别有active_low、device、direction、edge、power、subsystem、uevent、value八个文件,需要关心的文件是 active_low、direction、edge 以及 value 这四个属性文件,接下来分别介绍这四个属性文件的作用: direction:配置GPIO 引脚为输入或输出模式。该文件可读、可写,读表示查看 GPIO 当前是输入还是...
gpio_3= <&gpio89GPIO_ACTIVE_HIGH>; 二、GPIO的基操 2.1、下面是常用的 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...
GPIO_ACTIVE_HIGH表示高电平有效,如果想要低电平有效,可以改为:GPIO_ACTIVE_LOW,这个属性将被驱动所读取。 然后在probe函数中对DTS所添加的资源进行解析,代码如下: static int firefly_gpio_probe(struct platform_device *pdev) { int ret; int gpio; enum of_gpio_flags flag;...
GPIO_ACTIVE_LOW 表示低电平有效(灯亮),如果是高电平有效,需要替换为 GPIO_ACTIVE_HIGH 。 之后在驱动程序中加入对 GPIO 口的申请和控制则可: #ifdef CONFIG_OF #include <linux/of.h> #include <linux/of_gpio.h> #endif static int firefly_led_probe(struct platform_device *pdev) ...
GPIO_ACTIVE_LOW 表示低电平有效(灯亮),如果是高电平有效,需要替换为 GPIO_ACTIVE_HIGH 。之后在...
二、GPIO的基操 2.1、下面是常用的 GPIO API 定义: #include <linux/gpio.h> #include <linux/of_gpio.h> enum of_gpio_flags { OF_GPIO_ACTIVE_LOW = 0x1, }; int of_get_named_gpio_flags(struct device_node *np, const char *propname, ...
这里定义了两颗 LED 灯的 GPIO 设置: led-work GPIO8_A2 GPIO_ACTIVE_LOW led-power GPIO8_A1 GPIO_ACTIVE_LOW 1. 2. GPIO_ACTIVE_LOW 表示低电平有效(灯亮),如果是高电平有效,需要替换为 GPIO_ACTIVE_HIGH 。 之后在驱动程序中加入对 GPIO 口的申请和控制则可: ...
cs-gpios = <&gpio1 RK_PB2_GPIO_ACTIVE_LOW>; num-chipselects = <1>; pinctrl-names = "default"; pinctrl-0 = <&spi5_gpios>; status = "disabled"; }; 然后对pinctrl节点进行追加,追加内容如下所示: spi5_gpios: gpios { rockchip,pins = <0 RK_PB0 0 &pcfg_pull_none>, ...