Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
DriverPWM.h
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/anakod/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  ****/
7 
13 #include "../Wiring/WiringFrameworkDependencies.h"
14 #include "../Wiring/WVector.h"
15 
16 #define PWM_DEPTH 255
17 
18 #ifndef _SMING_CORE_PWM_H_
19 #define _SMING_CORE_PWM_H_
20 
21 class ChannelPWM;
22 
24 class DriverPWM
25 {
26 public:
29  DriverPWM();
30 
34  void initialize();
35 
41  void analogWrite(uint8_t pin, int duty);
42 
46  void noAnalogWrite(uint8_t pin);
47 
49 protected:
50  static void IRAM_ATTR processingStatic(void *arg);
51 
52 private:
53  os_timer_t main;
54  Vector<ChannelPWM> channels;
55  uint32_t period;
56  bool initialized;
57 };
58 
61 {
62 public:
65  ChannelPWM();
66 
70  ChannelPWM(int DriverPWMPin);
71 
74  void initialize();
75 
79  void IRAM_ATTR high();
80 
85  void config(int duty, uint32_t basePeriod);
86 
90  __inline int id() { return pin; }
91 
95  void close();
96 
97 protected:
98  static void IRAM_ATTR processingStatic(void *arg);
99 
100 private:
101  os_timer_t item;
102  int pin;
103  uint32_t time;
104 };
105 
106 // OOP style
113 extern DriverPWM EspPWM;
114 
116 #endif /* _SMING_CORE_PWM_H_ */
Pulse width modulator channel class.
Definition: DriverPWM.h:60
Pulse width modulator driver class.
Definition: DriverPWM.h:24
__inline int id()
Get the GPIO used by this PWM channel.
Definition: DriverPWM.h:90
void analogWrite(uint8_t pin, int duty)
Set PWM output.
DriverPWM EspPWM
Global instance of PWM driver object.
DriverPWM()
PWM driver class.
void initialize()
Initialise PWM driver.
void noAnalogWrite(uint8_t pin)
Disable PWM on GPIO.