Functions | |
int | PwmOut_SetActive (int index, int state) |
Sets whether the specified PWM device is active. | |
int | PwmOut_GetActive (int index) |
Returns the active state of the LED. | |
int | PwmOut_SetDuty (int index, int duty) |
Set the speed of a PWM device. | |
int | PwmOut_GetDuty (int index) |
Read the current duty of a PWM device. | |
int | PwmOut_SetInvertA (int index, char invert) |
Set whether the A channel associated with a PWM out should be inverted. | |
int | PwmOut_GetInvertA (int index) |
Read whether the A channel of a PWM device is inverted. | |
int | PwmOut_SetInvertB (int index, char invert) |
Read whether the B channel of a PWM out is inverted. | |
int | PwmOut_GetInvertB (int index) |
Read whether the B channel of a PWM device is inverted. | |
int | PwmOut_SetInvert (int index, char invertA, char invertB) |
Set whether the 2 channels of a PWM device are inverted. | |
int | PwmOut_SetAll (int index, int duty, char invertA, char invertB) |
Set the duty and the inversion of both channels of a PWM device. | |
int | PwmOut_SetDividerAValue (int val) |
Set the divider A value. | |
int | PwmOut_GetDividerAValue () |
Read the divider A value. | |
int | PwmOut_SetDividerAMux (int mux) |
Set the divider A mux value. | |
int | PwmOut_GetDividerAMux () |
Read the divider A mux value. | |
int | PwmOut_SetDividerBValue (int val) |
Set the divider B value. | |
int | PwmOut_GetDividerBValue () |
Read the divider B value. | |
int | PwmOut_SetDividerBMux (int mux) |
Set the divider B mux value. | |
int | PwmOut_GetDividerBMux () |
Read the divider B mux value. | |
int | PwmOut_SetWaveformAlignment (int index, int val) |
Set the alignment of a channel's waveform. | |
int | PwmOut_GetWaveformAlignment (int index) |
Read the configured waveform alignment for a given PWM channel. | |
int | PwmOut_SetWaveformPolarity (int index, int val) |
Set the Waveform Polarity for a PWM channel. | |
int | PwmOut_GetWaveformPolarity (int index) |
Read the waveform polarity for a given channel. |
Each PWM device controls a pair of Digital Outs - an A and a B channel:
The A and B channels of a PWM device can be set independently to be inverted, or not, from one another in order to control motors, lights, etc.
The simplest way to get started is simply with a call to PwmOut_SetActive() and then to PwmOut_SetDuty() - this will allow you to control simple dimming and motors. If you need to adjust timing, inversion or other parameters, delve a bit deeper into the API above.
PwmOut relies on the internal PWM (Pulse Width Modulation) system. See that page for more info on the timing issues involved with the PWM Out system.
int PwmOut_GetActive | ( | int | index | ) |
int PwmOut_GetDividerAMux | ( | void | ) |
Read the divider A mux value.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
int PwmOut_GetDividerAValue | ( | void | ) |
Read the divider A value.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
int PwmOut_GetDividerBMux | ( | void | ) |
Read the divider B mux value.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
int PwmOut_GetDividerBValue | ( | void | ) |
Read the divider B value.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
int PwmOut_GetDuty | ( | int | index | ) |
int PwmOut_GetInvertA | ( | int | index | ) |
int PwmOut_GetInvertB | ( | int | index | ) |
int PwmOut_GetWaveformAlignment | ( | int | index | ) |
Read the configured waveform alignment for a given PWM channel.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
index | The PWM channel (0-3) you'd like to read from. |
int PwmOut_GetWaveformPolarity | ( | int | index | ) |
Read the waveform polarity for a given channel.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
index | The PWM channel (0-3) that you'd like to read from. |
int PwmOut_SetActive | ( | int | index, | |
int | state | |||
) |
int PwmOut_SetAll | ( | int | index, | |
int | duty, | |||
char | invertA, | |||
char | invertB | |||
) |
Set the duty and the inversion of both channels of a PWM device.
This is a convenience function to set all the properties of a PWM device in a single call.
It is equivalent to separate calls to PwmOut_SetInvert() and PwmOut_SetDuty().
index | An integer specifying which PWM out. | |
duty | An integer specifying the duty (0 - 1023). | |
invertA | A character specifying the inversion of the A channel - 1/non-zero (inverted) or 0 (normal). | |
invertB | A character specifying the inversion of the B channel - 1/non-zero (inverted) or 0 (normal). |
int PwmOut_SetDividerAMux | ( | int | mux | ) |
Set the divider A mux value.
mux | The mux value (between 0 and 10) Contributed by TheStigg - http://www.makingthings.com/author/thestigg |
int PwmOut_SetDividerAValue | ( | int | val | ) |
Set the divider A value.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
val | The value (between 0 and 255) |
int PwmOut_SetDividerBMux | ( | int | mux | ) |
Set the divider B mux value.
mux | The mux value (between 0 and 10) Contributed by TheStigg - http://www.makingthings.com/author/thestigg |
int PwmOut_SetDividerBValue | ( | int | val | ) |
Set the divider B value.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
val | The value (between 0 and 255) |
int PwmOut_SetDuty | ( | int | index, | |
int | duty | |||
) |
int PwmOut_SetInvert | ( | int | index, | |
char | invertA, | |||
char | invertB | |||
) |
Set whether the 2 channels of a PWM device are inverted.
This is a convenience function, and is equivalent to making separate calls to PwmOut_SetInvertA() and PwmOut_SetInvertB().
index | An integer specifying which PWM device (0-3). | |
invertA | A character specifying the inversion of the A channel - 1/non-zero (inverted) or 0 (normal). | |
invertB | A character specifying the inversion of the B channel - 1/non-zero (inverted) or 0 (normal). |
int PwmOut_SetInvertA | ( | int | index, | |
char | invert | |||
) |
int PwmOut_SetInvertB | ( | int | index, | |
char | invert | |||
) |
int PwmOut_SetWaveformAlignment | ( | int | index, | |
int | val | |||
) |
Set the alignment of a channel's waveform.
Valid values are:
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
index | The PWM channel (0-3) that you'd like to configure. | |
val | The alignment value, as described above. |
int PwmOut_SetWaveformPolarity | ( | int | index, | |
int | val | |||
) |
Set the Waveform Polarity for a PWM channel.
Valid values are:
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
index | The PWM channel (0-3) that you'd like to configure. | |
val | The value, as described above. |