2 * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
4 * Copyright © 2014 Intel Corporation
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 /** A PWM object, used for interacting with PWM output.
37 * // Set up PWM object then cycle percentage 0-100.
44 * pwm.period_us(7968750i); //Max Galileo Rev D
66 void write_period(int period);
67 void write_duty(int duty);
74 /** Create an PWM object
76 * @param chipid The chip in which the following pin is on.
77 * @param pin The PWM channel to operate on
79 PWM(int chipid, int pin);
81 /** Set the ouput duty-cycle percentage, as a float
83 * @param percentage A floating-point value representing percentage of output.
84 * The value should lie between 0.0f (representing on 0%) and 1.0f
85 * Values above or below this range will be set at either 0.0f or 1.0f.
87 void write(float percentage);
89 /** Read the ouput duty-cycle percentage, as a float
91 * @return percentage A floating-point value representing percentage of output.
92 * The value should lie between 0.0f (representing on 0%) and 1.0f
93 * Values above or below this range will be set at either 0.0f or 1.0f.
97 /** Set the PWM period as seconds represented in a float
99 * @param seconds Peroid represented as a float in seconds.
101 void period(float seconds);
103 /** Set period. milli-oseconds.
104 * @param ms milli-seconds for period.
106 void period_ms(int ms);
108 /** Set period. microseconds
109 * @param ns microseconds as period.
111 void period_us(int us);
113 /** Set pulsewidth, As represnted by seconds in a (float).
114 * @param seconds The duration of a pulse
116 void pulsewidth(float seconds);
118 /** Set pulsewidth. Milliseconds
119 * @param ms milliseconds for pulsewidth.
121 void pulsewidth_ms(int ms);
123 /** Set pulsewidth, microseconds.
124 * @param us microseconds for pulsewidth.
126 void pulsewidth_us(int us);
128 /** Set the enable status of the PWM pin. None zero will assume on with output being driven.
129 * and 0 will disable the output.
130 * @param enable enable status of pin
132 void enable(int enable);
134 /** Close and unexport the PWM pin.