Esp8266/Components/esp8266/include/pwm.h
Go to the documentation of this file.
1 /*
2  * ESPRESSIF MIT License
3  *
4  * Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5  *
6  * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
7  * it is free of charge, to any person obtaining a copy of this software and associated
8  * documentation files (the "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11  * to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or
14  * substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  */
24 
25 #pragma once
26 
27 #include <c_types.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*pwm.h: function and macro definition of PWM API , driver level */
34 /*user_light.h: user interface for light API, user level*/
35 /*user_light_adj: API for color changing and lighting effects, user level*/
36 
37 /*SUPPORT UP TO 8 PWM CHANNEL*/
38 #define PWM_CHANNEL_NUM_MAX 8
39 
40 struct pwm_param {
41  uint32_t period;
42  uint32_t freq;
43  uint32_t duty[PWM_CHANNEL_NUM_MAX]; //PWM_CHANNEL<=8
44 };
45 
46 /* pwm_init should be called only once, for now */
47 void pwm_init(uint32_t period, uint32_t* duty, uint32_t pwm_channel_num, uint32_t (*pin_info_list)[3]);
48 void pwm_start(void);
49 
50 void pwm_set_duty(uint32_t duty, uint8_t channel);
51 uint32_t pwm_get_duty(uint8_t channel);
52 void pwm_set_period(uint32_t period);
53 uint32_t pwm_get_period(void);
54 
55 uint32_t get_pwm_version(void);
56 void set_pwm_debug_en(uint8_t print_en);
57 
58 #ifdef __cplusplus
59 }
60 #endif
Definition: Esp8266/Components/esp8266/include/pwm.h:40
uint32_t pwm_get_duty(uint8_t channel)
Get duty cycle of PWM output.
void pwm_set_duty(uint32_t duty, uint8_t channel)
Sets duty cycle of a PWM output.
void pwm_start(void)
Starts PWM.
uint32_t freq
Definition: Esp8266/Components/esp8266/include/pwm.h:42
uint32_t period
Definition: Esp8266/Components/esp8266/include/pwm.h:41
uint32_t get_pwm_version(void)
Get version information of PWM.
uint32_t pwm_get_period(void)
Get PWM period.
void pwm_init(uint32_t period, uint32_t *duty, uint32_t pwm_channel_num, uint32_t(*pin_info_list)[3])
Initialize PWM function, including GPIO selection, period and duty cycle.
#define PWM_CHANNEL_NUM_MAX
Definition: Esp8266/Components/esp8266/include/pwm.h:38
uint32_t duty[PWM_CHANNEL_NUM_MAX]
Definition: Esp8266/Components/esp8266/include/pwm.h:43
void pwm_set_period(uint32_t period)
Set PWM period.
void set_pwm_debug_en(uint8_t print_en)