1 /**
2  * @file pwm.h
3  * @copyright Copyright (C) 2015-2018 Alibaba Group Holding Limited
4  */
5 
6 #ifndef AOS_HAL_PWM_H
7 #define AOS_HAL_PWM_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /** @addtogroup hal_pwm PWM
14  *  pwm hal API.
15  *
16  *  @{
17  */
18 
19 #include <stdint.h>
20 
21 typedef struct {
22     float    duty_cycle; /**< the pwm duty_cycle */
23     uint32_t freq;       /**< the pwm freq */
24 } pwm_config_t;
25 
26 typedef struct {
27     uint8_t       port;   /**< pwm port */
28     pwm_config_t  config; /**< spi config */
29     void         *priv;   /**< priv data */
30 } pwm_dev_t;
31 
32 /**
33  * Initialises a PWM pin
34  *
35  * @param[in]  pwm  the PWM device
36  *
37  * @return  0 : on success,  otherwise is error
38  */
39 int32_t aos_hal_pwm_init(pwm_dev_t *pwm);
40 
41 /**
42  * Starts Pulse-Width Modulation signal output on a PWM pin
43  *
44  * @param[in]  pwm  the PWM device
45  *
46  * @return  0 : on success,  otherwise is error
47  */
48 int32_t aos_hal_pwm_start(pwm_dev_t *pwm);
49 
50 /**
51  * Stops output on a PWM pin
52  *
53  * @param[in]  pwm  the PWM device
54  *
55  * @return  0 : on success,  otherwise is error
56  */
57 int32_t aos_hal_pwm_stop(pwm_dev_t *pwm);
58 
59 /**
60  * change the para of pwm
61  *
62  * @param[in]  pwm   the PWM device
63  * @param[in]  para  the para of pwm
64  *
65  * @return  0 : on success,  otherwise is error
66  */
67 int32_t aos_hal_pwm_para_chg(pwm_dev_t *pwm, pwm_config_t para);
68 
69 /**
70  * De-initialises an PWM interface, Turns off an PWM hardware interface
71  *
72  * @param[in]  pwm  the interface which should be de-initialised
73  *
74  * @return  0 : on success,  otherwise is error
75  */
76 int32_t aos_hal_pwm_finalize(pwm_dev_t *pwm);
77 
78 /** @} */
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* AOS_HAL_PWM_H */
85 
86