|
14 | 14 | #warning The Arduino API will use GPIO numbers for this build.
|
15 | 15 | #endif
|
16 | 16 |
|
17 |
| -#if defined(BOARD_HAS_PIN_REMAP) && !defined(BOARD_USES_HW_GPIO_NUMBERS) |
18 |
| - |
19 | 17 | #include "Arduino.h"
|
20 | 18 |
|
21 |
| -static const int8_t TO_GPIO_NUMBER[NUM_DIGITAL_PINS] = { |
22 |
| - [D0] = 44, // RX |
23 |
| - [D1] = 43, // TX |
24 |
| - [D2] = 5, |
25 |
| - [D3] = 6, // CTS |
26 |
| - [D4] = 7, // DSR |
27 |
| - [D5] = 8, |
28 |
| - [D6] = 9, |
29 |
| - [D7] = 10, |
30 |
| - [D8] = 17, |
31 |
| - [D9] = 18, |
32 |
| - [D10] = 21, // SS |
33 |
| - [D11] = 38, // MOSI |
34 |
| - [D12] = 47, // MISO |
35 |
| - [D13] = 48, // SCK, LED_BUILTIN |
36 |
| - [LED_RED] = 46, |
37 |
| - [LED_GREEN] = 0, |
38 |
| - [LED_BLUE] = 45, // RTS |
39 |
| - [A0] = 1, // DTR |
40 |
| - [A1] = 2, |
41 |
| - [A2] = 3, |
42 |
| - [A3] = 4, |
43 |
| - [A4] = 11, // SDA |
44 |
| - [A5] = 12, // SCL |
45 |
| - [A6] = 13, |
46 |
| - [A7] = 14, |
| 19 | +// NOTE: This must match with the remapped pin sequence in pins_arduino.h |
| 20 | +static const int8_t TO_GPIO_NUMBER[] = { |
| 21 | + 44, // [ 0] D0, RX |
| 22 | + 43, // [ 1] D1, TX |
| 23 | + 5, // [ 2] D2 |
| 24 | + 6, // [ 3] D3, CTS |
| 25 | + 7, // [ 4] D4, DSR |
| 26 | + 8, // [ 5] D5 |
| 27 | + 9, // [ 6] D6 |
| 28 | + 10, // [ 7] D7 |
| 29 | + 17, // [ 8] D8 |
| 30 | + 18, // [ 9] D9 |
| 31 | + 21, // [10] D10, SS |
| 32 | + 38, // [11] D11, MOSI |
| 33 | + 47, // [12] D12, MISO |
| 34 | + 48, // [13] D13, SCK, LED_BUILTIN |
| 35 | + 46, // [14] LED_RED |
| 36 | + 0, // [15] LED_GREEN |
| 37 | + 45, // [16] LED_BLUE, RTS |
| 38 | + 1, // [17] A0, DTR |
| 39 | + 2, // [18] A1 |
| 40 | + 3, // [19] A2 |
| 41 | + 4, // [20] A3 |
| 42 | + 11, // [21] A4, SDA |
| 43 | + 12, // [22] A5, SCL |
| 44 | + 13, // [23] A6 |
| 45 | + 14, // [24] A7 |
47 | 46 | };
|
48 | 47 |
|
| 48 | +void _nano_nora_reset_gpio_matrix(void) |
| 49 | +{ |
| 50 | + // In this core file pin mapping is _not_ applied, so the API is |
| 51 | + // always GPIO-based, but the constants can be either. |
| 52 | + for (int pin = 0; pin < sizeof(TO_GPIO_NUMBER); ++pin) { |
| 53 | + int gpio = TO_GPIO_NUMBER[pin]; |
| 54 | +#if defined(BOARD_HAS_PIN_REMAP) && !defined(BOARD_USES_HW_GPIO_NUMBERS) |
| 55 | + // Pin remapping in effect, constants = indexes |
| 56 | + switch (pin) { |
| 57 | +#else |
| 58 | + // Pin remapping disabled, constants = GPIO numbers |
| 59 | + switch (gpio) { |
| 60 | +#endif |
| 61 | + case LED_RED: |
| 62 | + case LED_GREEN: |
| 63 | + case LED_BLUE: |
| 64 | + // set RGB pins to dig outputs, HIGH=off |
| 65 | + pinMode(gpio, OUTPUT); |
| 66 | + digitalWrite(gpio, HIGH); |
| 67 | + break; |
| 68 | + |
| 69 | + case TX: |
| 70 | + case RX: |
| 71 | + // leave UART pins alone |
| 72 | + break; |
| 73 | + |
| 74 | + default: |
| 75 | + // initialize other pins to dig inputs |
| 76 | + pinMode(gpio, INPUT); |
| 77 | + break; |
| 78 | + } |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +#if defined(BOARD_HAS_PIN_REMAP) && !defined(BOARD_USES_HW_GPIO_NUMBERS) |
| 83 | + |
49 | 84 | int8_t digitalPinToGPIONumber(int8_t digitalPin)
|
50 | 85 | {
|
51 | 86 | if ((digitalPin < 0) || (digitalPin >= NUM_DIGITAL_PINS))
|
|
0 commit comments