Modifying/Making a variant
If you wanted to do it in an Arduino-like way it would require editing the Arduino Due variant.cpp or copying the making your own variant, say from a copy of the Due, and editing the extern const PinDescription g_APinDescription[]
array to include an entry that matches for PC11.
Example changes
As an experiment I made the following changes to files in the packages/arduino/hardware/sam/1.6.12/variants/arduino_due_x
under the arduino15 directory.
In variant.cpp, an entry for in the g_APinDescription
array is insert an index number 79, between the existing two entries (shown for context):
{ PIOB, PIO_PB23B_SPI0_NPCS3,ID_PIOB,PIO_PERIPH_B,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS3
// Addition line here VVVV (this is the line for PC12, copied with PIO_PC12 changed to PIO_PC11
{ PIOC, PIO_PC11, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, //
// 79 .. 84 - "All pins" masks
// 79 - TWI0 all pins
{ PIOA, PIO_PA17A_TWD0|PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
This is a copy of the entry for PC12, with PIO_PC12
changed to PIO_PC11
.
In variant.h, PINS_COUNT
changes to 80u
, because we've inserted the pin:
#define PINS_COUNT (80u)
and later in the file the pin number associate with CAN are bumped up by one also because they're all numbered after the point of insertion:
/*
* Complementary CAN pins
*/
static const uint8_t CAN1RX = 89;
static const uint8_t CAN1TX = 90;
// CAN0
#define PINS_CAN0 (91u)
// CAN1
#define PINS_CAN1 (92u)
I programmed a sketch the blinks PC11 by way of digitalWrite(79, state);
and carefully placed a logic probe on the the unrouted pin on the Due board, and it "blinks" just fine. That's as far as I've tested.
Direct control
Alternately you could control the pin in your code manually, doing what digitalWrite
or digitalRead
would normally do. In other words, you could read the description of something like digitalWrite here and substitute all of the references that it would have gotten from g_APinDescription
with hard-coded values.