f37b40d619ef9eb40a1cb032327438ee757e9b4a
[platform/core/api/peripheral-io.git] / include / interface / peripheral_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 __PERIPHERAL_INTERFACE_PWM_H__
18 #define __PERIPHERAL_INTERFACE_PWM_H__
19
20 #include "peripheral_interface_common.h"
21
22 /**
23 * @brief pwm_close() deinit pwm pin.
24 *
25 * @param[in] chip pwm chip number
26 * @param[in] pin pwm pin number
27 * @return On success, 0 is returned. On failure, a negative value is returned.
28 */
29 int peripheral_interface_pwm_close(peripheral_pwm_h pwm);
30
31 /**
32 * @brief pwm_set_period() sets the pwm period.
33 *
34 * @param[in] chip pwm chip number
35 * @param[in] pin pwm pin number
36 * @param[in] period pwm period
37 * @return On success, 0 is returned. On failure, a negative value is returned.
38 */
39 int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, uint32_t period);
40
41 /**
42 * @brief pwm_set_duty_cycle() sets the pwm duty cycle.
43 *
44 * @param[in] chip pwm chip number
45 * @param[in] pin pwm pin number
46 * @param[in] duty_cycle pwm duty cycle
47 * @return On success, 0 is returned. On failure, a negative value is returned.
48 */
49 int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle);
50
51 /**
52 * @brief pwm_set_polarity() sets the pwm polarity.
53 *
54 * @param[in] chip pwm chip number
55 * @param[in] pin pwm pin number
56 * @param[in] polarity pwm polarity
57 * @return On success, 0 is returned. On failure, a negative value is returned.
58 */
59 int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity);
60
61 /**
62 * @brief pwm_set_enable() sets the pwm state.
63 *
64 * @param[in] chip pwm chip number
65 * @param[in] pin pwm pin number
66 * @param[in] enable pwm enable/disabled state value
67 * @return On success, 0 is returned. On failure, a negative value is returned.
68 */
69 int peripheral_interface_pwm_set_enable(peripheral_pwm_h pwm, bool enable);
70
71 #endif /* __PERIPHERAL_INTERFACE_PWM_H__ */