mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
PwmOut Class Reference
[Drivers]
A pulse-width modulation digital output. More...
#include <PwmOut.h>
Public Member Functions | |
PwmOut (PinName pin) | |
Create a PwmOut connected to the specified pin. | |
void | write (float value) |
Set the output duty-cycle, specified as a percentage (float) | |
float | read () |
Return the current output duty-cycle setting, measured as a percentage (float) | |
void | period (float seconds) |
Set the PWM period, specified in seconds (float), keeping the duty cycle the same. | |
void | period_ms (int ms) |
Set the PWM period, specified in milliseconds (int), keeping the duty cycle the same. | |
void | period_us (int us) |
Set the PWM period, specified in microseconds (int), keeping the duty cycle the same. | |
void | pulsewidth (float seconds) |
Set the PWM pulsewidth, specified in seconds (float), keeping the period the same. | |
void | pulsewidth_ms (int ms) |
Set the PWM pulsewidth, specified in milliseconds (int), keeping the period the same. | |
void | pulsewidth_us (int us) |
Set the PWM pulsewidth, specified in microseconds (int), keeping the period the same. | |
PwmOut & | operator= (float value) |
A operator shorthand for write() | |
PwmOut & | operator= (PwmOut &rhs) |
A operator shorthand for write() | |
operator float () | |
An operator shorthand for read() | |
PwmOut (PinName pin) | |
Create a PwmOut connected to the specified pin. | |
void | write (float value) |
Set the output duty-cycle, specified as a percentage (float) | |
float | read () |
Return the current output duty-cycle setting, measured as a percentage (float) | |
void | period (float seconds) |
Set the PWM period, specified in seconds (float), keeping the duty cycle the same. | |
void | period_ms (int ms) |
Set the PWM period, specified in milliseconds (int), keeping the duty cycle the same. | |
void | period_us (int us) |
Set the PWM period, specified in microseconds (int), keeping the duty cycle the same. | |
void | pulsewidth (float seconds) |
Set the PWM pulsewidth, specified in seconds (float), keeping the period the same. | |
void | pulsewidth_ms (int ms) |
Set the PWM pulsewidth, specified in milliseconds (int), keeping the period the same. | |
void | pulsewidth_us (int us) |
Set the PWM pulsewidth, specified in microseconds (int), keeping the period the same. | |
PwmOut & | operator= (float value) |
A operator shorthand for write() | |
PwmOut & | operator= (PwmOut &rhs) |
A operator shorthand for write() | |
operator float () | |
An operator shorthand for read() | |
Protected Member Functions | |
void | lock_deep_sleep () |
Lock deep sleep only if it is not yet locked. | |
void | unlock_deep_sleep () |
Unlock deep sleep in case it is locked. | |
void | lock_deep_sleep () |
Lock deep sleep only if it is not yet locked. | |
void | unlock_deep_sleep () |
Unlock deep sleep in case it is locked. |
Detailed Description
A pulse-width modulation digital output.
- Note:
- Synchronization level: Interrupt safe
Example
// Gradually change the intensity of the LED. #include "mbed.h" PwmOut led(LED1); int main() { while(1) { led = led + 0.01; wait(0.2); if(led == 1.0) { led = 0; } } }
Definition at line 53 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
Constructor & Destructor Documentation
PwmOut | ( | PinName | pin ) |
Create a PwmOut connected to the specified pin.
- Parameters:
-
pin PwmOut pin to connect to
Definition at line 61 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
PwmOut | ( | PinName | pin ) |
Create a PwmOut connected to the specified pin.
- Parameters:
-
pin PwmOut pin to connect to
Definition at line 61 of file drivers/PwmOut.h.
Member Function Documentation
void lock_deep_sleep | ( | ) | [protected] |
Lock deep sleep only if it is not yet locked.
Definition at line 204 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void lock_deep_sleep | ( | ) | [protected] |
Lock deep sleep only if it is not yet locked.
Definition at line 204 of file drivers/PwmOut.h.
operator float | ( | ) |
An operator shorthand for read()
- See also:
- PwmOut::read()
Definition at line 195 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
operator float | ( | ) |
An operator shorthand for read()
- See also:
- PwmOut::read()
Definition at line 195 of file drivers/PwmOut.h.
A operator shorthand for write()
- See also:
- PwmOut::write()
Definition at line 185 of file drivers/PwmOut.h.
PwmOut& operator= | ( | float | value ) |
A operator shorthand for write()
- See also:
- PwmOut::write()
Definition at line 175 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
A operator shorthand for write()
- See also:
- PwmOut::write()
Definition at line 185 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
PwmOut& operator= | ( | float | value ) |
A operator shorthand for write()
- See also:
- PwmOut::write()
Definition at line 175 of file drivers/PwmOut.h.
void period | ( | float | seconds ) |
Set the PWM period, specified in seconds (float), keeping the duty cycle the same.
- Parameters:
-
seconds Change the period of a PWM signal in seconds (float) without modifying the duty cycle
- Note:
- The resolution is currently in microseconds; periods smaller than this will be set to zero.
Definition at line 115 of file drivers/PwmOut.h.
void period | ( | float | seconds ) |
Set the PWM period, specified in seconds (float), keeping the duty cycle the same.
- Parameters:
-
seconds Change the period of a PWM signal in seconds (float) without modifying the duty cycle
- Note:
- The resolution is currently in microseconds; periods smaller than this will be set to zero.
Definition at line 115 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void period_ms | ( | int | ms ) |
Set the PWM period, specified in milliseconds (int), keeping the duty cycle the same.
- Parameters:
-
ms Change the period of a PWM signal in milliseconds without modifying the duty cycle
Definition at line 125 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void period_ms | ( | int | ms ) |
Set the PWM period, specified in milliseconds (int), keeping the duty cycle the same.
- Parameters:
-
ms Change the period of a PWM signal in milliseconds without modifying the duty cycle
Definition at line 125 of file drivers/PwmOut.h.
void period_us | ( | int | us ) |
Set the PWM period, specified in microseconds (int), keeping the duty cycle the same.
- Parameters:
-
us Change the period of a PWM signal in microseconds without modifying the duty cycle
Definition at line 135 of file drivers/PwmOut.h.
void period_us | ( | int | us ) |
Set the PWM period, specified in microseconds (int), keeping the duty cycle the same.
- Parameters:
-
us Change the period of a PWM signal in microseconds without modifying the duty cycle
Definition at line 135 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void pulsewidth | ( | float | seconds ) |
Set the PWM pulsewidth, specified in seconds (float), keeping the period the same.
- Parameters:
-
seconds Change the pulse width of a PWM signal specified in seconds (float)
Definition at line 145 of file drivers/PwmOut.h.
void pulsewidth | ( | float | seconds ) |
Set the PWM pulsewidth, specified in seconds (float), keeping the period the same.
- Parameters:
-
seconds Change the pulse width of a PWM signal specified in seconds (float)
Definition at line 145 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void pulsewidth_ms | ( | int | ms ) |
Set the PWM pulsewidth, specified in milliseconds (int), keeping the period the same.
- Parameters:
-
ms Change the pulse width of a PWM signal specified in milliseconds
Definition at line 155 of file drivers/PwmOut.h.
void pulsewidth_ms | ( | int | ms ) |
Set the PWM pulsewidth, specified in milliseconds (int), keeping the period the same.
- Parameters:
-
ms Change the pulse width of a PWM signal specified in milliseconds
Definition at line 155 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void pulsewidth_us | ( | int | us ) |
Set the PWM pulsewidth, specified in microseconds (int), keeping the period the same.
- Parameters:
-
us Change the pulse width of a PWM signal specified in microseconds
Definition at line 165 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void pulsewidth_us | ( | int | us ) |
Set the PWM pulsewidth, specified in microseconds (int), keeping the period the same.
- Parameters:
-
us Change the pulse width of a PWM signal specified in microseconds
Definition at line 165 of file drivers/PwmOut.h.
float read | ( | void | ) |
Return the current output duty-cycle setting, measured as a percentage (float)
- Returns:
- A floating-point value representing the current duty-cycle being output on the pin, measured as a percentage. The returned value will lie between 0.0f (representing on 0%) and 1.0f (representing on 100%).
- Note:
- This value may not match exactly the value set by a previous write().
Definition at line 100 of file drivers/PwmOut.h.
float read | ( | void | ) |
Return the current output duty-cycle setting, measured as a percentage (float)
- Returns:
- A floating-point value representing the current duty-cycle being output on the pin, measured as a percentage. The returned value will lie between 0.0f (representing on 0%) and 1.0f (representing on 100%).
- Note:
- This value may not match exactly the value set by a previous write().
Definition at line 100 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void unlock_deep_sleep | ( | ) | [protected] |
Unlock deep sleep in case it is locked.
Definition at line 213 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void unlock_deep_sleep | ( | ) | [protected] |
Unlock deep sleep in case it is locked.
Definition at line 213 of file drivers/PwmOut.h.
void write | ( | float | value ) |
Set the output duty-cycle, specified as a percentage (float)
- Parameters:
-
value A floating-point value representing the output duty-cycle, specified as a percentage. The value should lie between 0.0f (representing on 0%) and 1.0f (representing on 100%). Values outside this range will be saturated to 0.0f or 1.0f.
Definition at line 82 of file cmsis/BUILD/mbed/drivers/PwmOut.h.
void write | ( | float | value ) |
Set the output duty-cycle, specified as a percentage (float)
- Parameters:
-
value A floating-point value representing the output duty-cycle, specified as a percentage. The value should lie between 0.0f (representing on 0%) and 1.0f (representing on 100%). Values outside this range will be saturated to 0.0f or 1.0f.
Definition at line 82 of file drivers/PwmOut.h.
Generated on Tue Jul 12 2022 20:41:17 by 1.7.2