Data Types


Determines the way in which libsoc handles exporting and unexporting PWMs in the Linux subsystem.


Used for setting and reading the enabled state of the PWM device


Used for setting and reading the polarity of the PWM device



pwm* libsoc_pwm_request(unsigned int pwm_chip, unsigned int pwm_num, enum shared_mode mode)

Request a pwm by specifying its pwm chip number and the pwm number it is on that chip. Set shared_mode to handle how libsoc manages the file descriptor. Returns a malloced pwm struct which will need to be freed by libsoc_pwm_free when no longer needed.


int libsoc_pwm_free(pwm *pwm)

Free the memory associated with a previously requested PWM device and close the file descriptors.


int libsoc_pwm_set_enabled(pwm *pwm, pwm_enabled enabled)

Set the state of a PWM device, ENABLED to enable to the device, DISABLED to disable the device.


pwm_enabled libsoc_pwm_get_enabled(pwm *pwm)

Get the current pwm_enabled state of a requested PWM device.


int libsoc_pwm_set_period(pwm *pwm, unsigned int period)

Set the period of a PWM device, the value is specified in nanoseconds and is the sum of the active and inactive time of the signal.


int libsoc_pwm_get_period(pwm *pwm)

Get the currently set perioid of the PWM device in nanoseconds.


int libsoc_pwm_set_duty_cycle(pwm *pwm, unsigned int duty)

Set the duty cycle of the specified PWM device in nanoseconds. The duty cycle is the active time of the PWM signal and must be less than the period.


int libsoc_pwm_get_duty_cycle(pwm *pwm)

Get the currently set duty cycle of a requested PWM device in nanoseconds.


int libsoc_pwm_set_polarity(pwm *pwm, pwm_polarity polarity)

Set the polarity of a PWM device, NORMAL will give you the default polarity, INVERSED will give you the inverse polarity of normal.

Polarity support is optional, ensure your PWM devices kernel driver is capable before relying on this support. The value -1 will be returned on failure to set the polarity.


pwm_polarity libsoc_pwm_get_polarity(pwm *pwm)

Get the current pwm_polarity of a requested PWM device.