|
| 1 | +/* |
| 2 | + * Copyright (C) 2024 TU Dresden |
| 3 | + * |
| 4 | + * This file is subject to the terms and conditions of the GNU Lesser |
| 5 | + * General Public License v2.1. See the file LICENSE in the top level |
| 6 | + * directory for more details. |
| 7 | + */ |
| 8 | + |
| 9 | +/** |
| 10 | + * @ingroup boards_seeedstudio-xiao-nrf52840-sense |
| 11 | + * @{ |
| 12 | + * |
| 13 | + * @file |
| 14 | + * @brief Mapping from MCU pins to Arduino pins |
| 15 | + * |
| 16 | + * You can use the defines in this file for simplified interaction with the |
| 17 | + * Arduino specific pin numbers. |
| 18 | + * |
| 19 | + * @author Mikolai Gütschow <[email protected]> |
| 20 | + */ |
| 21 | + |
| 22 | +#ifndef ARDUINO_IOMAP_H |
| 23 | +#define ARDUINO_IOMAP_H |
| 24 | + |
| 25 | +#include "periph/gpio.h" |
| 26 | +#include "periph/adc.h" |
| 27 | + |
| 28 | +#ifdef __cplusplus |
| 29 | +extern "C" { |
| 30 | +#endif |
| 31 | + |
| 32 | +/** |
| 33 | + * @name XIAO's UART devices |
| 34 | + * @{ |
| 35 | + * @brief Arduino's Serial uses USB-CDC-ACM stdio by default |
| 36 | + */ |
| 37 | +#define ARDUINO_UART_DEV UART_UNDEF |
| 38 | +/** @} */ |
| 39 | + |
| 40 | +/** |
| 41 | + * @name XIAO's SPI buses |
| 42 | + * @{ |
| 43 | + */ |
| 44 | +#define ARDUINO_SPI_DEV SPI_DEV(0) |
| 45 | +/** @} */ |
| 46 | + |
| 47 | +/** |
| 48 | + * @name XIAO's I2C buses |
| 49 | + * @{ |
| 50 | + */ |
| 51 | +#define ARDUINO_I2C_DEV I2C_DEV(0) |
| 52 | +/** @} */ |
| 53 | + |
| 54 | +/** |
| 55 | + * @name XIAO's on-board LED (LED_BUILTIN) |
| 56 | + * @{ |
| 57 | + */ |
| 58 | +#define ARDUINO_LED (11) |
| 59 | +/** @} */ |
| 60 | + |
| 61 | +/** |
| 62 | + * @name Mapping of MCU pins to Arduino pins |
| 63 | + * @{ |
| 64 | + */ |
| 65 | +/* Left pins */ |
| 66 | +#define ARDUINO_PIN_0 GPIO_PIN(0, 2) |
| 67 | +#define ARDUINO_PIN_1 GPIO_PIN(0, 3) |
| 68 | +#define ARDUINO_PIN_2 GPIO_PIN(0, 28) |
| 69 | +#define ARDUINO_PIN_3 GPIO_PIN(0, 29) |
| 70 | +#define ARDUINO_PIN_4 GPIO_PIN(0, 4) |
| 71 | +#define ARDUINO_PIN_5 GPIO_PIN(0, 5) |
| 72 | +#define ARDUINO_PIN_6 GPIO_PIN(1, 11) |
| 73 | + |
| 74 | +/* Right side */ |
| 75 | +#define ARDUINO_PIN_7 GPIO_PIN(1, 12) |
| 76 | +#define ARDUINO_PIN_8 GPIO_PIN(1, 13) |
| 77 | +#define ARDUINO_PIN_9 GPIO_PIN(1, 14) |
| 78 | +#define ARDUINO_PIN_10 GPIO_PIN(1, 15) |
| 79 | + |
| 80 | +/* Internal (LEDs) */ |
| 81 | +#define ARDUINO_PIN_11 GPIO_PIN(0, 26) |
| 82 | +#define ARDUINO_PIN_12 GPIO_PIN(0, 6) |
| 83 | +#define ARDUINO_PIN_13 GPIO_PIN(0, 30) |
| 84 | + |
| 85 | +#define ARDUINO_PIN_LAST 13 |
| 86 | +/** @} */ |
| 87 | + |
| 88 | +/** |
| 89 | + * @name Aliases for analog pins |
| 90 | + * @{ |
| 91 | + */ |
| 92 | +#define ARDUINO_PIN_A0 ARDUINO_PIN_0 |
| 93 | +#define ARDUINO_PIN_A1 ARDUINO_PIN_1 |
| 94 | +#define ARDUINO_PIN_A2 ARDUINO_PIN_2 |
| 95 | +#define ARDUINO_PIN_A3 ARDUINO_PIN_3 |
| 96 | +#define ARDUINO_PIN_A4 ARDUINO_PIN_4 |
| 97 | +#define ARDUINO_PIN_A5 ARDUINO_PIN_5 |
| 98 | +/** @} */ |
| 99 | + |
| 100 | +/** |
| 101 | + * @name Mapping of Arduino analog pins to RIOT ADC lines |
| 102 | + * @{ |
| 103 | + */ |
| 104 | +/* The Seeed Studio XIAO nRF52840 has a fixed ADC to GPIO mapping: |
| 105 | + * |
| 106 | + * nRF | MCU pin | Exposed as Arduino pin |
| 107 | + * -----|-----------|----------------------- |
| 108 | + * AIN0 | P0.02 | A0 (D0) |
| 109 | + * AIN1 | P0.03 | A1 (D1) |
| 110 | + * AIN2 | P0.04 | A4 (D4) |
| 111 | + * AIN3 | P0.05 | A5 (D5) |
| 112 | + * AIN4 | P0.28 | A2 (D2) |
| 113 | + * AIN5 | P0.29 | A3 (D3) |
| 114 | + * AIN6 | P0.30 | - (D13) |
| 115 | + * AIN7 | P0.31 | - (-) |
| 116 | + */ |
| 117 | +#define ARDUINO_A0 ADC_LINE(0) |
| 118 | +#define ARDUINO_A1 ADC_LINE(1) |
| 119 | +#define ARDUINO_A2 ADC_LINE(4) |
| 120 | +#define ARDUINO_A3 ADC_LINE(5) |
| 121 | +#define ARDUINO_A4 ADC_LINE(2) |
| 122 | +#define ARDUINO_A5 ADC_LINE(3) |
| 123 | + |
| 124 | +#define ARDUINO_ANALOG_PIN_LAST 5 |
| 125 | +/** @} */ |
| 126 | + |
| 127 | +#ifdef __cplusplus |
| 128 | +} |
| 129 | +#endif |
| 130 | + |
| 131 | +#endif /* ARDUINO_IOMAP_H */ |
| 132 | +/** @} */ |
0 commit comments