Skip to content

Commit 9bb2a39

Browse files
committed
Variant file make up
1 parent c216d9e commit 9bb2a39

File tree

1 file changed

+49
-57
lines changed

1 file changed

+49
-57
lines changed

variants/mkr1000/variant.h

Lines changed: 49 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,39 @@
1818

1919
#pragma once
2020

21-
#include "WVariant.h"
21+
// The definitions here needs a SAMD core >=1.6.3
22+
#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10603
2223

23-
/*----------------------------------------------------------------------------
24-
* Definitions
25-
*----------------------------------------------------------------------------*/
24+
#include <WVariant.h>
25+
26+
// General definitions
27+
// -------------------
2628

2729
// Frequency of the board main oscillator
2830
#define VARIANT_MAINOSC (32768ul)
2931

3032
// Master clock frequency
3133
#define VARIANT_MCK (48000000ul)
3234

33-
//#ifdef __cplusplus
34-
//extern "C"
35-
//{
36-
//#endif // __cplusplus
37-
38-
/*----------------------------------------------------------------------------
39-
* Pins
40-
*----------------------------------------------------------------------------*/
35+
// Pins
36+
// ----
4137

4238
// Number of pins defined in PinDescription array
4339
#define PINS_COUNT (26u)
4440
#define NUM_DIGITAL_PINS (15u)
4541
#define NUM_ANALOG_INPUTS (7u)
4642
#define NUM_ANALOG_OUTPUTS (1u)
4743

48-
#define digitalPinToPort(P) (&(PORT->Group[g_APinDescription[P].ulPort]))
49-
#define digitalPinToBitMask(P) (1 << g_APinDescription[P].ulPin)
50-
//#define analogInPinToBit(P) ()
51-
#define portOutputRegister(port) (&(port->OUT.reg))
52-
#define portInputRegister(port) (&(port->IN.reg))
53-
#define portModeRegister(port) (&(port->DIR.reg))
54-
#define digitalPinHasPWM(P) (g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER)
55-
#define digitalPinToInterrupt(P) (g_APinDescription[P].ulExtInt)
44+
// Low-level pin register query macros
45+
// -----------------------------------
46+
#define digitalPinToPort(P) (&(PORT->Group[g_APinDescription[P].ulPort]))
47+
#define digitalPinToBitMask(P) (1 << g_APinDescription[P].ulPin)
48+
//#define analogInPinToBit(P) ()
49+
#define portOutputRegister(port) (&(port->OUT.reg))
50+
#define portInputRegister(port) (&(port->IN.reg))
51+
#define portModeRegister(port) (&(port->DIR.reg))
52+
#define digitalPinHasPWM(P) (g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER)
53+
#define digitalPinToInterrupt(P) (g_APinDescription[P].ulExtInt)
5654

5755
/*
5856
* digitalPinToTimer(..) is AVR-specific and is not defined for SAMD
@@ -63,55 +61,54 @@
6361
*/
6462
// #define digitalPinToTimer(P)
6563

66-
6764
// LEDs
6865
// ----
69-
#define PIN_LED (7u)
70-
#define LED_BUILTIN PIN_LED
66+
#define PIN_LED (7u)
67+
#define LED_BUILTIN PIN_LED
7168

7269
// Analog pins
7370
// -----------
74-
#define PIN_A0 (15u)
75-
#define PIN_A1 (16u)
76-
#define PIN_A2 (17u)
77-
#define PIN_A3 (18u)
78-
#define PIN_A4 (19u)
79-
#define PIN_A5 (20u)
80-
#define PIN_A6 (21u)
71+
#define PIN_A0 (15u)
72+
#define PIN_A1 (16u)
73+
#define PIN_A2 (17u)
74+
#define PIN_A3 (18u)
75+
#define PIN_A4 (19u)
76+
#define PIN_A5 (20u)
77+
#define PIN_A6 (21u)
8178
static const uint8_t A0 = PIN_A0;
8279
static const uint8_t A1 = PIN_A1;
8380
static const uint8_t A2 = PIN_A2;
8481
static const uint8_t A3 = PIN_A3;
8582
static const uint8_t A4 = PIN_A4;
8683
static const uint8_t A5 = PIN_A5;
8784
static const uint8_t A6 = PIN_A6;
88-
#define ADC_RESOLUTION 12
85+
#define ADC_RESOLUTION 12
8986

