From 0acacf67b813c7689ccb2113d88e5f806518d57e Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Sun, 10 May 2020 18:52:54 -0700 Subject: [PATCH] Finish conversion back to `uintptr_t` token --- cores/nRF5/HardwarePWM.cpp | 4 ++-- cores/nRF5/HardwarePWM.h | 13 ++++--------- cores/nRF5/Tone.cpp | 3 +-- cores/nRF5/wiring_analog.cpp | 2 +- libraries/Servo/src/nrf52/Servo.cpp | 2 +- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/cores/nRF5/HardwarePWM.cpp b/cores/nRF5/HardwarePWM.cpp index 6c354fb0..bf68dcb7 100644 --- a/cores/nRF5/HardwarePWM.cpp +++ b/cores/nRF5/HardwarePWM.cpp @@ -53,6 +53,7 @@ HardwarePWM* HwPWMx[] = #endif }; +#if CFG_DEBUG bool can_stringify_token(uintptr_t token) { uint8_t * t = (uint8_t *)&token; @@ -91,8 +92,7 @@ void HardwarePWM::DebugOutput(Stream& logger) } logger.printf("\n"); } - - +#endif // CFG_DEBUG // returns true ONLY when (1) no PWM channel has a pin, and (2) the owner token is nullptr bool HardwarePWM::takeOwnership(uintptr_t token) diff --git a/cores/nRF5/HardwarePWM.h b/cores/nRF5/HardwarePWM.h index 7457d164..fbf9a672 100644 --- a/cores/nRF5/HardwarePWM.h +++ b/cores/nRF5/HardwarePWM.h @@ -76,17 +76,11 @@ class HardwarePWM bool releaseOwnership(uintptr_t token); // allows caller to verify that they own the peripheral - __INLINE bool isOwner(uintptr_t token) const __attribute__((__always_inline__)) + __INLINE bool isOwner(uintptr_t token) const + __attribute__ ((__always_inline__)) { return this->_owner_token == token; } - __INLINE bool takeOwnership (void const * token) - { return takeOwnership((uintptr_t)token); } - __INLINE bool releaseOwnership(void const * token) - { return releaseOwnership((uintptr_t)token); } - __INLINE bool isOwner (void const * token) const - __attribute__ ((__always_inline__)) - { return isOwner((uintptr_t)token); } bool addPin (uint8_t pin); bool removePin (uint8_t pin); @@ -122,8 +116,9 @@ class HardwarePWM uint8_t usedChannelCount() const; uint8_t freeChannelCount() const; - // for debug/validation +#if CFG_DEBUG static void DebugOutput(Stream& logger); +#endif // CFG_DEBUG }; extern HardwarePWM HwPWM0; diff --git a/cores/nRF5/Tone.cpp b/cores/nRF5/Tone.cpp index 30b6eacf..ed70680e 100644 --- a/cores/nRF5/Tone.cpp +++ b/cores/nRF5/Tone.cpp @@ -41,8 +41,7 @@ Version Modified By Date Comments unsigned long int count_duration=0; volatile bool no_stop = false; uint8_t pin_sound=0; -static char const * _toneToken = "Tone"; - +static uintptr_t _toneToken = 0x656e6f54; // 'T' 'o' 'n' 'e' void tone(uint8_t pin, unsigned int frequency, unsigned long duration) { diff --git a/cores/nRF5/wiring_analog.cpp b/cores/nRF5/wiring_analog.cpp index 79ccf408..3d2aadb7 100644 --- a/cores/nRF5/wiring_analog.cpp +++ b/cores/nRF5/wiring_analog.cpp @@ -47,7 +47,7 @@ extern "C" { static uint8_t _lastAnalogWriteResolution; -static char const * _analogToken = "analog"; +static uintptr_t _analogToken = 0x676f6c41; // 'A' 'l' 'o' 'g' /** * This will apply to all PWM Hardware currently used by analogWrite(), diff --git a/libraries/Servo/src/nrf52/Servo.cpp b/libraries/Servo/src/nrf52/Servo.cpp index adbcf455..0d4f6b16 100644 --- a/libraries/Servo/src/nrf52/Servo.cpp +++ b/libraries/Servo/src/nrf52/Servo.cpp @@ -21,7 +21,7 @@ #include #include -static char const * _servoToken = "Servo"; +static uintptr_t _servoToken = 0x76726553; // 'S' 'e' 'r' 'v' static servo_t servos[MAX_SERVOS]; // static array of servo structures uint8_t ServoCount = 0; // the total number of attached servos