|
Open Model Railroad Network (OpenMRN)
|
Single-channel PWM implementation for the ESP8266 that uses the hardware timer resource. More...
#include <TimerBasedPwm.hxx>
Public Member Functions | |
| void | enable () |
| Turns on the PWM. | |
| void ICACHE_RAM_ATTR | owned_isr_handler () |
| interrupt handler (to be called with a this pointer externally stored). | |
| void | set_off () |
| Turns off the previous output that may have been running. | |
| void | old_set_state (int pin, long long nsec_period, long long nsec_on) |
| Enables the PWM on a specific pin. | |
| void | pause (long long nsec_pause) |
| Pauses updating the PWM for a certain amount of time. | |
| void | set_state (int pin, long long nsec_period, long long nsec_on) |
| Sets the PWM parameters. | |
Static Public Member Functions | |
| static void ICACHE_RAM_ATTR | isr_handler (void *) |
| Interrupt handler. | |
| static void ICACHE_RAM_ATTR | new_isr_handler (void *) |
| New implementation of the interrupt handler. | |
Static Private Attributes | |
| static uint32_t | gpioValue_ = 0 |
| Bit-shifted value to send to the GPIO output port. | |
| static uint32_t | clockOn_ |
| How many clock cycles we should wait after switching ON before swithing OFF. | |
| static uint32_t | clockOff_ |
| How many clock cycles we should wait after switching OFF before swithing ON. | |
| static bool | isOn_ |
| 1 if output is currently on, 0 if it is off. | |
Single-channel PWM implementation for the ESP8266 that uses the hardware timer resource.
It is very efficient and can support even 20 kHz PWM frequency.
Definition at line 46 of file TimerBasedPwm.hxx.
|
inline |
Definition at line 48 of file TimerBasedPwm.hxx.
|
inline |
Turns on the PWM.
Definition at line 52 of file TimerBasedPwm.hxx.
|
inlinestatic |
Interrupt handler.
Definition at line 62 of file TimerBasedPwm.hxx.
|
inlinestatic |
New implementation of the interrupt handler.
Definition at line 146 of file TimerBasedPwm.hxx.
|
inline |
Enables the PWM on a specific pin.
| pin | is the GPIO number of the pin (0..15) |
| nsec_period | is the total period length of the output |
| nsec_on | is the time for which the output shall be turned on |
Definition at line 96 of file TimerBasedPwm.hxx.
|
inline |
interrupt handler (to be called with a this pointer externally stored).
Definition at line 67 of file TimerBasedPwm.hxx.
|
inline |
Pauses updating the PWM for a certain amount of time.
After this function returns the output pins are guaranteed to not be modified for the given amount of time. After the pause the PWM will continue, but whether with low or high is unspecified.
Calling set_state immediately cancels the pause.
| nsec_pause | pause (in nanoseconds) to do. Maximum value is 104 msec |
Definition at line 135 of file TimerBasedPwm.hxx.
|
inline |
Turns off the previous output that may have been running.
Call set_state to revert.
Definition at line 83 of file TimerBasedPwm.hxx.
|
inline |
Sets the PWM parameters.
| pin | pin number to PWM. |
| nsec_period | what is the period time of the PWM signal |
| nsec_on | how much the signal should be HIGH within the period. |
Definition at line 168 of file TimerBasedPwm.hxx.
|
staticprivate |
How many clock cycles we should wait after switching OFF before swithing ON.
Definition at line 198 of file TimerBasedPwm.hxx.
|
staticprivate |
How many clock cycles we should wait after switching ON before swithing OFF.
Definition at line 195 of file TimerBasedPwm.hxx.
|
staticprivate |
Bit-shifted value to send to the GPIO output port.
Definition at line 192 of file TimerBasedPwm.hxx.
|
staticprivate |
1 if output is currently on, 0 if it is off.
Definition at line 200 of file TimerBasedPwm.hxx.