From b0d0e292c9786be6b51bf106aebfff7227894f73 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Wed, 7 Sep 2022 15:19:12 -0700 Subject: [PATCH] Minor - Add number separators (#845) --- cores/rp2040/PolledTimeout.h | 8 ++++---- cores/rp2040/RP2040Support.h | 2 +- cores/rp2040/SerialUSB.cpp | 2 +- cores/rp2040/Tone.cpp | 2 +- cores/rp2040/posix.cpp | 8 ++++---- cores/rp2040/wiring_analog.cpp | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cores/rp2040/PolledTimeout.h b/cores/rp2040/PolledTimeout.h index 32494d8..3551437 100644 --- a/cores/rp2040/PolledTimeout.h +++ b/cores/rp2040/PolledTimeout.h @@ -129,10 +129,10 @@ struct TimeUnit { } }; -using TimeMillis = TimeUnit< TimeSourceMillis, 1000 >; -using TimeFastMillis = TimeUnit< TimeSourceCycles, 1000 >; -using TimeFastMicros = TimeUnit< TimeSourceCycles, 1000000 >; -using TimeFastNanos = TimeUnit< TimeSourceCycles, 1000000000 >; +using TimeMillis = TimeUnit < TimeSourceMillis, 1'000 >; +using TimeFastMillis = TimeUnit < TimeSourceCycles, 1'000 >; +using TimeFastMicros = TimeUnit < TimeSourceCycles, 1'000'000 >; +using TimeFastNanos = TimeUnit < TimeSourceCycles, 1'000'000'000 >; } //TimePolicy diff --git a/cores/rp2040/RP2040Support.h b/cores/rp2040/RP2040Support.h index e78d365..0468e6b 100644 --- a/cores/rp2040/RP2040Support.h +++ b/cores/rp2040/RP2040Support.h @@ -238,7 +238,7 @@ public: // Convert from microseconds to PIO clock cycles static int usToPIOCycles(int us) { // Parenthesis needed to guarantee order of operations to avoid 32bit overflow - return (us * (clock_get_hz(clk_sys) / 1000000)); + return (us * (clock_get_hz(clk_sys) / 1'000'000)); } // Get current clock frequency diff --git a/cores/rp2040/SerialUSB.cpp b/cores/rp2040/SerialUSB.cpp index 932fc31..29beb84 100644 --- a/cores/rp2040/SerialUSB.cpp +++ b/cores/rp2040/SerialUSB.cpp @@ -147,7 +147,7 @@ size_t SerialUSB::write(const uint8_t *buf, size_t length) { tud_task(); tud_cdc_write_flush(); if (!tud_cdc_connected() || - (!tud_cdc_write_available() && time_us_64() > last_avail_time + 1000000 /* 1 second */)) { + (!tud_cdc_write_available() && time_us_64() > last_avail_time + 1'000'000 /* 1 second */)) { break; } } diff --git a/cores/rp2040/Tone.cpp b/cores/rp2040/Tone.cpp index 2fde825..c5fa57e 100644 --- a/cores/rp2040/Tone.cpp +++ b/cores/rp2040/Tone.cpp @@ -62,7 +62,7 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration) { return; // Weird deadlock case } - int us = 1000000 / frequency / 2; + int us = 1'000'000 / frequency / 2; if (us < 5) { us = 5; } diff --git a/cores/rp2040/posix.cpp b/cores/rp2040/posix.cpp index 19564b7..1ee1cc6 100644 --- a/cores/rp2040/posix.cpp +++ b/cores/rp2040/posix.cpp @@ -90,8 +90,8 @@ extern "C" int _gettimeofday(struct timeval *tv, void *tz) { (void) tz; uint64_t now_us = to_us_since_boot(get_absolute_time()) + __timedelta_us; if (tv) { - tv->tv_sec = now_us / 1000000L; - tv->tv_usec = now_us % 1000000L; + tv->tv_sec = now_us / 1'000'000L; + tv->tv_usec = now_us % 1'000'000L; } return 0; } @@ -101,7 +101,7 @@ extern "C" int settimeofday(const struct timeval *tv, const struct timezone *tz) uint64_t now_us = to_us_since_boot(get_absolute_time()); if (tv) { uint64_t newnow_us; - newnow_us = tv->tv_sec * 1000000L; + newnow_us = tv->tv_sec * 1'000'000L; newnow_us += tv->tv_usec; __timedelta_us = newnow_us - now_us; } @@ -111,7 +111,7 @@ extern "C" int settimeofday(const struct timeval *tv, const struct timezone *tz) // For NTP extern "C" void __setSystemTime(unsigned long long sec, unsigned long usec) { uint64_t now_us = to_us_since_boot(get_absolute_time()); - uint64_t newnow_us = sec * 1000000LL + usec; + uint64_t newnow_us = sec * 1'000'000LL + usec; __timedelta_us = newnow_us - now_us; } diff --git a/cores/rp2040/wiring_analog.cpp b/cores/rp2040/wiring_analog.cpp index 35a40f0..afd8027 100644 --- a/cores/rp2040/wiring_analog.cpp +++ b/cores/rp2040/wiring_analog.cpp @@ -42,9 +42,9 @@ extern "C" void analogWriteFreq(uint32_t freq) { if (freq < 100) { DEBUGCORE("ERROR: analogWriteFreq too low (%d)\n", freq); analogFreq = 100; - } else if (freq > 1000000) { + } else if (freq > 1'000'000) { DEBUGCORE("ERROR: analogWriteFreq too high (%d)\n", freq); - analogFreq = 1000000; + analogFreq = 1'000'000; } else { analogFreq = freq; }