PIN Mapping: nrf51 to Arduino

Okay, sorry for this to getting a little bit confusing. I’ve create a project myself using pio init -b nrf51_dk --ide=eclipse. After compiling a test program I realized that it uses the variant.cpp in variants\PCA1000X\variant.cpp with the macro PCA10000 defined… (execute pio settings set force_verbose Yes to see all gcc/g++ build commands).

arm-none-eabi-g++ -o .pioenvs\nrf51_dk\FrameworkArduinoVariant\variant.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -Wall -mthumb -nostdlib -mcpu=cortex-m0 --param max-inline-insns-single=500 -DPLATFORMIO=30502 -DPCA10000 -DARDUINO=10805 -DF_CPU=16000000L -DARDUINO__NRF5 -DNRF5 -DNRF51 -DUSE_LFXO -IC:\Users\Maxi\.platformio\packages\framework-arduinonordicnrf5\cores\nRF5 -IC:\Users\Maxi\.platformio\packages\framework-arduinonordicnrf5\cores\nRF5\SDK\components\drivers_nrf\delay -IC:\Users\Maxi\.platformio\packages\framework-arduinonordicnrf5\cores\nRF5\SDK\components\device -IC:\Users\Maxi\.platformio\packages\framework-arduinonordicnrf5\cores\nRF5\SDK\components\toolchain -IC:\Users\Maxi\.platformio\packages\framework-arduinonordicnrf5\cores\nRF5\SDK\components\toolchain\CMSIS\Include -IC:\Users\Maxi\.platformio\packages\framework-arduinonordicnrf5\variants\PCA1000X C:\Users\Maxi\.platformio\packages\framework-arduinonordicnrf5\variants\PCA1000X\variant.cpp

Initially I just guessed it was the nRF51Dongle variant that was selected, but it’s the PCA1000X that gets selected here. Which means that we’re actually looking at a completely different pin map. Which doesn’t seem to match the board you’ve linked in… Only has 7 digital pins and 0 analog pins, obviously wrong. (see PCA1000X\variant.cpp and PCA1000X\variant.h).

const uint32_t g_ADigitalPinMap[] = {
  8,  // RTS
  9,  // TxD
  10, // CTS
  11, // RxD
  21, // LED Red
  22, // LED Green
  23, // LED Blue
};

@ivankravets, a little help here? The compiled pin definitions in the variant.h/cpp for the nrf51_dk device do not match up with the board (Nordic nRF51-DK | Mbed)?

You can manually manipulate the pin definitions in that map, of course, but I would wait for confirmation and an official fix. And yes, with the pinMode, digitalWrite and digitalRead functions, since it remaps the argument using the g_ADigitalPinMap object, you can only use the pins defined inside that map. Or you duplicate the function like I did above without any checks and remapping present. See if above test sketch works.