Skip to content

Commit d1e86c6

Browse files
committed
update the pin for metro52
1 parent a1a2042 commit d1e86c6

File tree

3 files changed

+92
-77
lines changed

3 files changed

+92
-77
lines changed

variants/feather52/variant.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,16 @@ static const uint8_t SCK = PIN_SPI_SCK ;
119119

120120
static inline bool isPinValid(uint32_t pin)
121121
{
122-
return (pin < PINS_COUNT) && (pin != PIN_SERIAL_RX) && (pin != PIN_SERIAL_TX);
122+
// 0, 1 is xtal
123+
if (pin >= PINS_COUNT) return false;
124+
125+
const uint8_t forbid[] = { 0, 1, };
126+
for(uint8_t i=0; i<sizeof(forbid); i++)
127+
{
128+
if ( pin == forbid[i] ) return false;
129+
}
130+
131+
return true;
123132
}
124133

125134
#ifdef __cplusplus

variants/metro52/variant.cpp

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,52 +22,15 @@
2222
#include "wiring_digital.h"
2323
#include <nrf.h>
2424

25-
const uint32_t g_ADigitalPinMap[] = {
26-
// D0 - D7
27-
0, // xtal 1
28-
1, // xtal 2
29-
2, // a0
30-
3, // a1
31-
4, // a2
32-
5, // a3
33-
6, // TXD
34-
7, // GPIO #7
35-
36-
// D8 - D13
37-
8, // RXD
38-
39-
9, // NFC1
40-
10, // NFC2
41-
42-
11, // GPIO11
43-
44-
12, // SCK
45-
13, // MOSI
46-
14, // MISO
47-
48-
15, // GPIO #15
49-
16, // GPIO #16
50-
51-
// function set pins
52-
17, // LED #1 (red)
53-
18, // SWO
54-
19, // LED #2 (blue)
55-
20, // DFU
56-
21, // Reset
57-
22, // Factory Reset
58-
23, // N/A
59-
24, // N/A
60-
61-
25, // SDA
62-
26, // SCL
63-
27, // GPIO #27
64-
28, // A4
65-
29, // A5
66-
30, // A6
67-
31, // A7
68-
25+
const uint32_t g_ADigitalPinMap[] =
26+
{
27+
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,
28+
8 , 9 , 10 , 11 , 12 , 13 , 14 , 15,
29+
16 , 17 , 18 , 19 , 20 , 21 , 22 , 23,
30+
24 , 25 , 26 , 27 , 28 , 29 , 30 , 31
6931
};
7032

33+
7134
void initVariant()
7235
{
7336
// LED1 & LED2

variants/metro52/variant.h

Lines changed: 75 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1515
*/
1616

17-
#ifndef _VARIANT_FEATHER52_
18-
#define _VARIANT_FEATHER52_
17+
#ifndef _VARIANT_METRO52_
18+
#define _VARIANT_METRO52_
1919

2020
/** Master clock frequency */
2121
#define VARIANT_MCK (64000000ul)
@@ -34,20 +34,55 @@ extern "C"
3434
// Number of pins defined in PinDescription array
3535
#define PINS_COUNT (32u)
3636
#define NUM_DIGITAL_PINS (32u)
37-
#define NUM_ANALOG_INPUTS (8u)
37+
#define NUM_ANALOG_INPUTS (6u)
3838
#define NUM_ANALOG_OUTPUTS (0u)
3939

40-
// LEDs
41-
#define PIN_LED1 (17)
42-
#define PIN_LED2 (19)
40+
/*
41+
* Digital Pins
42+
*/
43+
#define PIN_D0 (23)
44+
#define PIN_D1 (8)
45+
#define PIN_D2 (24)
46+
#define PIN_D3 (20)
47+
#define PIN_D4 (19)
48+
#define PIN_D5 (17)
49+
#define PIN_D6 (16)
50+
#define PIN_D7 (15)
51+
#define PIN_D8 (14)
52+
#define PIN_D9 (13)
53+
#define PIN_D10 (12)
54+
#define PIN_D11 (11)
55+
#define PIN_D12 (28)
56+
#define PIN_D13 (29)
57+
58+
#define D0 PIN_D0
59+
#define D1 PIN_D1
60+
#define D2 PIN_D2
61+
#define D3 PIN_D3
62+
#define D4 PIN_D4
63+
#define D5 PIN_D5
64+
#define D6 PIN_D6
65+
#define D7 PIN_D7
66+
#define D8 PIN_D8
67+
#define D9 PIN_D9
68+
#define D10 PIN_D10
69+
#define D11 PIN_D11
70+
#define D12 PIN_D12
71+
#define D13 PIN_D13
72+
73+
/*
74+
* LEDs
75+
*/
76+
#define PIN_LED1 PIN_D13
77+
#define PIN_LED2 (22)
4378

44-
#define LED_BUILTIN PIN_LED1
45-
#define LED_CONN PIN_LED2
79+
#define LED_BUILTIN PIN_LED1
80+
#define LED_CONN PIN_LED2
4681

47-
#define LED_RED PIN_LED1
48-
#define LED_BLUE PIN_LED2
82+
#define LED_RED PIN_LED1
83+
#define LED_BLUE PIN_LED2
4984

50-
#define LED_STATE_ON 1 // State when LED is litted
85+
#define LED_STATE_ON 1 // State when LED is litted
5186

5287
// Buttons
5388
/*
@@ -60,28 +95,28 @@ extern "C"
6095
/*
6196
* Analog pins
6297
*/
63-
#define PIN_A0 (2)
64-
#define PIN_A1 (3)
65-
#define PIN_A2 (4)
66-
#define PIN_A3 (5)
67-
#define PIN_A4 (28)
68-
#define PIN_A5 (29)
69-
#define PIN_A6 (30)
70-
#define PIN_A7 (31)
98+
#define PIN_A0 (30)
99+
#define PIN_A1 (31)
100+
#define PIN_A2 (2)
101+
#define PIN_A3 (3)
102+
#define PIN_A4 (4)
103+
#define PIN_A5 (5)
104+
//#define PIN_A6 (30)
105+
//#define PIN_A7 (31)
71106

72107
static const uint8_t A0 = PIN_A0 ;
73108
static const uint8_t A1 = PIN_A1 ;
74109
static const uint8_t A2 = PIN_A2 ;
75110
static const uint8_t A3 = PIN_A3 ;
76111
static const uint8_t A4 = PIN_A4 ;
77112
static const uint8_t A5 = PIN_A5 ;
78-
static const uint8_t A6 = PIN_A6 ;
79-
static const uint8_t A7 = PIN_A7 ;
113+
//static const uint8_t A6 = PIN_A6 ;
114+
//static const uint8_t A7 = PIN_A7 ;
80115
#define ADC_RESOLUTION 14
81116

82117
// Other pins
83-
#define PIN_AREF (24)
84-
#define PIN_DFU (20)
118+
#define PIN_AREF (24) // ?
119+
#define PIN_DFU (22) // Mux with LED2
85120
#define PIN_NFC1 (9)
86121
#define PIN_NFC2 (10)
87122

@@ -91,17 +126,17 @@ static const uint8_t AREF = PIN_AREF;
91126
* Serial interfaces
92127
*/
93128
// Serial
94-
#define PIN_SERIAL_RX (8)
95-
#define PIN_SERIAL_TX (6)
129+
#define PIN_SERIAL_RX PIN_D0
130+
#define PIN_SERIAL_TX PIN_D1
96131

97132
/*
98133
* SPI Interfaces
99134
*/
100135
#define SPI_INTERFACES_COUNT 1
101136

102-
#define PIN_SPI_MISO (14)
103-
#define PIN_SPI_MOSI (13)
104-
#define PIN_SPI_SCK (12)
137+
#define PIN_SPI_MISO (27)
138+
#define PIN_SPI_MOSI (25)
139+
#define PIN_SPI_SCK (26)
105140

106141
static const uint8_t SS = 18 ;
107142
static const uint8_t MOSI = PIN_SPI_MOSI ;
@@ -113,13 +148,21 @@ static const uint8_t SCK = PIN_SPI_SCK ;
113148
*/
114149
#define WIRE_INTERFACES_COUNT 1
115150

116-
#define PIN_WIRE_SDA (25u)
117-
#define PIN_WIRE_SCL (26u)
118-
151+
#define PIN_WIRE_SDA (6)
152+
#define PIN_WIRE_SCL (7)
119153

120154
static inline bool isPinValid(uint32_t pin)
121155
{
122-
return (pin < PINS_COUNT) && (pin != PIN_SERIAL_RX) && (pin != PIN_SERIAL_TX);
156+
// 0, 1 is xtal
157+
if (pin >= PINS_COUNT) return false;
158+
159+
const uint8_t forbid[] = { 0, 1, };
160+
for(uint8_t i=0; i<sizeof(forbid); i++)
161+
{
162+
if ( pin == forbid[i] ) return false;
163+
}
164+
165+
return true;
123166
}
124167

125168
#ifdef __cplusplus

0 commit comments

Comments
 (0)