|
CRpi
A library for rpi with intefaces to: gpio, pwm, dma
|
Generates pwm outputs on the gpio pins using the dma engine. More...
Go to the source code of this file.
Functions | |
| int | pwmDma_init (unsigned int pulseDuration_us) |
| Initialize: call this before any other function in this file. This sets up the pwm to use it as a timer, so don't mess with it after calling this function. More... | |
| unsigned int | pwmDma_get_pulseDuration_us () |
| Returns the duration in microseconds of a single pulse, you can set this duration in pwmDma_init(...) More... | |
| int | pwmDma_isChannelInitialized (int channel) |
| Tells if a channel is initialized. More... | |
| int | pwmDma_getChannelPeriodUs (int channel) |
| Return the duration in microseconds of a cycle for the specified channel. More... | |
| int | pwmDma_initChannel_periodInPulses (int channel, unsigned int pulsesPerPeriod) |
| Sets up the channel to output pwm, you can use only a channel at a time. More... | |
| int | pwmDma_initChannel (int channel, unsigned int period_us) |
| Sets up the channel to output pwm. More... | |
| int | pwmDma_freeChannel (int channel) |
| Frees a channel initialized with pwmDma_initChannel or pwmDma_initChannel_periodInPulses. More... | |
| int | pwmDma_startChannel (int channel) |
| Starts a stopped channel. More... | |
| int | pwmDma_stopChannelWaitCycleEnd (int channel) |
| Stops channel waiting for the current cycle to finish. More... | |
| int | pwmDma_stopChannel (int channel) |
| Stops channel. More... | |
| int | pwmDma_addPulse (int channel, int bcmPort, unsigned int start_us, unsigned int length_us) |
| Sets a pulse on the specified channel and gpio. More... | |
| int | pwmDma_printWords (int channel) |
| For debugging purposes: prints all the set/clear words. More... | |
| int | pwmDma_printControlBlocks (int channel) |
| For debugging purposes: prints all the control blocks. More... | |
| int | pwmDma_setMSRatio (int channel, int bcmPort, double ratio) |
| Set the port to output a square wave with the specified duty cycle. Will be high for the first ratio*period microseconds and then low. More... | |
| int | pwmDma_clearPort (int channel, int bcmPort) |
| Removes any pulse on this port at the specified channel. More... | |
| int | pwmDma_addMultiplePulse (int channel, int bcmPort, unsigned int start_us, unsigned int length_us, unsigned int subPeriod_us) |
| Adds multiple pulses to the channel at the specified port. The pulse will be repeated every subPeriod_us microseconds. In this way you can simulate a channel initialized with period=subPeriod_us. More... | |
Generates pwm outputs on the gpio pins using the dma engine.
To generate a pwm output you first have to call pwmDma_init().
Then you can initilize a channel with pwmDma_initChannel().
After this you can add pulses to the channel using pwmDma_addPulse(), pwmDma_addMultiplePulse() or pwmDma_setMSRatio().
You can clear the output on a port using pwmDma_clearPort()
When you finish you HAVE TO call pwmDma_freeChannel() on the channel you initialized.
See pwmByDma.c for more details.
| int pwmDma_addMultiplePulse | ( | int | channel, |
| int | bcmPort, | ||
| unsigned int | start_us, | ||
| unsigned int | length_us, | ||
| unsigned int | subPeriod_us | ||
| ) |
Adds multiple pulses to the channel at the specified port. The pulse will be repeated every subPeriod_us microseconds. In this way you can simulate a channel initialized with period=subPeriod_us.
| channel | The channel number |
| bcmPort | The port broadcom number, only ports 0-31 are available |
| start_us | The start time of the pulse in microseconds, has to be a multiple of the pulse duration, and between 0 and the subPeriod_us |
| length_us | The length of the pulse in microseconds, has to be a multiple of the pulse duration and not bigger than subPeriod_us |
| subPeriod_us | The period at which the pulse will be repeated. Has to be a divisor of the period of the channel |
| int pwmDma_addPulse | ( | int | channel, |
| int | bcmPort, | ||
| unsigned int | start_us, | ||
| unsigned int | length_us | ||
| ) |
Sets a pulse on the specified channel and gpio.
| channel | The channel number |
| bcmPort | The port broadcom number, only ports 0-31 are available |
| start_us | The start time of the pulse in microseconds, has to be a multiple of the pulse duration, and between 0 and the period duration of this channel |
| length_us | The length of the pulse in microseconds, has to be a multiple of the pulse duration |
| int pwmDma_clearPort | ( | int | channel, |
| int | bcmPort | ||
| ) |
Removes any pulse on this port at the specified channel.
| channel | The channel |
| bcmPort | The port |
| int pwmDma_freeChannel | ( | int | channel | ) |
Frees a channel initialized with pwmDma_initChannel or pwmDma_initChannel_periodInPulses.
| channel | The channel number |
| unsigned int pwmDma_get_pulseDuration_us | ( | ) |
Returns the duration in microseconds of a single pulse, you can set this duration in pwmDma_init(...)
| int pwmDma_getChannelPeriodUs | ( | int | channel | ) |
Return the duration in microseconds of a cycle for the specified channel.
| channel | The channel number |
| int pwmDma_init | ( | unsigned int | pulseDuration_us | ) |
Initialize: call this before any other function in this file. This sets up the pwm to use it as a timer, so don't mess with it after calling this function.
| pulseDuration_us | The duration of a single pulse in microseconds, in other words: the granularity, the precision. All prime numbers over 4095 and all the numbers over 33546 aren't acceptable. |
| int pwmDma_initChannel | ( | int | channel, |
| unsigned int | period_us | ||
| ) |
Sets up the channel to output pwm.
| channel | The channel to use |
| period_us | Duration of a cycle in microseconds |
| int pwmDma_initChannel_periodInPulses | ( | int | channel, |
| unsigned int | pulsesPerPeriod | ||
| ) |
Sets up the channel to output pwm, you can use only a channel at a time.
| channel | The channel to use |
| pulsesPerPeriod | Number of pulses in a cycle. The resulting period duration is: period_us = pulsesPerPeriod*pulseDuration_us. Where pulseDuration_us is specified in pwmDma_init(...) |
| int pwmDma_isChannelInitialized | ( | int | channel | ) |
Tells if a channel is initialized.
| channel | The channel number |
| int pwmDma_printControlBlocks | ( | int | channel | ) |
For debugging purposes: prints all the control blocks.
| int pwmDma_printWords | ( | int | channel | ) |
For debugging purposes: prints all the set/clear words.
| int pwmDma_setMSRatio | ( | int | channel, |
| int | bcmPort, | ||
| double | ratio | ||
| ) |
Set the port to output a square wave with the specified duty cycle. Will be high for the first ratio*period microseconds and then low.
| channel | The channel to use |
| bcmPort | The port to use |
| ratio | The duty cycle ratio |
| int pwmDma_startChannel | ( | int | channel | ) |
Starts a stopped channel.
| channel | The channel number |
| int pwmDma_stopChannel | ( | int | channel | ) |
Stops channel.
| channel | The channel number |
| int pwmDma_stopChannelWaitCycleEnd | ( | int | channel | ) |
Stops channel waiting for the current cycle to finish.
| channel | The channel number |
1.8.11