Robot Control Library
|
C interface for the Sitara PWM driver.
<rc/pwm.h>
These functions provide a general interface to all 3 PWM subsystems, each of which have two available channels A and B. PWM subsystems 1 and 2 are used for controlling the 4 motor drivers on the Robotics Cape, however they may be controlled by the user directly instead of using the motor API. PWM subsystem 0 channels A and B can be accessed on the GPS header if set up with the Pinmux API to do so. The user may have exclusive use of that subsystem.
Functions | |
int | rc_pwm_init (int ss, int frequency) |
Configures subsystem 0, 1, or 2 to operate at a particular frequency. More... | |
int | rc_pwm_cleanup (int ss) |
Stops a subsystem and puts it into a low-power state. More... | |
int | rc_pwm_set_duty (int ss, char ch, double duty) |
Sets the duty cycle of a specific pwm channel. More... | |
int | rc_pwm_set_duty_ns (int ss, char ch, unsigned int duty_ns) |
Like rc_pwm_set_duty() but takes a pulse width in nanoseconds. More... | |
int rc_pwm_init | ( | int | ss, |
int | frequency | ||
) |
Configures subsystem 0, 1, or 2 to operate at a particular frequency.
This may be called at runtime to change the pwm frequency without stopping the motors or pwm signal.
[in] | ss | Subsystem 0 1 or 2 |
[in] | frequency | The frequency in HZ |
int rc_pwm_cleanup | ( | int | ss | ) |
Stops a subsystem and puts it into a low-power state.
Recommended to call before userspace program exits to ensure the PWM hardware stops.
[in] | ss | subsystem 0,1,2 |
int rc_pwm_set_duty | ( | int | ss, |
char | ch, | ||
double | duty | ||
) |
Sets the duty cycle of a specific pwm channel.
[in] | ss | subsystem 0,1,2 |
[in] | ch | channel 'A' or 'B' |
[in] | duty | between 0.0 (off) and 1.0(full on) |
int rc_pwm_set_duty_ns | ( | int | ss, |
char | ch, | ||
unsigned int | duty_ns | ||
) |
Like rc_pwm_set_duty() but takes a pulse width in nanoseconds.
duty_ns which must range from 0 (off) to the number of nanoseconds in a single cycle as determined by the freqency specified when calling rc_pwm_init(). For example, a pwm frequency of 25kz corresponds to a maximum pulse width of 40,000ns.
[in] | ss | subsystem 0,1,2 |
[in] | ch | channel 'A' or 'B' |
[in] | duty_ns | The duty cycle (pulse width) in nanoseconds |