'What are my options for PWM using C++ on the Google Coral dev board?

I started looking into the libgpiod library as recommended by the Coral documentation for GPIO in C++. However I cannot find anything on using hardware PWM with that library. Is it possible?



Solution 1:[1]

In linux, everything is file.
You can try to directly control the node "/sys/class/pwm/pwmchip0/"

Try below command to control PWM.

echo 0 > /sys/class/pwm/pwmchip0/export
echo 50000 > /sys/calss/pwm/pwmchip0/pwm0/period
echo 25000 > /sys/calss/pwm/pwmchip0/pwm0/duty_cycle
ehco 1 > /sys/calss/pwm/pwmchip0/pwm0/enable

You can open and wirte those files.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1