[3/6] fd passing: use fd directly without opening it
[platform/core/api/peripheral-io.git] / include / interface / pwm.h
1 /*
2  * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __PWM_H__
18 #define __PWM_H__
19
20 #include "peripheral_io.h"
21
22 /**
23  * @brief Enumeration for Polarity
24  */
25 typedef enum {
26         PWM_POLARITY_NORMAL = 0,
27         PWM_POLARITY_INVERSED,
28 } pwm_polarity_e;
29
30
31 /**
32 * @brief pwm_close() deinit pwm pin.
33 *
34 * @param[in] chip pwm chip number
35 * @param[in] pin pwm pin number
36 * @return On success, 0 is returned. On failure, a negative value is returned.
37 */
38 int pwm_close(peripheral_pwm_h pwm);
39
40 /**
41 * @brief pwm_set_period() sets the pwm period.
42 *
43 * @param[in] chip pwm chip number
44 * @param[in] pin pwm pin number
45 * @param[in] period pwm period
46 * @return On success, 0 is returned. On failure, a negative value is returned.
47 */
48 int pwm_set_period(peripheral_pwm_h pwm, int period);
49
50 /**
51 * @brief pwm_set_duty_cycle() sets the pwm duty cycle.
52 *
53 * @param[in] chip pwm chip number
54 * @param[in] pin pwm pin number
55 * @param[in] duty_cycle pwm duty cycle
56 * @return On success, 0 is returned. On failure, a negative value is returned.
57 */
58 int pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle);
59
60 /**
61 * @brief pwm_set_polarity() sets the pwm polarity.
62 *
63 * @param[in] chip pwm chip number
64 * @param[in] pin pwm pin number
65 * @param[in] polarity pwm polarity
66 * @return On success, 0 is returned. On failure, a negative value is returned.
67 */
68 int pwm_set_polarity(peripheral_pwm_h pwm, pwm_polarity_e polarity);
69
70 /**
71 * @brief pwm_set_enable() sets the pwm state.
72 *
73 * @param[in] chip pwm chip number
74 * @param[in] pin pwm pin number
75 * @param[in] enable pwm enable/disabled state value
76 * @return On success, 0 is returned. On failure, a negative value is returned.
77 */
78 int pwm_set_enable(peripheral_pwm_h pwm, bool enable);
79
80 #endif /* __PWM_H__ */