Skip to content

Commit a1a2042

Browse files
committed
add variant file for metro52
1 parent f42bea8 commit a1a2042

File tree

3 files changed

+230
-0
lines changed

3 files changed

+230
-0
lines changed

variants/metro52/pins_arduino.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
This library is free software; you can redistribute it and/or
4+
modify it under the terms of the GNU Lesser General Public
5+
License as published by the Free Software Foundation; either
6+
version 2.1 of the License, or (at your option) any later version.
7+
This library is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10+
See the GNU Lesser General Public License for more details.
11+
You should have received a copy of the GNU Lesser General Public
12+
License along with this library; if not, write to the Free Software
13+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
14+
*/
15+
16+
// API compatibility
17+
#include "variant.h"

variants/metro52/variant.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
Copyright (c) 2016 Sandeep Mistry All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
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+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include "variant.h"
21+
#include "wiring_constants.h"
22+
#include "wiring_digital.h"
23+
#include <nrf.h>
24+
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+
69+
};
70+
71+
void initVariant()
72+
{
73+
// LED1 & LED2
74+
pinMode(PIN_LED1, OUTPUT);
75+
ledOff(PIN_LED1);
76+
77+
pinMode(PIN_LED2, OUTPUT);
78+
ledOff(PIN_LED2);
79+
}
80+

variants/metro52/variant.h

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
Copyright (c) 2016 Sandeep Mistry All right reserved.
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
This library is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
See the GNU Lesser General Public License for more details.
12+
You should have received a copy of the GNU Lesser General Public
13+
License along with this library; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
*/
16+
17+
#ifndef _VARIANT_FEATHER52_
18+
#define _VARIANT_FEATHER52_
19+
20+
/** Master clock frequency */
21+
#define VARIANT_MCK (64000000ul)
22+
23+
/*----------------------------------------------------------------------------
24+
* Headers
25+
*----------------------------------------------------------------------------*/
26+
27+
#include "WVariant.h"
28+
29+
#ifdef __cplusplus
30+
extern "C"
31+
{
32+
#endif // __cplusplus
33+
34+
// Number of pins defined in PinDescription array
35+
#define PINS_COUNT (32u)
36+
#define NUM_DIGITAL_PINS (32u)
37+
#define NUM_ANALOG_INPUTS (8u)
38+
#define NUM_ANALOG_OUTPUTS (0u)
39+
40+
// LEDs
41+
#define PIN_LED1 (17)
42+
#define PIN_LED2 (19)
43+
44+
#define LED_BUILTIN PIN_LED1
45+
#define LED_CONN PIN_LED2
46+
47+
#define LED_RED PIN_LED1
48+
#define LED_BLUE PIN_LED2
49+
50+
#define LED_STATE_ON 1 // State when LED is litted
51+
52+
// Buttons
53+
/*
54+
#define PIN_BUTTON1 (2)
55+
#define PIN_BUTTON2 (3)
56+
#define PIN_BUTTON3 (4)
57+
#define PIN_BUTTON4 (5)
58+
*/
59+
60+
/*
61+
* Analog pins
62+
*/
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)
71+
72+
static const uint8_t A0 = PIN_A0 ;
73+
static const uint8_t A1 = PIN_A1 ;
74+
static const uint8_t A2 = PIN_A2 ;
75+
static const uint8_t A3 = PIN_A3 ;
76+
static const uint8_t A4 = PIN_A4 ;
77+
static const uint8_t A5 = PIN_A5 ;
78+
static const uint8_t A6 = PIN_A6 ;
79+
static const uint8_t A7 = PIN_A7 ;
80+
#define ADC_RESOLUTION 14
81+
82+
// Other pins
83+
#define PIN_AREF (24)
84+
#define PIN_DFU (20)
85+
#define PIN_NFC1 (9)
86+
#define PIN_NFC2 (10)
87+
88+
static const uint8_t AREF = PIN_AREF;
89+
90+
/*
91+
* Serial interfaces
92+
*/
93+
// Serial
94+
#define PIN_SERIAL_RX (8)
95+
#define PIN_SERIAL_TX (6)
96+
97+
/*
98+
* SPI Interfaces
99+
*/
100+
#define SPI_INTERFACES_COUNT 1
101+
102+
#define PIN_SPI_MISO (14)
103+
#define PIN_SPI_MOSI (13)
104+
#define PIN_SPI_SCK (12)
105+
106+
static const uint8_t SS = 18 ;
107+
static const uint8_t MOSI = PIN_SPI_MOSI ;
108+
static const uint8_t MISO = PIN_SPI_MISO ;
109+
static const uint8_t SCK = PIN_SPI_SCK ;
110+
111+
/*
112+
* Wire Interfaces
113+
*/
114+
#define WIRE_INTERFACES_COUNT 1
115+
116+
#define PIN_WIRE_SDA (25u)
117+
#define PIN_WIRE_SCL (26u)
118+
119+
120+
static inline bool isPinValid(uint32_t pin)
121+
{
122+
return (pin < PINS_COUNT) && (pin != PIN_SERIAL_RX) && (pin != PIN_SERIAL_TX);
123+
}
124+
125+
#ifdef __cplusplus
126+
}
127+
#endif
128+
129+
/*----------------------------------------------------------------------------
130+
* Arduino objects - C++ only
131+
*----------------------------------------------------------------------------*/
132+
133+
#endif

0 commit comments

Comments
 (0)