|
5 | 5 | Copyright (c) 2018 Earle F. Philhower, III. All rights reserved.
|
6 | 6 |
|
7 | 7 | The core idea is to have a programmable waveform generator with a unique
|
8 |
| - high and low period (defined in microseconds). TIMER1 is set to 1-shot |
9 |
| - mode and is always loaded with the time until the next edge of any live |
10 |
| - waveforms. |
| 8 | + high and low period (defined in microseconds or CPU clock cycles). TIMER1 is |
| 9 | + set to 1-shot mode and is always loaded with the time until the next edge |
| 10 | + of any live waveforms. |
11 | 11 |
|
12 | 12 | Up to one waveform generator per pin supported.
|
13 | 13 |
|
14 |
| - Each waveform generator is synchronized to the ESP cycle counter, not the |
| 14 | + Each waveform generator is synchronized to the ESP clock cycle counter, not the |
15 | 15 | timer. This allows for removing interrupt jitter and delay as the counter
|
16 | 16 | always increments once per 80MHz clock. Changes to a waveform are
|
17 | 17 | contiguous and only take effect on the next waveform transition,
|
18 | 18 | allowing for smooth transitions.
|
19 | 19 |
|
20 | 20 | This replaces older tone(), analogWrite(), and the Servo classes.
|
21 | 21 |
|
22 |
| - Everywhere in the code where "cycles" is used, it means ESP.getCycleTime() |
23 |
| - cycles, not TIMER1 cycles (which may be 2 CPU clocks @ 160MHz). |
| 22 | + Everywhere in the code where "cycles" is used, it means ESP.getCycleCount() |
| 23 | + clock cycle count, or an interval measured in CPU clock cycles, but not TIMER1 |
| 24 | + cycles (which may be 2 CPU clock cycles @ 160MHz). |
24 | 25 |
|
25 | 26 | This library is free software; you can redistribute it and/or
|
26 | 27 | modify it under the terms of the GNU Lesser General Public
|
@@ -50,8 +51,10 @@ extern "C" {
|
50 | 51 | // If runtimeUS > 0 then automatically stop it after that many usecs.
|
51 | 52 | // Returns true or false on success or failure.
|
52 | 53 | int startWaveform(uint8_t pin, uint32_t timeHighUS, uint32_t timeLowUS, uint32_t runTimeUS);
|
53 |
| -// Same as above, but pass in CPU clock cycles instead of microseconds |
54 |
| -int startWaveformCycles(uint8_t pin, uint32_t timeHighCycles, uint32_t timeLowCycles, uint32_t runTimeCycles); |
| 54 | +// Start or change a waveform of the specified high and low CPU clock cycles on specific pin. |
| 55 | +// If runtimeCycles > 0 then automatically stop it after that many CPU clock cycles. |
| 56 | +// Returns true or false on success or failure. |
| 57 | +int startWaveformClockCycles(uint8_t pin, uint32_t timeHighCycles, uint32_t timeLowCycles, uint32_t runTimeCycles); |
55 | 58 | // Stop a waveform, if any, on the specified pin.
|
56 | 59 | // Returns true or false on success or failure.
|
57 | 60 | int stopWaveform(uint8_t pin);
|
|
0 commit comments