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.
23 * This file defines the pwm interface for libmaa
37 maa_pwm_context* maa_pwm_init(int chipin, int pin);
39 /** Set the ouput duty-cycle percentage, as a float
41 * @param percentage A floating-point value representing percentage of output.
42 * The value should lie between 0.0f (representing on 0%) and 1.0f
43 * Values above or below this range will be set at either 0.0f or 1.0f.
45 void maa_pwm_write(maa_pwm_context* pwm, float percentage);
47 /** Read the ouput duty-cycle percentage, as a float
49 * @return percentage A floating-point value representing percentage of output.
50 * The value should lie between 0.0f (representing on 0%) and 1.0f
51 * Values above or below this range will be set at either 0.0f or 1.0f.
53 float maa_pwm_read(maa_pwm_context* pwm);
55 /** Set the PWM period as seconds represented in a float
57 * @param seconds Peroid represented as a float in seconds.
59 void maa_pwm_period(maa_pwm_context* pwm, float seconds);
61 /** Set period. milli-oseconds.
62 * @param ms milli-seconds for period.
64 void maa_pwm_period_ms(maa_pwm_context* pwm, int ms);
66 /** Set period. microseconds
67 * @param ns microseconds as period.
69 void maa_pwm_period_us(maa_pwm_context* pwm, int us);
71 /** Set pulsewidth, As represnted by seconds in a (float).
72 * @param seconds The duration of a pulse
74 void maa_pwm_pulsewidth(maa_pwm_context* pwm, float seconds);
76 /** Set pulsewidth. Milliseconds
77 * @param ms milliseconds for pulsewidth.
79 void maa_pwm_pulsewidth_ms(maa_pwm_context* pwm, int ms);
81 /** Set pulsewidth, microseconds.
82 * @param us microseconds for pulsewidth.
84 void maa_pwm_pulsewidth_us(maa_pwm_context* pwm, int us);
86 /** Set the enable status of the PWM pin. None zero will assume on with output being driven.
87 * and 0 will disable the output.
88 * @param enable enable status of pin
90 void maa_pwm_enable(maa_pwm_context* pwm, int enable);
92 /** Close and unexport the PWM pin.
94 void maa_pwm_close(maa_pwm_context* pwm);