Skip to content

Commit e26d8b2

Browse files
committed
Finish conversion back to uintptr_t token
1 parent 61cc471 commit e26d8b2

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

cores/nRF5/HardwarePWM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ HardwarePWM* HwPWMx[] =
5353
#endif
5454
};
5555

56+
#if CFG_DEBUG
5657
bool can_stringify_token(uintptr_t token)
5758
{
5859
uint8_t * t = (uint8_t *)&token;
@@ -91,8 +92,7 @@ void HardwarePWM::DebugOutput(Stream& logger)
9192
}
9293
logger.printf("\n");
9394
}
94-
95-
95+
#endif // CFG_DEBUG
9696

9797
// returns true ONLY when (1) no PWM channel has a pin, and (2) the owner token is nullptr
9898
bool HardwarePWM::takeOwnership(uintptr_t token)

cores/nRF5/HardwarePWM.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,11 @@ class HardwarePWM
7676
bool releaseOwnership(uintptr_t token);
7777

7878
// allows caller to verify that they own the peripheral
79-
__INLINE bool isOwner(uintptr_t token) const __attribute__((__always_inline__))
79+
__INLINE bool isOwner(uintptr_t token) const
80+
__attribute__ ((__always_inline__))
8081
{
8182
return this->_owner_token == token;
8283
}
83-
__INLINE bool takeOwnership (void const * token)
84-
{ return takeOwnership((uintptr_t)token); }
85-
__INLINE bool releaseOwnership(void const * token)
86-
{ return releaseOwnership((uintptr_t)token); }
87-
__INLINE bool isOwner (void const * token) const
88-
__attribute__ ((__always_inline__))
89-
{ return isOwner((uintptr_t)token); }
9084

9185
bool addPin (uint8_t pin);
9286
bool removePin (uint8_t pin);
@@ -122,8 +116,9 @@ class HardwarePWM
122116
uint8_t usedChannelCount() const;
123117
uint8_t freeChannelCount() const;
124118

125-
// for debug/validation
119+
#if CFG_DEBUG
126120
static void DebugOutput(Stream& logger);
121+
#endif // CFG_DEBUG
127122
};
128123

129124
extern HardwarePWM HwPWM0;

cores/nRF5/Tone.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ Version Modified By Date Comments
4141
unsigned long int count_duration=0;
4242
volatile bool no_stop = false;
4343
uint8_t pin_sound=0;
44-
static char const * _toneToken = "Tone";
45-
44+
static uintptr_t _toneToken = 0x656e6f54; // 'T' 'o' 'n' 'e'
4645

4746
void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
4847
{

cores/nRF5/wiring_analog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extern "C"
4747
{
4848

4949
static uint8_t _lastAnalogWriteResolution;
50-
static char const * _analogToken = "analog";
50+
static uintptr_t _analogToken = 0x676f6c41; // 'A' 'l' 'o' 'g'
5151

5252
/**
5353
* This will apply to all PWM Hardware currently used by analogWrite(),

libraries/Servo/src/nrf52/Servo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <Arduino.h>
2222
#include <Servo.h>
2323

24-
static char const * _servoToken = "Servo";
24+
static uintptr_t _servoToken = 0x76726553; // 'S' 'e' 'r' 'v'
2525

2626
static servo_t servos[MAX_SERVOS]; // static array of servo structures
2727
uint8_t ServoCount = 0; // the total number of attached servos

0 commit comments

Comments
 (0)