* 则为 gpiod_get_index(dev, con_id, 1, flags); */structgpio_desc *__must_checkgpiod_get(structdevice *dev,constchar*con_id,enumgpiod_flags flags){returngpiod_get_index(dev, con_id,0, flags); }structgpio_desc *__must_checkgpiod_get_index(structdevice *dev,constchar*con_id,un...
[1] 请求引脚 *//* 使用 gpiod_get() 或 devm_gpiod_get() 或 gpiod_get_index() 或 devm_gpiod_get_index() 等等函数 *//* [gpio][2] 设置方向 *//* 使用 gpiod_direction_input() 或 gpiod_direction_output() 等等函数 *//* [gpio][3] 导出到应用层 *//* 使用 gpiod_export() ...
struct gpio_desc *gpiod_get_index_optional(struct device *dev, const char *con_id, unsigned int index, enum gpiod_flags flags) 1. 2. 3. 4. 5. 6. 7. 8. 使用如下函数同时获取多个设备: AI检测代码解析 struct gpio_descs *gpiod_get_array(struct device *dev, const char *con_id, en...
相较于上面介绍的gpiod_get函数,下面的三个函数可能会多一个index参数和optional的函数后缀,其中index 表示GPIO的索引值,当设备树的GPIO属性值包含多个GPIO引脚描述时,使用index来表示每个GPIO引脚的唯一标识。而带optional() 后缀的函数与不带 optional 后缀的函数在功能上是相同的,都用于获取GPIO描述符,两者的区别在...
devm_gpiod_get_array devm_gpiod_get_array_op devm_gpiod_get_index devm_gpiod_get_index_op devm_gpiod_get_optional devm_gpiod_put devm_gpiod_put_array fwnode_get_named_gpiod gpio_to_desc gpiod_cansleep gpiod_count gpiod_direction_input ...
};staticintmy_pdrv_probe(struct platform_device *pdev){intretval;structdevice*dev= &pdev->dev;// 获得 gpio descriptor 的同时也将其设置为 output,并且输出低电平red = gpiod_get_index(dev,"led",0, GPIOD_OUT_LOW); green = gpiod_get_index(dev,"led",1, GPIOD_OUT_LOW); ...
gpiod_get gpiod_get_array gpiod_get_array_optiona gpiod_get_direction gpiod_get_index gpiod_get_index_optiona gpiod_get_optional gpiod_get_raw_value gpiod_get_raw_value_can gpiod_get_value gpiod_get_value_canslee gpiod_is_active_low gpiod_put gpiod_put_array gpiod_set_array_...
struct gpio_desc*red,*green,*blue,*power;red=gpiod_get_index(dev,"led",0,GPIOD_OUT_HIGH);green=gpiod_get_index(dev,"led",1,GPIOD_OUT_HIGH);blue=gpiod_get_index(dev,"led",2,GPIOD_OUT_HIGH);power=gpiod_get(dev,"power",GPIOD_OUT_HIGH); ...
1. 获取GPIO编号函数of_get_named_gpio GPIO子系统大多数API函数会用到GPIO编号。GPIO编号可以通过of_get_named_gpio函数从设备树中获取。 of_get_named_gpio函数(内核源码include/linux/of_gpio.h)¶ 1 staticinlineintof_get_named_gpio(structdevice_node*np,constchar*propname,intindex) ...
struct gpio_desc *gpiod_get(struct device *dev, const char *con_id,enum gpiod_flags flags) 如果一个功能是通过一起使用多个GPIO实现的(例如,显示数字的简单LED设备),可以指定一个额外的索引参数: struct gpio_desc *gpiod_get_index(struct device *dev,const char *con_id, unsigned int idx,enum ...