9087
// SPI Interfaces
9188
// --------------
9289
#define SPI_INTERFACES_COUNT 2
9390

9491
// SPI
95-
#define PIN_SPI_MISO (10u)
96-
#define PIN_SPI_MOSI (8u)
97-
#define PIN_SPI_SCK (9u)
98-
#define PIN_SPI_SS (24u)
99-
#define PERIPH_SPI sercom1
100-
#define PAD_SPI_TX SPI_PAD_0_SCK_1
101-
#define PAD_SPI_RX SERCOM_RX_PAD_3
92+
#define PIN_SPI_MISO (10u)
93+
#define PIN_SPI_MOSI (8u)
94+
#define PIN_SPI_SCK (9u)
95+
#define PIN_SPI_SS (24u)
96+
#define PERIPH_SPI sercom1
97+
#define PAD_SPI_TX SPI_PAD_0_SCK_1
98+
#define PAD_SPI_RX SERCOM_RX_PAD_3
10299
static const uint8_t SS = PIN_SPI_SS; // SPI Slave SS not used. Set here only for reference.
103100
static const uint8_t MOSI = PIN_SPI_MOSI;
104101
static const uint8_t MISO = PIN_SPI_MISO;
105102
static const uint8_t SCK = PIN_SPI_SCK;
106103

107104
// SPI1: Connected to WINC1501B
108-
#define PIN_SPI1_MISO (29u)
109-
#define PIN_SPI1_MOSI (26u)
110-
#define PIN_SPI1_SCK (27u)
111-
#define PIN_SPI1_SS (28u)
112-
#define PERIPH_SPI1 sercom2
113-
#define PAD_SPI1_TX SPI_PAD_0_SCK_1
114-
#define PAD_SPI1_RX SERCOM_RX_PAD_3
105+
#define PIN_SPI1_MISO (29u)
106+
#define PIN_SPI1_MOSI (26u)
107+
#define PIN_SPI1_SCK (27u)
108+
#define PIN_SPI1_SS (28u)
109+
#define PERIPH_SPI1 sercom2
110+
#define PAD_SPI1_TX SPI_PAD_0_SCK_1
111+
#define PAD_SPI1_RX SERCOM_RX_PAD_3
115112
static const uint8_t SS1 = PIN_SPI1_SS;
116113
static const uint8_t MOSI1 = PIN_SPI1_MOSI;
117114
static const uint8_t MISO1 = PIN_SPI1_MISO;
@@ -133,10 +130,6 @@ static const uint8_t SCK1 = PIN_SPI1_SCK;
133130
#define PIN_USB_DP (23ul)
134131
#define PIN_USB_HOST_ENABLE (24ul)
135132

136-
//#ifdef __cplusplus
137-
//}
138-
//#endif
139-
140133
// Needed for WINC1501B (WiFi101) library
141134
// --------------------------------------
142135
#define WINC1501_RESET_PIN (30u)
@@ -145,10 +138,9 @@ static const uint8_t SCK1 = PIN_SPI1_SCK;
145138
#define WINC1501_SPI SPI1
146139
#define WINC1501_SPI_CS_PIN PIN_SPI1_SS
147140

148-
/*----------------------------------------------------------------------------
149-
* Arduino objects - C++ only
150-
*----------------------------------------------------------------------------*/
151141

142+
// Serial ports
143+
// ------------
152144
#ifdef __cplusplus
153145
#include "SERCOM.h"
154146
#include "Uart.h"
@@ -163,11 +155,11 @@ extern SERCOM sercom5;
163155

164156
// Serial1
165157
extern Uart Serial1;
166-
#define PIN_SERIAL1_RX (13ul)
167-
#define PIN_SERIAL1_TX (14ul)
168-
#define PAD_SERIAL1_TX (UART_TX_PAD_2)
169-
#define PAD_SERIAL1_RX (SERCOM_RX_PAD_3)
170-
#endif
158+
#define PIN_SERIAL1_RX (13ul)
159+
#define PIN_SERIAL1_TX (14ul)
160+
#define PAD_SERIAL1_TX (UART_TX_PAD_2)
161+
#define PAD_SERIAL1_RX (SERCOM_RX_PAD_3)
162+
#endif // __cplusplus
171163

172164
// These serial port names are intended to allow libraries and architecture-neutral
173165
// sketches to automatically default to the correct port name for a particular type

0 commit comments

Comments
 (0)