CRpi
A library for rpi with intefaces to: gpio, pwm, dma
|
Interface to the PWM peripheral. More...
#include <peripherals/clockManager.h>
#include <memoryManagement/physMemoryManagement.h>
#include <peripherals/pwm.h>
#include <memoryManagement/addressing.h>
#include <CCRCodingUtils/include/errorManagement.h>
#include <stdlib.h>
#include <unistd.h>
#include "pwm_internal.h"
Functions | |
int | pwm_init () |
Initializes this peripheral interface, to use before any other function in this file. More... | |
int | pwm_isInit () |
true if pwm_init has been called with success | |
int | pwm_setClock (int clkSrc, int divisorInt, int divisorFrac) |
sets the clock divisor for the pwm (the base frequency is 19.2 MHz) More... | |
int | pwm_resetChannel (int channel) |
Resets the specified channel to: disabled, pwm mode, don't repeat last, silence=0, normal polarity, don't use fifo, don't use M/S Warning: the pwm peripheral likes to ignore the CTL_RPTL1_MASK and repeat the last word even if you say it not to. More... | |
int | pwm_setRepeatLastWord (int channel, unsigned int value) |
Sets the repetition of the last word in the fifo on serializer mode Warning: the pwm peripheral likes to ignore this setting and repeat the last word even if you say it not to. More... | |
int | pwm_clearFifo () |
clears the fifo More... | |
int | pwm_setEnable (int channel, unsigned int value) |
Sets the enabled status of the specified channel. After the dma completes a transfer (a chain of control blocks) and 0 gets loaded as control block this is resetted to 0. More... | |
int | pwm_setMode (int channel, unsigned int mode) |
Sets the mode of the specified channel to PWM or Serializer. More... | |
int | pwm_setSerializerMode (int channel, unsigned int mode) |
Set the serialized mode to use the fifo or the data register. More... | |
int | pwm_setMSenable (int channel, unsigned int mode) |
Sets the pwm mode: M/S or the algorithm (see datasheet pag 139) More... | |
int | pwm_setRange (int channel, uint32_t range) |
Sets the range of the specified channel counter. More... | |
int | pwm_setData (int channel, uint32_t data) |
Sets the data for the specified channel: in Serializer mode (if not using fifo) it will be sent as pulses, in PWM mode it's the number of pulses in a period. More... | |
int | pwm_writeToFifo (unsigned int data) |
Write the provided data word to the fifo. More... | |
int | pwm_setDreqThreshold (unsigned int threshold) |
Sets the threshold under which the dreq signal is raised. More... | |
int | pwm_setDmaEnable (unsigned int value) |
Enables or disables the generation of the dma signals DREQ and PANIC. More... | |
Interface to the PWM peripheral.
If you haven't already, see pwm.h See documentation at "BCM2835 ARM peripherals" pag 138d
int pwm_clearFifo | ( | ) |
clears the fifo
int pwm_init | ( | ) |
Initializes this peripheral interface, to use before any other function in this file.
int pwm_resetChannel | ( | int | channel | ) |
Resets the specified channel to: disabled, pwm mode, don't repeat last, silence=0, normal polarity, don't use fifo, don't use M/S Warning: the pwm peripheral likes to ignore the CTL_RPTL1_MASK and repeat the last word even if you say it not to.
channel | The channel |
int pwm_setClock | ( | int | clkSrc, |
int | divisorInt, | ||
int | divisorFrac | ||
) |
sets the clock divisor for the pwm (the base frequency is 19.2 MHz)
clkSrc | Clock source, see the macros in clockManager. Normally you want CLK_SRC_OSCILLATOR (19.2MHz) |
divisorInt | Integer part of the divisor |
divisorFrac | Fractional part of the divisor |
int pwm_setData | ( | int | channel, |
uint32_t | data | ||
) |
Sets the data for the specified channel: in Serializer mode (if not using fifo) it will be sent as pulses, in PWM mode it's the number of pulses in a period.
channel | The channel: 1 or 2 |
data | The data value |
int pwm_setDmaEnable | ( | unsigned int | value | ) |
Enables or disables the generation of the dma signals DREQ and PANIC.
value | 0=disabled, any other value=enabled |
int pwm_setDreqThreshold | ( | unsigned int | threshold | ) |
Sets the threshold under which the dreq signal is raised.
threshold | The threshold |
int pwm_setEnable | ( | int | channel, |
unsigned int | value | ||
) |
Sets the enabled status of the specified channel. After the dma completes a transfer (a chain of control blocks) and 0 gets loaded as control block this is resetted to 0.
channel | The channel: 1 or 2 |
value | It's a boolean: 0=disabled, 1=enabled |
int pwm_setMode | ( | int | channel, |
unsigned int | mode | ||
) |
Sets the mode of the specified channel to PWM or Serializer.
channel | The channel: 1 or 2 |
mode | The mode: 0=PWM, 1=Serializer |
int pwm_setMSenable | ( | int | channel, |
unsigned int | mode | ||
) |
Sets the pwm mode: M/S or the algorithm (see datasheet pag 139)
channel | The channel: 1 or 2 |
mode | The mode: 0=algorithm, 1=M/S |
int pwm_setRange | ( | int | channel, |
uint32_t | range | ||
) |
Sets the range of the specified channel counter.
channel | The channel: 1 or 2 |
range | Range, it's the number of possible pulses in a period. |
int pwm_setRepeatLastWord | ( | int | channel, |
unsigned int | value | ||
) |
Sets the repetition of the last word in the fifo on serializer mode Warning: the pwm peripheral likes to ignore this setting and repeat the last word even if you say it not to.
channel | The channel to configure |
value | 0=don't repeat, 1=repeat |
int pwm_setSerializerMode | ( | int | channel, |
unsigned int | mode | ||
) |
Set the serialized mode to use the fifo or the data register.
channel | The channel: 1 or 2 |
mode | The mode: 0=use data register, 1=use fifo |
int pwm_writeToFifo | ( | unsigned int | data | ) |
Write the provided data word to the fifo.
data | The data |