Define C++-compatible pin map for Argon #2187
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The Particle
pinmap_defines.h
headers establish pin IDs likeSCA
with a#define
, meaning that any stand-alone use of the tokenSCA
gets replaced with a number by the preprocessor. Other Arduino-based platforms don't do this. Because of Particle's headers, Particle apps cannot directly use some Arduino libraries that use a token likeSCA
internally, such as:Solution
We should use C++ to establish constants when we're building in C++. This allows library code to safely use tokens like
SCA
without preprocessor interference.Since
pinmap_defines.h
is also used to compile some nRF platform code in C, we unfortunately need to make the pin mappings available through both C and C++ means, whichever we're compiling with. That said, these defines are unlikely to change, to put it mildly, so I think this poses a negligible maintenance burden.This PR offers this change for the Argon platform only (since that's what I'm using for my current project). If we believe that this is overall a good idea, I'm happy to make the change for all headers and platforms.
Steps to Test
Build
device-os/main
withmake PLATFORM=argon
.Completeness