gpt4 book ai didi

linux-kernel - Linux 内核中的 gpiod_* 与 gpio_* 方法

转载 作者:行者123 更新时间:2023-12-03 03:00:25 25 4
gpt4 key购买 nike

Linux 设备驱动程序编程中哪种 GPIO API 更适合以及在什么条件下使用:gpio_set_value()gpiod_set_value()

一种将 GPIO desc 作为对象,另一种则采用从设备树中解析出的 GPIO。

最佳答案

对于所有新驱动程序,建议使用 gpiod_* API。老gpio_* API 现已被视为已弃用。

来自this提交:

gpiolib: export descriptor-based GPIO interface

This patch exports the gpiod_* family of API functions, a safer alternative to the legacy GPIO interface. Differences between the gpiod and legacy gpio APIs are:

  • gpio works with integers, whereas gpiod operates on opaque handlers which cannot be forged or used before proper acquisition
  • gpiod get/set functions are aware of the active low state of a GPIO
  • gpio consumers should now include <linux/gpio/consumer.h> to access the new interface, whereas chips drivers will use <linux/gpio/driver.h>

The legacy gpio API is now built as inline functions on top of gpiod.

有关新 gpiod API 的详细信息,请参阅下一个链接:

关于linux-kernel - Linux 内核中的 gpiod_* 与 gpio_* 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39103185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com