* 则为 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. 解释 devm_fwnode_gpiod_get 函数的用途 devm_fwnode_gpiod_get 是一个用于从固件节点(fwnode)获取 GPIO 描述符(gpio_desc)的函数。它允许驱动程序从设备树(Device Tree)或 ACPI 表等固件接口中查找和获取 GPIO 资源,并对其进行管理。
gpio_direction_output() :设置GPIO为输出模式。该函数用于将指定的GPIO设置为输出模式,以便向其写入数据。gpio_get_value():读取GPI O状态。该函数用于读取指定GPIO的状态,返回值为0或1。gpio_set_value():设置GPIO值。该函数用于将指定GPI O的值设置为0或1。gpio_free():释放GPIO资源。该函数用于释放之前通过...
devm_gpiod_get_optional ->devm_gpiod_get_index_optional->//index为0devm_gpiod_get_index ->gpiod_get_index 可以看到devm_gpiod_get_optional只是对gpiod_get_index的包装而已,并且index为0。index参数后面会提。 函数参数: structgpio_desc *__must_check devm_gpiod_get_index(structdevice *dev,co...
使用一下两个函数获取GPIO设备,多个设备时需要附带index参数。函数返回一个GPIO描述符,或一个错误编码,可以使用IS_ERR()进行检查: struct gpio_desc *gpiod_get(struct device *dev, const char *con_id, enum gpiod_flags flags) struct gpio_desc *gpiod_get_index(struct device *dev, ...
power = gpiod_get(dev, "power", GPIOD_OUT_HIGH); 1. 2. 3. 4. 5. 1.3.2 旧的gpio函数举例 如果需要使用gpio_函数,需要知道引脚号,引脚号的计算: 每个注册的GPIO Controller会确定它的"base number",那么这个控制器里的第n号引脚的号码就是,base number + n ...
看头文件里面包含的函数列表 desc_to_gpio devm_get_gpiod_from_chi devm_gpiod_get 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 ...
int gpiod_get_direction(const struct gpio_desc *desc) 函数返回 GPIOF_DIR_IN 或者 GPIOF_DIR_OUT #读取 GPIO 口电平 访问分为两种,一种是通过储存器读写实现的,这种操作属于原子操作,不需要等待,所以可以在中断处理程序中使用: int gpiod_get_value(const struct gpio_desc *desc);void gpiod_set_val...
struct gpiod_line *line; line = gpiod_chip_get_line(chip, <引脚号>); 设置引脚方向:使用gpiod_line_request_output函数将引脚设置为输出模式。可以使用以下代码设置引脚方向: 代码语言:txt 复制 int ret; ret = gpiod_line_request_output(line, "example", 0); ...
int gpio_get_value(unsigned gpio); /* GPIO OUTPUT */ void gpio_set_value(unsigned gpio, int value); 1. 2. 3. 4. 此函数需要注意三个问题:第一、value的值是布尔类型(boolean),0表示低,非0表示高;第二:返回的值和输出值有可能不匹配,需要考虑wire-OR情况以及输出延时;第三、这两个函数不需要...