Difference between revisions of "Unit PWM"
Line 43: | Line 43: | ||
! '''Note''' | ! '''Note''' | ||
| Called only during system startup | | Called only during system startup | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''PWM functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceStart(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to start | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceStop(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Stop the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to stop | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceWrite(PWM:PPWMDevice; Value:LongWord):LongWord; </pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write a value to the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to write to | ||
+ | |- | ||
+ | ! '''Value''' | ||
+ | | The value to write | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | The exact meaning of value may depend on the device and other configured options, in many cases the value will represent the "on" time of each pulse with regard to the duty cycle of the waveform output by the device | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceGetGPIO(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the GPIO pin used by the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to get the GPIO pin from | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | The current GPIO pin or GPIO_PIN_UNKNOWN on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceSetGPIO(PWM:PPWMDevice; GPIO:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the GPIO pin used by the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to set the GPIO pin for | ||
+ | |- | ||
+ | ! '''GPIO''' | ||
+ | | The GPIO pin to set (eg GPIO_PIN_12) | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceGetMode(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current mode of the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to get the mode from | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | The current mode or a default value of PWM_MODE_MARKSPACE | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceSetMode(PWM:PPWMDevice; Mode:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the current mode for the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to set the mode for | ||
+ | |- | ||
+ | ! '''Mode''' | ||
+ | | The mode value to set (eg PWM_MODE_MARKSPACE) | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceGetRange(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current range of the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to get the range from | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | The current range or 0 on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceSetRange(PWM:PPWMDevice; Range:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the current range for the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to set the clock rate for | ||
+ | |- | ||
+ | ! '''Range''' | ||
+ | | The range value to set | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | The exact meaning of range may depend on the device and other configured options, in many cases the range will represent the period of one full cycle of the waveform output by the device | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceGetFrequency(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the clock frequency of the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to get the clock frequency from | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | The clock frequency in Hz or 0 on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceSetFrequency(PWM:PPWMDevice; Frequency:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the clock frequency for the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to set the clock frequency for | ||
+ | |- | ||
+ | ! '''Frequency''' | ||
+ | | The clock frequency to set in Hz | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceGetPolarity(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current polarity of the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to get the polarity from | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | The current polarity or a default value of PWM_POLARITY_NORMAL | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceSetPolarity(PWM:PPWMDevice; Polarity:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the current polarity for the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to set the polarity for | ||
+ | |- | ||
+ | ! '''Polarity''' | ||
+ | | The polarity value to set (eg PWM_POLARITY_NORMAL) | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceConfigure(PWM:PPWMDevice; DutyNS,PeriodNS:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the configuration of the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to set the configuration for | ||
+ | |- | ||
+ | ! '''DutyNS''' | ||
+ | | The "on" time part of the cycle (Nanoseconds) | ||
+ | |- | ||
+ | ! '''PeriodNS''' | ||
+ | | The duration of one full cycle (Nanoseconds) | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceProperties(PWM:PPWMDevice; Properties:PPWMProperties):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''PWM''' | ||
+ | | The PWM device to get properties from | ||
+ | |- | ||
+ | ! '''Properties''' | ||
+ | | Pointer to a TPWMProperties structure to fill in | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceCreate:PPWMDevice;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new PWM entry</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | Pointer to new PWM entry or nil if PWM could not be created | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceCreateEx(Size:LongWord):PPWMDevice;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new PWM entry</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Size''' | ||
+ | | Size in bytes to allocate for new PWM (Including the PWM entry) | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | Pointer to new PWM entry or nil if PWM could not be created | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceDestroy(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Destroy an existing PWM entry</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceRegister(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a new PWM in the PWM table</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceDeregister(PWM:PPWMDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister a PWM from the PWM table</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceFind(PWMId:LongWord):PPWMDevice;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceFindByName(const Name:String):PPWMDevice; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceFindByDescription(const Description:String):PPWMDevice; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceEnumerate(Callback:TPWMEnumerate; Data:Pointer):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function PWMDeviceNotification(PWM:PPWMDevice; Callback:TPWMNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
|- | |- | ||
|} | |} |
Revision as of 04:09, 2 September 2016
Return to Unit Reference
Description
Pulse Width Modulation (PWM) is a technique of encoding a pulsed signal so as to control the ratio of on to off by switching the signal between on and off at a very high rate.
This on and off switching allows control of the average power supplied to the load and therefore gives fine grained control of things such as motor speeds, lamp dimming and heating elements.
PWM is also used in many low power applications as well such as controlling servo motors and can even by used for audio applications such as class D amplifiers.
This unit deals with the usage of PWM for control applications (for audio applications see the Audio unit) and provides methods to control the state, frequency, duty cycle, range and mode of PWM host controllers. Not all devices support all of these concepts so this API includes a properties function to allow obtaining information about a PWM device and its capabilities.
Constants
To be documented
Type definitions
To be documented
Public variables
To be documented
Function declarations
Initialization functions
procedure PWMInit;
Note | Called only during system startup |
---|
PWM functions
function PWMDeviceStart(PWM:PPWMDevice):LongWord;
PWM | The PWM device to start |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function PWMDeviceStop(PWM:PPWMDevice):LongWord;
PWM | The PWM device to stop |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function PWMDeviceWrite(PWM:PPWMDevice; Value:LongWord):LongWord;
PWM | The PWM device to write to |
---|---|
Value | The value to write |
Return | ERROR_SUCCESS if completed or another error code on failure |
Note | The exact meaning of value may depend on the device and other configured options, in many cases the value will represent the "on" time of each pulse with regard to the duty cycle of the waveform output by the device |
function PWMDeviceGetGPIO(PWM:PPWMDevice):LongWord;
PWM | The PWM device to get the GPIO pin from |
---|---|
Return | The current GPIO pin or GPIO_PIN_UNKNOWN on failure |
function PWMDeviceSetGPIO(PWM:PPWMDevice; GPIO:LongWord):LongWord;
PWM | The PWM device to set the GPIO pin for |
---|---|
GPIO | The GPIO pin to set (eg GPIO_PIN_12) |
Return | ERROR_SUCCESS if completed or another error code on failure |
function PWMDeviceGetMode(PWM:PPWMDevice):LongWord;
PWM | The PWM device to get the mode from |
---|---|
Return | The current mode or a default value of PWM_MODE_MARKSPACE |
function PWMDeviceSetMode(PWM:PPWMDevice; Mode:LongWord):LongWord;
PWM | The PWM device to set the mode for |
---|---|
Mode | The mode value to set (eg PWM_MODE_MARKSPACE) |
Return | ERROR_SUCCESS if completed or another error code on failure |
function PWMDeviceGetRange(PWM:PPWMDevice):LongWord;
PWM | The PWM device to get the range from |
---|---|
Return | The current range or 0 on failure |
function PWMDeviceSetRange(PWM:PPWMDevice; Range:LongWord):LongWord;
PWM | The PWM device to set the clock rate for |
---|---|
Range | The range value to set |
Return | ERROR_SUCCESS if completed or another error code on failure |
Note | The exact meaning of range may depend on the device and other configured options, in many cases the range will represent the period of one full cycle of the waveform output by the device |
function PWMDeviceGetFrequency(PWM:PPWMDevice):LongWord;
PWM | The PWM device to get the clock frequency from |
---|---|
Return | The clock frequency in Hz or 0 on failure |
function PWMDeviceSetFrequency(PWM:PPWMDevice; Frequency:LongWord):LongWord;
PWM | The PWM device to set the clock frequency for |
---|---|
Frequency | The clock frequency to set in Hz |
Return | ERROR_SUCCESS if completed or another error code on failure |
function PWMDeviceGetPolarity(PWM:PPWMDevice):LongWord;
PWM | The PWM device to get the polarity from |
---|---|
Return | The current polarity or a default value of PWM_POLARITY_NORMAL |
function PWMDeviceSetPolarity(PWM:PPWMDevice; Polarity:LongWord):LongWord;
PWM | The PWM device to set the polarity for |
---|---|
Polarity | The polarity value to set (eg PWM_POLARITY_NORMAL) |
Return | ERROR_SUCCESS if completed or another error code on failure |
function PWMDeviceConfigure(PWM:PPWMDevice; DutyNS,PeriodNS:LongWord):LongWord;
PWM | The PWM device to set the configuration for |
---|---|
DutyNS | The "on" time part of the cycle (Nanoseconds) |
PeriodNS | The duration of one full cycle (Nanoseconds) |
Return | ERROR_SUCCESS if completed or another error code on failure |
function PWMDeviceProperties(PWM:PPWMDevice; Properties:PPWMProperties):LongWord;
PWM | The PWM device to get properties from |
---|---|
Properties | Pointer to a TPWMProperties structure to fill in |
Return | ERROR_SUCCESS if completed or another error code on failure |
function PWMDeviceCreate:PPWMDevice;
Return | Pointer to new PWM entry or nil if PWM could not be created |
---|
function PWMDeviceCreateEx(Size:LongWord):PPWMDevice;
Size | Size in bytes to allocate for new PWM (Including the PWM entry) |
---|---|
Return | Pointer to new PWM entry or nil if PWM could not be created |
function PWMDeviceDestroy(PWM:PPWMDevice):LongWord;
Note | To be documented |
---|
function PWMDeviceRegister(PWM:PPWMDevice):LongWord;
Note | To be documented |
---|
function PWMDeviceDeregister(PWM:PPWMDevice):LongWord;
Note | To be documented |
---|
function PWMDeviceFind(PWMId:LongWord):PPWMDevice;
Note | To be documented |
---|
function PWMDeviceFindByName(const Name:String):PPWMDevice; inline;
Note | To be documented |
---|
function PWMDeviceFindByDescription(const Description:String):PPWMDevice; inline;
Note | To be documented |
---|
function PWMDeviceEnumerate(Callback:TPWMEnumerate; Data:Pointer):LongWord;
Note | To be documented |
---|
function PWMDeviceNotification(PWM:PPWMDevice; Callback:TPWMNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Note | To be documented |
---|
Return to Unit Reference