A couple of different ways:
Update pin tables: either directly in their variant or make your own variant.
for example to update MINIMA, go to the variant folder and update variant.cpp.
You will see a table near the start that looks like:
extern "C" const PinMuxCfg_t g_pin_cfg[] = {
{ BSP_IO_PORT_03_PIN_01, P301 }, /* (0) D0 ------------------------- DIGITAL */
{ BSP_IO_PORT_03_PIN_02, P302 }, /* (1) D1 */
{ BSP_IO_PORT_01_PIN_05, P105 }, /* (2) D2 */
{ BSP_IO_PORT_01_PIN_04, P104 }, /* (3) D3~ */
{ BSP_IO_PORT_01_PIN_03, P103 }, /* (4) D4 */
{ BSP_IO_PORT_01_PIN_02, P102 }, /* (5) D5~ */
{ BSP_IO_PORT_01_PIN_06, P106 }, /* (6) D6~ */
{ BSP_IO_PORT_01_PIN_07, P107 }, /* (7) D7 */
{ BSP_IO_PORT_03_PIN_04, P304 }, /* (8) D8 */
{ BSP_IO_PORT_03_PIN_03, P303 }, /* (9) D9~ */
{ BSP_IO_PORT_01_PIN_12, P112 }, /* (10) D10~ */
{ BSP_IO_PORT_01_PIN_09, P109 }, /* (11) D11~ */
{ BSP_IO_PORT_01_PIN_10, P110 }, /* (12) D12 */
{ BSP_IO_PORT_01_PIN_11, P111 }, /* (13) D13 */
{ BSP_IO_PORT_00_PIN_14, P014 }, /* (14) A0 -------------------------- ANALOG */
{ BSP_IO_PORT_00_PIN_00, P000 }, /* (15) A1 */
{ BSP_IO_PORT_00_PIN_01, P001 }, /* (16) A2 */
{ BSP_IO_PORT_00_PIN_02, P002 }, /* (17) A3 */
{ BSP_IO_PORT_01_PIN_01, P101 }, /* (18) A4/SDA */
{ BSP_IO_PORT_01_PIN_00, P100 }, /* (19) A5/SCL */
{ BSP_IO_PORT_05_PIN_00, P500 }, /* (20) Analog voltage measure pin */
{ BSP_IO_PORT_00_PIN_12, P012 }, /* (21) TX LED */
{ BSP_IO_PORT_00_PIN_13, P013 }, /* (22) RX LED */
{ BSP_IO_PORT_05_PIN_01, P501 }, /* (23) TX on SWD connector */
{ BSP_IO_PORT_05_PIN_02, P502 }, /* (24) RX on SWD connector */
{ BSP_IO_PORT_01_PIN_08, P108 }, /* (25) SWDIO */
{ BSP_IO_PORT_03_PIN_00, P300 }, /* (26) SWCLK */
};
Add your new pins at the end.
You then go into the file pinmux.inc and add data for each of the pins.
Note the last pin in table above is P300 - port 3 pin 0
In the pinmux.inc you will find:
const uint16_t P300[] = {
PIN_PWM|CHANNEL_0|PWM_CHANNEL_A|GPT_ODD_CFG|LAST_ITEM_GUARD
};
The section depends on the pins capabilities. And you can hopefully deduce the data from other like pins that are defined.
unwind the calls like digitalWrite:
For example:
pinMode(0. OUTPUT);
digitalWrite(0, HIGH);
Could be replaced by:
R_IOPORT_PinCfg(NULL,BSP_IO_PORT_03_PIN_01,IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PMOS_ENABLE);
R_IOPORT_PinWrite(NULL, BSP_IO_PORT_03_PIN_01, BSP_IO_LEVEL_HIGH);`
Write your own tables and methods:
Combination of the two. - That is create your own table for the added pins,
And duplicate the functions like digitalWrite -> digitalWriteAdded
Where it looks at your table of added pins to then call off to the underlying system.