2 * Originally from mbed Microcontroller Library
3 * Copyright (c) 2006-2013 ARM Limited
4 * Copyright (c) 2014 Intel Corporation
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
26 /** A PWM object, used for interacting with PWM output.
30 * // Set up PWM object then cycle percentage 0-100.
37 * pwm.period_us(7968750i); //Max Galileo Rev D
59 void write_period(int period);
60 void write_duty(int duty);
67 /** Create an PWM object
69 * @param chipid The chip in which the following pin is on.
70 * @param pin The PWM channel to operate on
72 PWM(int chipid, int pin);
74 /** Set the ouput duty-cycle percentage, as a float
76 * @param percentage A floating-point value representing percentage of output.
77 * The value should lie between 0.0f (representing on 0%) and 1.0f
78 * Values above or below this range will be set at either 0.0f or 1.0f.
80 void write(float percentage);
82 /** Read the ouput duty-cycle percentage, as a float
84 * @return percentage A floating-point value representing percentage of output.
85 * The value should lie between 0.0f (representing on 0%) and 1.0f
86 * Values above or below this range will be set at either 0.0f or 1.0f.
90 /** Set the PWM period as seconds represented in a float
92 * @param seconds Peroid represented as a float in seconds.
94 void period(float seconds);
96 /** Set period. milli-oseconds.
97 * @param ms milli-seconds for period.
99 void period_ms(int ms);
101 /** Set period. microseconds
102 * @param ns microseconds as period.
104 void period_us(int us);
106 /** Set pulsewidth, As represnted by seconds in a (float).
107 * @param seconds The duration of a pulse
109 void pulsewidth(float seconds);
111 /** Set pulsewidth. Milliseconds
112 * @param ms milliseconds for pulsewidth.
114 void pulsewidth_ms(int ms);
116 /** Set pulsewidth, microseconds.
117 * @param us microseconds for pulsewidth.
119 void pulsewidth_us(int us);
121 /** Set the enable status of the PWM pin. None zero will assume on with output being driven.
122 * and 0 will disable the output.
123 * @param enable enable status of pin
125 void enable(int enable);
127 /** Close and unexport the PWM pin.