Skip to content

Commit aea8a39

Browse files
author
Mike Grusin
committed
Fixes to variant.cpp and variant.h
Added LED_BUILTIN for Arduino 1.8 blink sketch etc. Maps to red LED in onboard RGB.
1 parent 43e3b1e commit aea8a39

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

sparkfun/samd/variants/SparkFun_LilyMini/variant.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ const PinDescription g_APinDescription[]=
4040
/*USB DM 9*/{ PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // 9
4141
/*USB DP 10*/{ PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // 10
4242
/*button 11*/{ PORTA, 5, PIO_DIGITAL, (PIN_ATTR_EXTINT), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // 11
43-
/*unused 12*/{ NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, NOT_ON_TIMER, No_ADC_Channel, EXTERNAL_INT_NONE }, // 12
43+
/*unused 12*/{ NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // 12
4444
/*red LED 13*/{ PORTA, 30, PIO_OUTPUT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM),No_ADC_Channel,PWM2_CH0,TC2_CH0,EXTERNAL_INT_NONE }, // 13
45-
// Note that pin 13 is mapped to red LED to support example code that blinks pin 13
45+
// Note that pin 13 is mapped to red LED to support example code that uses pin 13
4646
};
4747

4848
const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TC1, TC2 } ;

sparkfun/samd/variants/SparkFun_LilyMini/variant.h

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,19 @@ extern "C"
7777
// Interrupts
7878
#define digitalPinToInterrupt(P) ( g_APinDescription[P].ulExtInt )
7979

80-
// LEDs
80+
// Digital pins
81+
#define LED_RED (5u)
82+
#define LED_GREEN (6u)
83+
#define LED_BLUE (7u)
84+
#define LED_BUILTIN (5u) // Introduced in Arduino 1.8, tied to red LED
85+
8186
#define PIN_LED_RED (5u)
8287
#define PIN_LED_GREEN (6u)
8388
#define PIN_LED_BLUE (7u)
8489
#define PIN_POWER (8u)
8590
#define PIN_BUTTON (11u)
86-
/*
87-
* Analog pins
88-
*/
91+
92+
// Analog pins
8993
#define PIN_A0 (1ul)
9094
#define PIN_A1 (1ul)
9195
#define PIN_A2 (2ul)
@@ -99,26 +103,21 @@ static const uint8_t A3 = PIN_A3;
99103
static const uint8_t A4 = PIN_A4;
100104
#define ADC_RESOLUTION 10
101105

102-
// Other pins
106+
// Internal "pins"
103107
#define PIN_BATT (ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val)
104108
#define PIN_1V (ADC_INPUTCTRL_MUXPOS_BANDGAP_Val)
105109
#define PIN_TEMP (ADC_INPUTCTRL_MUXPOS_TEMP_Val)
106110

107111
#define analogReadBattVolts() ((analogRead(PIN_BATT)*4000)/((analogRead(PIN_1V)*100)/11)) // will be e.g. 199 for 1.99V
108112
#define analogReadVolts(pin) ((analogRead(pin)*1000)/((analogRead(PIN_1V)*100)/11)) // will be e.g. 199 for 1.99V
109113

110-
/*
111-
* Serial interfaces
112-
*/
113114
// Serial (SERCOM0)
114115
#define PIN_SERIAL_RX (3ul)
115116
#define PIN_SERIAL_TX (4ul)
116117
#define PAD_SERIAL_TX (UART_TX_PAD_0)
117118
#define PAD_SERIAL_RX (SERCOM_RX_PAD_1)
118119

119-
/*
120-
* SPI Interfaces
121-
*/
120+
// SPI
122121
#define SPI_INTERFACES_COUNT 1
123122
#define PIN_SPI_MISO (4u)
124123
#define PIN_SPI_MOSI (1u)
@@ -130,27 +129,20 @@ static const uint8_t A4 = PIN_A4;
130129
#define PAD_SPI_TX SPI_PAD_0_SCK_1
131130
#define PAD_SPI_RX SERCOM_RX_PAD_3
132131

133-
/*
134132
static const uint8_t SS = PIN_SPI_SS;
135133
static const uint8_t MOSI = PIN_SPI_MOSI;
136134
static const uint8_t MISO = PIN_SPI_MISO;
137135
static const uint8_t SCK = PIN_SPI_SCK;
138-
*/
139136

140-
/*
141-
* Wire Interfaces
142-
*/
137+
// I2C (wire)
143138
#define WIRE_INTERFACES_COUNT 1
144139

145140
#define PIN_WIRE_SDA (1u)
146141
#define PIN_WIRE_SCL (2u)
147142
#define PERIPH_WIRE sercom2
148143
#define WIRE_IT_HANDLER SERCOM2_Handler
149144

150-
/*
151-
* USB
152-
*/
153-
//#define PIN_USB_HOST_ENABLE (XXul)
145+
// USB
154146
#define PIN_USB_DM (9ul)
155147
#define PIN_USB_DP (10ul)
156148

0 commit comments

Comments
 (0)