summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-04-09 09:49:29 +1000
committerDamien George <damien.p.george@gmail.com>2020-04-09 16:23:34 +1000
commitd6f80963df501766fdb120069445f08b9d6165be (patch)
tree58a5b3f756fd1a66cf19e85ff93a5e0850ee7ff4
parente292296d52800939e70513e33ec456518330c4ad (diff)
esp32/espneopixel: Use integer arithmetic to compute timing values.
-rw-r--r--ports/esp32/espneopixel.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ports/esp32/espneopixel.c b/ports/esp32/espneopixel.c
index 1736e2a46..bcdf38873 100644
--- a/ports/esp32/espneopixel.c
+++ b/ports/esp32/espneopixel.c
@@ -20,18 +20,18 @@ void IRAM_ATTR esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32_t numByte
mask = 0x80;
startTime = 0;
- uint32_t fcpu = ets_get_cpu_frequency() * 1000000;
+ uint32_t fcpu = ets_get_cpu_frequency();
if (timing == 1) {
// 800 KHz
- time0 = (fcpu * 0.35) / 1000000; // 0.35us
- time1 = (fcpu * 0.8) / 1000000; // 0.8us
- period = (fcpu * 1.25) / 1000000; // 1.25us per bit
+ time0 = (fcpu * 350) / 1000; // 0.35us
+ time1 = (fcpu * 800) / 1000; // 0.8us
+ period = (fcpu * 1250) / 1000; // 1.25us per bit
} else {
// 400 KHz
- time0 = (fcpu * 0.5) / 1000000; // 0.35us
- time1 = (fcpu * 1.2) / 1000000; // 0.8us
- period = (fcpu * 2.5) / 1000000; // 1.25us per bit
+ time0 = (fcpu * 500) / 1000; // 0.5us
+ time1 = (fcpu * 1200) / 1000; // 1.2us
+ period = (fcpu * 2500) / 1000; // 2.5us per bit
}
uint32_t irq_state = mp_hal_quiet_timing_enter();