Skip to content

Commit 93c7057

Browse files
committed
add metro variant
1 parent 269d168 commit 93c7057

File tree

6 files changed

+256
-10
lines changed

6 files changed

+256
-10
lines changed

variants/feather_nrf52840_express/variant.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ const uint32_t g_ADigitalPinMap[] =
6868

6969
// P1
7070
33, 34, 35, 36, 37, 38, 39,
71-
40, 41, 42, 43, 44, 45, 46, 47,
72-
48, 49, 50, 51, 52, 53, 54, 55,
73-
56, 57, 58, 59, 60, 61, 62, 63
71+
40, 41, 42, 43, 44, 45, 46, 47
7472
};
7573

7674
void initVariant()

variants/feather_nrf52840_express/variant.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ extern "C"
3737
#endif // __cplusplus
3838

3939
// Number of pins defined in PinDescription array
40-
#define PINS_COUNT (64)
41-
#define NUM_DIGITAL_PINS (64)
40+
#define PINS_COUNT (48)
41+
#define NUM_DIGITAL_PINS (48)
4242
#define NUM_ANALOG_INPUTS (6)
4343
#define NUM_ANALOG_OUTPUTS (0)
4444

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
Copyright (c) 2016 Sandeep Mistry All right reserved.
4+
Copyright (c) 2018, Adafruit Industries (adafruit.com)
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
See the GNU Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#include "variant.h"
22+
#include "wiring_constants.h"
23+
#include "wiring_digital.h"
24+
#include "nrf.h"
25+
26+
#include "usb.h"
27+
#include "flash/flash_qspi.h"
28+
29+
#define _PINNUM(port, pin) ((port)*32 + (pin))
30+
31+
const uint32_t g_ADigitalPinMap[] =
32+
{
33+
_PINNUM(0, 25), // D0 is UART TX on P0.25
34+
_PINNUM(0, 24), // D1 is UART RX on P0.24
35+
_PINNUM(1, 10), // D2 is on P1.10
36+
_PINNUM(1, 4 ), // D3 on P1.04
37+
_PINNUM(1, 11), // D4 on P1.11
38+
_PINNUM(1, 12), // D5 on P1.12
39+
_PINNUM(1, 14), // D6 on P1.14
40+
_PINNUM(0, 26), // D7 on P0.26
41+
_PINNUM(0, 27), // D8 on P0.27
42+
_PINNUM(0, 12), // D9 on P0.12
43+
_PINNUM(0, 6 ), // D10 on P0.06
44+
_PINNUM(0, 8 ), // D11 on P0.08
45+
_PINNUM(1, 9 ), // D12 on P1.09
46+
_PINNUM(0, 14), // D13 on P0.14
47+
48+
_PINNUM(0, 4 ), // D14 is A0 on P0.04
49+
_PINNUM(0, 5 ), // D15 is A1 on P0.05
50+
_PINNUM(0, 28), // D16 is A2 on P0.28
51+
_PINNUM(0, 30), // D17 is A3 on P0.30
52+
_PINNUM(0, 2 ), // D18 is A4 on P0.02
53+
_PINNUM(0, 3 ), // D19 is A5 on P0.03
54+
_PINNUM(0, 29), // D20 is A6 (Battery) on P0.29
55+
_PINNUM(0, 31), // D21 is A7 (ARef) on P0.31
56+
57+
_PINNUM(0, 15), // D22 is SDA on P0.15
58+
_PINNUM(0, 16), // D23 is SCL on P0.16
59+
60+
_PINNUM(0, 11), // D24 is SPI MISO on P0.11
61+
_PINNUM(1, 8 ), // D25 is SPI MOSI on P1.08
62+
_PINNUM(0, 7 ), // D26 is SPI SCK on P0.07
63+
64+
_PINNUM(0, 19), // D27 is QSPI CLK on P0.19
65+
_PINNUM(0, 20), // D28 is QSPI CS on P0.20
66+
_PINNUM(0, 17), // D29 is QSPI Data 0 on P0.17
67+
_PINNUM(0, 23), // D30 is QSPI Data 1 on P0.23
68+
_PINNUM(0, 22), // D31 is QSPI Data 2 on P0.22
69+
_PINNUM(0, 21), // D32 is QSPI Data 3 on P0.21
70+
71+
_PINNUM(1, 13), // D33 is LED1 on P1.13
72+
_PINNUM(1, 15), // D34 is LED2 on P1.15
73+
_PINNUM(0, 13), // D35 is NeoPixel on P0.13
74+
_PINNUM(1, 2 ), // D36 is Switch on P1.02
75+
_PINNUM(1, 0 ), // D37 is SWO/DFU on P1.00
76+
_PINNUM(0, 9 ), // D38 is NFC1 on P0.09
77+
_PINNUM(0, 10), // D39 is NFC2 on P0.10
78+
79+
// Unused pin
80+
40, 41, 42, 43, 44, 45, 46, 47
81+
};
82+
83+
84+
85+
void initVariant()
86+
{
87+
// LED1 & LED2
88+
pinMode(PIN_LED1, OUTPUT);
89+
ledOff(PIN_LED1);
90+
91+
pinMode(PIN_LED2, OUTPUT);
92+
ledOff(PIN_LED2);
93+
94+
#if 0 // disable QSPI flash for now
95+
// Init External Flash
96+
flash_qspi_init();
97+
#endif
98+
99+
100+
// USB init
101+
usb_init();
102+
}
103+
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
Copyright (c) 2016 Sandeep Mistry All right reserved.
4+
Copyright (c) 2018, Adafruit Industries (adafruit.com)
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
See the GNU Lesser General Public License for more details.
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#ifndef _VARIANT_METRO52840
20+
#define _VARIANT_METRO52840
21+
22+
/** Master clock frequency */
23+
#define VARIANT_MCK (64000000ul)
24+
25+
#define USE_LFXO // Board uses 32khz crystal for LF
26+
// define USE_LFRC // Board uses RC for LF
27+
28+
/*----------------------------------------------------------------------------
29+
* Headers
30+
*----------------------------------------------------------------------------*/
31+
32+
#include "WVariant.h"
33+
34+
#ifdef __cplusplus
35+
extern "C"
36+
{
37+
#endif // __cplusplus
38+
39+
// Number of pins defined in PinDescription array
40+
#define PINS_COUNT (48)
41+
#define NUM_DIGITAL_PINS (48)
42+
#define NUM_ANALOG_INPUTS (6)
43+
#define NUM_ANALOG_OUTPUTS (0)
44+
45+
// LEDs
46+
#define PIN_LED1 (33)
47+
#define PIN_LED2 (34)
48+
#define PIN_NEOPIXEL (35)
49+
50+
#define LED_BUILTIN PIN_LED1
51+
#define LED_CONN PIN_LED2
52+
53+
#define LED_RED PIN_LED1
54+
#define LED_BLUE PIN_LED2
55+
56+
#define LED_STATE_ON 1 // State when LED is litted
57+
58+
// Buttons
59+
/*
60+
#define PIN_BUTTON1 (2)
61+
#define PIN_BUTTON2 (3)
62+
#define PIN_BUTTON3 (4)
63+
#define PIN_BUTTON4 (5)
64+
*/
65+
66+
/*
67+
* Analog pins
68+
*/
69+
#define PIN_A0 (14)
70+
#define PIN_A1 (15)
71+
#define PIN_A2 (16)
72+
#define PIN_A3 (17)
73+
#define PIN_A4 (18)
74+
#define PIN_A5 (19)
75+
#define PIN_A6 (20)
76+
#define PIN_A7 (21)
77+
78+
static const uint8_t A0 = PIN_A0 ;
79+
static const uint8_t A1 = PIN_A1 ;
80+
static const uint8_t A2 = PIN_A2 ;
81+
static const uint8_t A3 = PIN_A3 ;
82+
static const uint8_t A4 = PIN_A4 ;
83+
static const uint8_t A5 = PIN_A5 ;
84+
static const uint8_t A6 = PIN_A6 ;
85+
static const uint8_t A7 = PIN_A7 ;
86+
#define ADC_RESOLUTION 14
87+
88+
// Other pins
89+
#define PIN_AREF (PIN_A7)
90+
#define PIN_DFU (7)
91+
#define PIN_NFC1 (2)
92+
#define PIN_NFC2 (51)
93+
94+
static const uint8_t AREF = PIN_AREF;
95+
96+
/*
97+
* Serial interfaces
98+
*/
99+
// Serial
100+
#define PIN_SERIAL_RX (1)
101+
#define PIN_SERIAL_TX (0)
102+
103+
/*
104+
* SPI Interfaces
105+
*/
106+
#define SPI_INTERFACES_COUNT 1
107+
108+
#define PIN_SPI_MISO (24)
109+
#define PIN_SPI_MOSI (25)
110+
#define PIN_SPI_SCK (26)
111+
112+
static const uint8_t SS = (5);
113+
static const uint8_t MOSI = PIN_SPI_MOSI ;
114+
static const uint8_t MISO = PIN_SPI_MISO ;
115+
static const uint8_t SCK = PIN_SPI_SCK ;
116+
117+
/*
118+
* Wire Interfaces
119+
*/
120+
#define WIRE_INTERFACES_COUNT 1
121+
122+
#define PIN_WIRE_SDA (22)
123+
#define PIN_WIRE_SCL (23)
124+
125+
/*
126+
* QSPI interface for external flash
127+
*/
128+
#define PIN_QSPI_SCK 27
129+
#define PIN_QSPI_CS 28
130+
#define PIN_QSPI_DATA0 29
131+
#define PIN_QSPI_DATA1 30
132+
#define PIN_QSPI_DATA2 31
133+
#define PIN_QSPI_DATA3 32
134+
135+
// On-board QSPI Flash
136+
// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used
137+
#define EXTERNAL_FLASH_DEVICES GD25Q16C
138+
139+
#ifdef __cplusplus
140+
}
141+
#endif
142+
143+
/*----------------------------------------------------------------------------
144+
* Arduino objects - C++ only
145+
*----------------------------------------------------------------------------*/
146+
147+
#endif

variants/pca10056/variant.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ const uint32_t g_ADigitalPinMap[] =
3636

3737
// P1
3838
32, 33, 34, 35, 36, 37, 38, 39,
39-
40, 41, 42, 43, 44, 45, 46, 47,
40-
48, 49, 50, 51, 52, 53, 54, 55,
41-
56, 57, 58, 59, 60, 61, 62, 63
39+
40, 41, 42, 43, 44, 45, 46, 47
4240
};
4341

4442

variants/pca10056/variant.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ extern "C"
3737
#endif // __cplusplus
3838

3939
// Number of pins defined in PinDescription array
40-
#define PINS_COUNT (64)
41-
#define NUM_DIGITAL_PINS (64)
40+
#define PINS_COUNT (48)
41+
#define NUM_DIGITAL_PINS (48)
4242
#define NUM_ANALOG_INPUTS (6)
4343
#define NUM_ANALOG_OUTPUTS (0)
4444

0 commit comments

Comments
 (0)