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.
31 maa_result_t maa_pwm_init(pwm_t* pwm, int chipin, int pin);
33 /** Set the ouput duty-cycle percentage, as a float
35 * @param percentage A floating-point value representing percentage of output.
36 * The value should lie between 0.0f (representing on 0%) and 1.0f
37 * Values above or below this range will be set at either 0.0f or 1.0f.
39 void maa_pwm_write(pwm_t* pwm, float percentage);
41 /** Read the ouput duty-cycle percentage, as a float
43 * @return percentage A floating-point value representing percentage of output.
44 * The value should lie between 0.0f (representing on 0%) and 1.0f
45 * Values above or below this range will be set at either 0.0f or 1.0f.
47 float maa_pwm_read(pwm_t* pwm);
49 /** Set the PWM period as seconds represented in a float
51 * @param seconds Peroid represented as a float in seconds.
53 void maa_pwm_period(pwm_t* pwm, float seconds);
55 /** Set period. milli-oseconds.
56 * @param ms milli-seconds for period.
58 void maa_pwm_period_ms(pwm_t* pwm, int ms);
60 /** Set period. microseconds
61 * @param ns microseconds as period.
63 void maa_pwm_period_us(pwm_t* pwm, int us);
65 /** Set pulsewidth, As represnted by seconds in a (float).
66 * @param seconds The duration of a pulse
68 void maa_pwm_pulsewidth(pwm_t* pwm, float seconds);
70 /** Set pulsewidth. Milliseconds
71 * @param ms milliseconds for pulsewidth.
73 void maa_pwm_pulsewidth_ms(pwm_t* pwm, int ms);
75 /** Set pulsewidth, microseconds.
76 * @param us microseconds for pulsewidth.
78 void maa_pwm_pulsewidth_us(pwm_t* pwm, int us);
80 /** Set the enable status of the PWM pin. None zero will assume on with output being driven.
81 * and 0 will disable the output.
82 * @param enable enable status of pin
84 void maa_pwm_enable(pwm_t* pwm, int enable);
86 /** Close and unexport the PWM pin.
88 void maa_pwm_close(pwm_t* pwm);