Skip to content

Commit 13a01fe

Browse files
committed
change token type from uintptr_t to uint32_t
1 parent 3cc5b5b commit 13a01fe

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

cores/nRF5/HardwarePWM.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ HardwarePWM* HwPWMx[] =
5454
};
5555

5656
#if CFG_DEBUG
57-
bool can_stringify_token(uintptr_t token)
57+
bool can_stringify_token(uint32_t token)
5858
{
5959
uint8_t * t = (uint8_t *)&token;
60-
for (size_t i = 0; i < sizeof(uintptr_t); ++i, ++t)
60+
for (size_t i = 0; i < sizeof(uint32_t); ++i, ++t)
6161
{
6262
uint8_t x = *t;
6363
if ((x < 0x20) || (x > 0x7E)) return false;
@@ -71,7 +71,7 @@ void HardwarePWM::DebugOutput(Stream& logger)
7171
logger.printf("HwPWM Debug:");
7272
for (size_t i = 0; i < count; i++) {
7373
HardwarePWM const * pwm = HwPWMx[i];
74-
uintptr_t token = pwm->_owner_token;
74+
uint32_t token = pwm->_owner_token;
7575
logger.printf(" || %d:", i);
7676
if (can_stringify_token(token)) {
7777
uint8_t * t = (uint8_t*)(&token);
@@ -271,7 +271,7 @@ uint8_t HardwarePWM::freeChannelCount(void) const
271271
}
272272

273273
// returns true ONLY when (1) no PWM channel has a pin, and (2) the owner token is nullptr
274-
bool HardwarePWM::takeOwnership(uintptr_t token)
274+
bool HardwarePWM::takeOwnership(uint32_t token)
275275
{
276276
if (token == 0) {
277277
LOG_LV1("HwPWM", "zero / nullptr is not a valid ownership token (attempted use in takeOwnership)");
@@ -288,12 +288,12 @@ bool HardwarePWM::takeOwnership(uintptr_t token)
288288
if ( this->enabled() ) return false;
289289

290290
// Use C++11 atomic CAS operation
291-
uintptr_t expectedValue = 0U;
291+
uint32_t expectedValue = 0U;
292292
return this->_owner_token.compare_exchange_strong(expectedValue, token);
293293
}
294294

295295
// returns true ONLY when (1) no PWM channel has a pin attached, and (2) the owner token matches
296-
bool HardwarePWM::releaseOwnership(uintptr_t token)
296+
bool HardwarePWM::releaseOwnership(uint32_t token)
297297
{
298298
if (token == 0) {
299299
LOG_LV1("HwPWM", "zero / nullptr is not a valid ownership token (attempted use in releaseOwnership)");

cores/nRF5/HardwarePWM.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class HardwarePWM
5151
private:
5252
enum { MAX_CHANNELS = 4 }; // Max channel per group
5353
NRF_PWM_Type * const _pwm;
54-
std::atomic_uintptr_t _owner_token;
54+
std::atomic_uint32_t _owner_token;
5555

5656
uint16_t _seq0[MAX_CHANNELS];
5757

@@ -70,13 +70,13 @@ class HardwarePWM
7070
// Cooperative ownership sharing
7171

7272
// returns true ONLY when (1) no PWM channel has a pin, and (2) the owner token is nullptr
73-
bool takeOwnership (uintptr_t token);
73+
bool takeOwnership (uint32_t token);
7474

7575
// returns true ONLY when (1) no PWM channel has a pin attached, and (2) the owner token matches
76-
bool releaseOwnership(uintptr_t token);
76+
bool releaseOwnership(uint32_t token);
7777

7878
// allows caller to verify that they own the peripheral
79-
bool isOwner(uintptr_t token) const
79+
bool isOwner(uint32_t token) const
8080
{
8181
return this->_owner_token == token;
8282
}

cores/nRF5/Tone.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static HardwarePWM * const _HwPWM = HwPWMx[2];
4848
// Defined a struct, to simplify validation testing ... also provides context when debugging
4949
class TonePwmConfig {
5050
private:
51-
const uintptr_t toneToken = 0x656e6f54; //< 'T' 'o' 'n' 'e'
51+
const uint32_t toneToken = 0x656e6f54; //< 'T' 'o' 'n' 'e'
5252
uint64_t pulse_count; //< total number of PWM pulses
5353
uint32_t seq0_refresh; //< count of pulses for each SEQ0 iteration
5454
uint32_t seq1_refresh; //< count of pulses for each SEQ1 iteration

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 _analogResolution = 8; // default is 256 levels
50-
static uintptr_t _analogToken = 0x676f6c41; // 'A' 'l' 'o' 'g'
50+
static uint32_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 uintptr_t _servoToken = 0x76726553; // 'S' 'e' 'r' 'v'
24+
static uint32_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)