I just pushed up an updated version where I added in duplicates of the digitalWriteFast, digitalToggleFast and digitalReadFast functions, where I added in overloaded functions that either handle by the normal arduino pin number, or by the PinName
I also added a test sketch that touches the 3 LED colors to see if they work. It is setup, that it can be configured to run in the M7 or M4 cores. And tried accessing them by several different name/numbers, to see what maps to what:
#include <RPC.h>
#include <GIGA_digitalWriteFast.h>
Stream *USERIAL = nullptr;
void setup() {
// put your setup code here, to run once:
if (HAL_GetCurrentCPUID() == CM7_CPUID) {
while (!Serial && millis() < 5000) {}
Serial.begin(115200);
Serial.println("\n*** Test Led Pins M7 version ***");
USERIAL = &Serial;
} else {
RPC.begin();
USERIAL = &RPC;
USERIAL->println("\n*** Test Led Pins M4 version ***");
}
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_RED, OUTPUT);
pinMode(86, OUTPUT);
pinMode(87, OUTPUT);
pinMode(88, OUTPUT);
}
void test_pin(const char *name, pin_size_t pin) {
USERIAL->print("Test Pin by number: ");
USERIAL->print(name);
USERIAL->print("(");
USERIAL->print(pin, DEC);
USERIAL->println(")");
for (uint8_t i = 0; i < 2; i++) {
digitalWriteFast(pin, HIGH);
delay(250);
digitalWriteFast(pin, LOW);
delay(250);
}
for (uint8_t i = 0; i < 4; i++) {
digitalToggleFast(pin);
delay(500);
}
digitalWriteFast(pin, HIGH);
}
void test_pin(const char *name, PinName pin) {
USERIAL->print("Test Pin by name: ");
USERIAL->print(name);
USERIAL->print("(");
USERIAL->print(pin, DEC);
USERIAL->println(")");
for (uint8_t i = 0; i < 2; i++) {
digitalWriteFast(pin, HIGH);
delay(250);
digitalWriteFast(pin, LOW);
delay(250);
}
for (uint8_t i = 0; i < 4; i++) {
digitalToggleFast(pin);
delay(500);
}
digitalWriteFast(pin, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
test_pin("LED_BUILTIN", LED_BUILTIN);
test_pin("LED_RED", LED_RED);
test_pin("LED_GREEN", LED_GREEN);
test_pin("LED_BLUE", LED_BLUE);
test_pin("86", 86);
test_pin("87", 87);
test_pin("88", 88);
test_pin("D86", D86);
test_pin("D87", D87);
test_pin("D88", D88);
}
All of the name combinations appears to work fine on the M7 core, but the named
ones like LED_RED do not work on the M4 core, as the variant defined for this is using the mappings for a different board which does not match.
That is the pins for M7 are defined correctly:
PinName LED_RED: 140 Green: 157 Blue: 67
But on the M4 they are currently defined:
PinName LED_RED: 165 Green: 166 Blue: 167
As you can see by debug output:
*** Test Led Pins M4 version ***
Test Pin by number: LED_BUILTIN(87)
Test Pin by name: LED_RED(165)
Test Pin by name: LED_GREEN(166)
Test Pin by name: LED_BLUE(167)
Test Pin by number: 86(86)
Test Pin by number: 87(87)
Test Pin by number: 88(88)
Test Pin by number: D86(86)
Test Pin by number: D87(87)
Test Pin by number: D88(88)