libgpiod is the standard library for driving GPIOs via the GPIO character device, /dev/gpiochipN, which is the standard GPIO userspace interface for Linux.There are several libraries for programming the GPIO, but I get the impression that the recommended one is libgpiod. My take is that it's the most versatile one. Am I correct?
That interface is the only one that works on all Pi variants. Other libraries that use the obsolete sysfs interface or the /dev/gpiomem interface will not work on the Pi5.
libgpiod v2 can do anything that is possible via that interface.
Then you should use libgpiod v2. That is the latest version and replaces the less versatile libgpiod v1 which has a different API and is now a dead-end.This is for simple examples of programming a GPIO pin that I'm giving in an introductory book I'm writing, so I want things to be "standard" and "future-proof." At the same time, I want to prepare a reader for moving on to more advanced things, so I don't want to take the simplest route that may be sort of a dead-end. My examples are in C, assembly language, and Python. So far, I haven't figured out how to use assembly language on the RPi 5, which uses the RP1 chip, but I'm working on it.
It provides both C and Python bindings (and C++ and Rust too), and includes examples for common use cases in all of the languages it supports.
Last I heard it was not packaged for Pi OS - the available packages are libgpiod v1 (yes even the libgpiod2 package), so you would need to install it from source. They are planning to package v2 for Pi OS, but I don't think they are there yet.
Using assembly for GPIO on the Pi5 doesn't make sense to me.
Statistics: Posted by warthog618 — Sat Mar 16, 2024 8:19 am