libpwm

Section: Linux Simple I/O Library (2)
Updated: 21 December 2018
Index Return to Main Contents
 

NAME

libpwm -- Linux Simple I/O Library: PWM Output Module  

SYNOPSIS

#include <libsimpleio/libpwm.h>

typedef enum
{
  PWM_POLARITY_ACTIVELOW,
  PWM_POLARITY_ACTIVEHIGH,
} PWM_POLARITY_t;

void PWM_configure(int32_t chip, int32_t channel, int32_t period,
  int32_t ontime, int32_t polarity, int32_t *error);

void PWM_open(int32_t chip, int32_t channel, int32_t *fd,
  int32_t *error);

void PWM_close(int32_t fd, int32_t *error);

void PWM_write(int32_t fd, int32_t ontime, int32_t *error);

Link with -lsimpleio.  

DESCRIPTION

All functions return either 0 (upon success) or an errno value (upon failure) in *error.

PWM_configure() configures a single PWM output. The chip parameter selects the PWM controller chip (as numbered by the Linux kernel) and the channel parameter selects the PWM output (also as numbered by the Linux kernel) to be configured. The period parameter sets the PWM output pulse period in nanoseconds. Note that many PWM controllers require the same PWM pulse frequency for all channels. Therefore, configuring different pulse period values for different channels within the same PWM controller may result in incorrect operation. The ontime parameter sets the initial PWM output pulse width in nanoseconds. The polarity parameter sets the PWM output polarity and may be PWM_POLARITY_ACTIVELOW or PWM_POLARITY_ACTIVEHIGH. Note that some PWM controllers will not allow the PWM_POLARITY_ACTIVELOW setting.

PWM_open() opens a (previously) configured PWM output device. The PWM controller chip number must be passed in the chip parameter and the PWM output number must be passed in the channel parameter. Upon success, a file descriptor for the PWM output device is returned in *fd.

PWM_close() closes a previously opened PWM output device.

PWM_write() changes the PWM output pulse width. The file descriptor for an open PWM output device must be passed in the fd parameter. The new PWM output pulse width in nanoseconds must be passed in the ontime parameter.  

SEE ALSO

libsimpleio(2), libadc(2), libdac(2), libevent(2), libgpio(2),
libhidraw(2), libi2c(2), libipv4(2), liblinux(2), liblinx(2),
libserial(2), libspi(2), libstream(2), libwatchdog(2)  

AUTHOR

Philip Munts, President, Munts AM Corp dba Munts Technologies


 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 09:41:20 GMT, December 21, 2018