PWM

Background

Implements userspace PWM, via the sysfs interface.

Class Description

class SysFS_PWM_Pin

A PWM pin, as represented in /sys/class/pwm/pwmchip0/pwm7/

Encapsulates an exported sysfs PWM pin. It does not export the pin itself (by writing to /sys/class/pwm/pwmchipN/export). Rather, you have to make sure that the pin directory exists, and is configured correctly.

Note that the pin’s period property has no setter. This is because a PWM pin’s period is not subject to change once it has been configured (only the duty_cycle is).

Public Functions

inline SysFS_PWM_Pin(const std::string &pindir)

Constructor

Parameters:

pindir – The sysfs pin directory; e.g. /sys/class/pwm/pwmchip0/pwm7

inline uint64_t period()

Get period

inline uint64_t duty_cycle()

Get duty cycle

void set_duty_cycle(uint64_t i)

Set duty cycle