1 /* mbed Microcontroller Library - PwmOut
2 * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
11 #include "PeripheralNames.h"
17 * A pulse-width modulation digital output
35 * Note that on the LPC1768 and LPC2368, the PWMs all share the same
36 * period - if you change the period for one, you change it for all.
37 * Although routines that change the period maintain the duty cycle
38 * for its PWM, all other PWMs will require their duty cycle to be
41 class PwmOut : public Base {
45 /* Constructor: PwmOut
46 * Create a PwmOut connected to the specified pin
49 * pin - PwmOut pin to connect to
51 PwmOut(PinName pin, const char *name = NULL);
54 * Set the ouput duty-cycle, specified as a percentage (float)
57 * value - A floating-point value representing the output duty-cycle,
58 * specified as a percentage. The value should lie between
59 * 0.0f (representing on 0%) and 1.0f (representing on 100%).
60 * Values outside this range will be saturated to 0.0f or 1.0f.
62 void write(float value);
65 * Return the current output duty-cycle setting, measured as a percentage (float)
68 * returns - A floating-point value representing the current duty-cycle being output on the pin,
69 * measured as a percentage. The returned value will lie between
70 * 0.0f (representing on 0%) and 1.0f (representing on 100%).
73 * This value may not match exactly the value set by a previous <write>.
78 * Set the PWM period, specified in seconds (float), keeping the
79 * duty cycle the same.
82 * The resolution is currently in microseconds; periods smaller than this
83 * will be set to zero.
85 void period(float seconds);
87 /* Function: period_ms
88 * Set the PWM period, specified in milli-seconds (int), keeping the
89 * duty cycle the same.
91 void period_ms(int ms);
93 /* Function: period_us
94 * Set the PWM period, specified in micro-seconds (int), keeping the
95 * duty cycle the same.
97 void period_us(int us);
99 /* Function: pulsewidth
100 * Set the PWM pulsewidth, specified in seconds (float), keeping the
103 void pulsewidth(float seconds);
105 /* Function: pulsewidth_ms
106 * Set the PWM pulsewidth, specified in milli-seconds (int), keeping
107 * the period the same.
109 void pulsewidth_ms(int ms);
111 /* Function: pulsewidth_us
112 * Set the PWM pulsewidth, specified in micro-seconds (int), keeping
113 * the period the same.
115 void pulsewidth_us(int us);
117 #ifdef MBED_OPERATORS
118 /* Function: operator=
119 * A operator shorthand for <write()>
121 PwmOut& operator= (float value);
122 PwmOut& operator= (PwmOut& rhs);
124 /* Function: operator float()
125 * An operator shorthand for <read()>
131 virtual const struct rpc_method *get_rpc_methods();
132 static struct rpc_class *get_rpc_class();