Skip to content

Commit 36654c5

Browse files
committed
Added support for up to 6 SERCOM on the L21E (32-pin). Added two additional timers to the C21E.
1 parent 78f25ce commit 36654c5

File tree

11 files changed

+337
-73
lines changed

11 files changed

+337
-73
lines changed

boards.txt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,26 @@ mattairtech_mt_d21e_revb.menu.serial.four_uart=FOUR_UART_NO_WIRE_NO_SPI
175175
mattairtech_mt_d21e_revb.menu.serial.four_uart.build.serialcom_uart=FOUR_UART
176176
mattairtech_mt_d21e_revb.menu.serial.four_uart.build.serialcom_wire=NO_WIRE
177177
mattairtech_mt_d21e_revb.menu.serial.four_uart.build.serialcom_spi=NO_SPI
178-
mattairtech_mt_d21e_revb.menu.serial.no_uart=NO_UART_ONE_WIRE_TWO_SPI
179-
mattairtech_mt_d21e_revb.menu.serial.no_uart.build.serialcom_uart=NO_UART
180-
mattairtech_mt_d21e_revb.menu.serial.no_uart.build.serialcom_wire=ONE_WIRE
181-
mattairtech_mt_d21e_revb.menu.serial.no_uart.build.serialcom_spi=TWO_SPI
178+
mattairtech_mt_d21e_revb.menu.serial.no_uart_one_wire_two_spi=NO_UART_ONE_WIRE_TWO_SPI
179+
mattairtech_mt_d21e_revb.menu.serial.no_uart_one_wire_two_spi.build.serialcom_uart=NO_UART
180+
mattairtech_mt_d21e_revb.menu.serial.no_uart_one_wire_two_spi.build.serialcom_wire=ONE_WIRE
181+
mattairtech_mt_d21e_revb.menu.serial.no_uart_one_wire_two_spi.build.serialcom_spi=TWO_SPI
182+
mattairtech_mt_d21e_revb.menu.serial.four_uart_one_wire_one_spi=FOUR_UART_ONE_WIRE_ONE_SPI (L21 only)
183+
mattairtech_mt_d21e_revb.menu.serial.four_uart_one_wire_one_spi.build.serialcom_uart=FOUR_UART
184+
mattairtech_mt_d21e_revb.menu.serial.four_uart_one_wire_one_spi.build.serialcom_wire=ONE_WIRE
185+
mattairtech_mt_d21e_revb.menu.serial.four_uart_one_wire_one_spi.build.serialcom_spi=ONE_SPI
186+
mattairtech_mt_d21e_revb.menu.serial.five_uart_no_wire_one_spi=FIVE_UART_NO_WIRE_ONE_SPI (L21 only)
187+
mattairtech_mt_d21e_revb.menu.serial.five_uart_no_wire_one_spi.build.serialcom_uart=FIVE_UART
188+
mattairtech_mt_d21e_revb.menu.serial.five_uart_no_wire_one_spi.build.serialcom_wire=NO_WIRE
189+
mattairtech_mt_d21e_revb.menu.serial.five_uart_no_wire_one_spi.build.serialcom_spi=ONE_SPI
190+
mattairtech_mt_d21e_revb.menu.serial.five_uart_one_wire_no_spi=FIVE_UART_ONE_WIRE_NO_SPI (L21 only)
191+
mattairtech_mt_d21e_revb.menu.serial.five_uart_one_wire_no_spi.build.serialcom_uart=FIVE_UART
192+
mattairtech_mt_d21e_revb.menu.serial.five_uart_one_wire_no_spi.build.serialcom_wire=ONE_WIRE
193+
mattairtech_mt_d21e_revb.menu.serial.five_uart_one_wire_no_spi.build.serialcom_spi=NO_SPI
194+
mattairtech_mt_d21e_revb.menu.serial.six_uart=SIX_UART_NO_WIRE_NO_SPI (L21 only)
195+
mattairtech_mt_d21e_revb.menu.serial.six_uart.build.serialcom_uart=SIX_UART
196+
mattairtech_mt_d21e_revb.menu.serial.six_uart.build.serialcom_wire=NO_WIRE
197+
mattairtech_mt_d21e_revb.menu.serial.six_uart.build.serialcom_spi=NO_SPI
182198
mattairtech_mt_d21e_revb.menu.usb.cdc=CDC_ONLY
183199
mattairtech_mt_d21e_revb.menu.usb.cdc.build.usbcom=CDC_ONLY
184200
mattairtech_mt_d21e_revb.menu.usb.cdc.build.pid=0x0557
@@ -305,10 +321,10 @@ mattairtech_mt_d21e.menu.serial.four_uart=FOUR_UART_NO_WIRE_NO_SPI
305321
mattairtech_mt_d21e.menu.serial.four_uart.build.serialcom_uart=FOUR_UART
306322
mattairtech_mt_d21e.menu.serial.four_uart.build.serialcom_wire=NO_WIRE
307323
mattairtech_mt_d21e.menu.serial.four_uart.build.serialcom_spi=NO_SPI
308-
mattairtech_mt_d21e.menu.serial.no_uart=NO_UART_ONE_WIRE_TWO_SPI
309-
mattairtech_mt_d21e.menu.serial.no_uart.build.serialcom_uart=NO_UART
310-
mattairtech_mt_d21e.menu.serial.no_uart.build.serialcom_wire=ONE_WIRE
311-
mattairtech_mt_d21e.menu.serial.no_uart.build.serialcom_spi=TWO_SPI
324+
mattairtech_mt_d21e.menu.serial.no_uart_one_wire_two_spi=NO_UART_ONE_WIRE_TWO_SPI
325+
mattairtech_mt_d21e.menu.serial.no_uart_one_wire_two_spi.build.serialcom_uart=NO_UART
326+
mattairtech_mt_d21e.menu.serial.no_uart_one_wire_two_spi.build.serialcom_wire=ONE_WIRE
327+
mattairtech_mt_d21e.menu.serial.no_uart_one_wire_two_spi.build.serialcom_spi=TWO_SPI
312328
mattairtech_mt_d21e.menu.usb.cdc=CDC_ONLY
313329
mattairtech_mt_d21e.menu.usb.cdc.build.usbcom=CDC_ONLY
314330
mattairtech_mt_d21e.menu.usb.cdc.build.pid=0x0557

cores/arduino/USB/samd21_host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

19+
#include "sam.h"
1920

2021
#if (SAMD21 || SAML21)
2122
#include <stdio.h>
@@ -27,7 +28,6 @@
2728
#include "WVariant.h"
2829
#include "USB_host.h"
2930
#include "samd21_host.h"
30-
#include "sam.h"
3131
#include "wiring_digital.h"
3232
#include "wiring_private.h"
3333

cores/arduino/wiring.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,30 @@ void init( void )
134134
regAPBCMASK |= MCLK_APBCMASK_SERCOM0 | MCLK_APBCMASK_SERCOM1 | MCLK_APBCMASK_SERCOM2 | MCLK_APBCMASK_SERCOM3 | MCLK_APBCMASK_SERCOM4 | MCLK_APBCMASK_SERCOM5 ;
135135
regAPBCMASK |= MCLK_APBCMASK_TCC0 | MCLK_APBCMASK_TCC1 | MCLK_APBCMASK_TCC2 | MCLK_APBCMASK_TC0 | MCLK_APBCMASK_TC1 | MCLK_APBCMASK_TC2 | MCLK_APBCMASK_TC3 | MCLK_APBCMASK_TC4 ;
136136
#endif
137-
137+
138138
#if (SAML)
139139
regAPBCMASK |= MCLK_APBCMASK_DAC ;
140140
MCLK->APBDMASK.reg |= MCLK_APBDMASK_ADC; // On the SAML, ADC is on the low power bridge
141141
#elif (SAMC)
142142
regAPBCMASK |= MCLK_APBCMASK_ADC0 | MCLK_APBCMASK_ADC1 | MCLK_APBCMASK_DAC ;
143143
#endif
144-
144+
145145
MCLK->APBCMASK.reg |= regAPBCMASK ;
146146
#else
147147
#error "wiring.c: Unsupported chip"
148148
#endif
149149

150-
//Setup all pins (digital and analog) in STARTUP mode (enable INEN and set default pull direction to pullup (pullup will not be enabled))
150+
// Setup all pins (digital and analog) in STARTUP mode (enable INEN and set default pull direction to pullup (pullup will not be enabled))
151151
for (uint32_t ul = 0 ; ul < NUM_DIGITAL_PINS ; ul++ )
152152
{
153153
pinMode( ul, PIO_STARTUP ) ;
154154
}
155155

156+
// At least on the L21, pin A31 must be set as an input. It is possible that debugger probe detection is being falsely
157+
// detected (even with a pullup on A31 (SWCLK)), which would change the peripheral mux of A31 to COM.
158+
// This might not normally be a problem, but one strange effect is that Serial2 loses characters if pin A31 is not set as INPUT.
159+
pinMode(31, INPUT);
160+
156161
// I/O mux table footnote for D21 and D11: enable pullups on PA24 and PA24 when using as GPIO to avoid excessive current
157162
// Errata: disable pull resistors on PA24 or PA25 manually before switching to peripheral
158163
// Errata: do not use continuous sampling (not enabled by default) on PA24 or PA25

variants/Generic_D11C14A/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ SWDCLK TX1/MISO* 30 | A30 A31 | 31 * RX1/SS
2020
using PIN_MAP_COMPACT, the Arduino numbering is sequential starting from 0 at the top
2121
left pin (A2). PIN_MAP_COMPACT uses less RAM.
2222
* When USB CDC is enabled, Serial refers to SerialUSB, otherwise it refers to Serial1.
23-
* When using NO_UART_ONE_WIRE_ONE_SPI, use SPI on pins 4, 5, 14, and 15.
24-
When using ONE_UART_NO_WIRE_ONE_SPI, use SPI on pins 8, 9, 30, and 31.
23+
* When using ONE_UART_NO_WIRE_ONE_SPI, use SPI on pins 4, 5, 14, and 15.
24+
When using NO_UART_ONE_WIRE_ONE_SPI, use SPI on pins 8, 9, 30, and 31.
2525
* Tone available on TC2. TC2 is not routed to pins in the D11C14A.
2626
* Leave pin A30 floating (or use external pullup) during reset.
2727
* DO NOT connect voltages higher than 3.3V!

variants/MT_D11/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ BTN SS * * | A15 RST |
2424
left pin (A2). PIN_MAP_COMPACT uses less RAM.
2525
* When USB CDC is enabled, Serial refers to SerialUSB, otherwise it refers to Serial1.
2626
* Leave pin A30 floating (or use external pullup) during reset.
27-
* Tone available on TC2. DO NOT connect voltages higher than 3.3V!
27+
* DO NOT connect voltages higher than 3.3V!
28+
* Tone available on TC2.
2829
```
2930

3031

variants/MT_D11/variant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,4 +388,4 @@ extern Uart Serial2;
388388
#define Serial Serial1
389389
#endif
390390

391-
#endif /* _VARIANT_ARDUINO_ZERO_ */
391+
#endif /* _VARIANT_MATTAIRTECH_MT_D11_ */

variants/MT_D21E/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ USB D+ TC51 | A25+ | | Vin |
3232
functions (ie: digitalRead(), analogRead(), analogWrite(), attachInterrupt(), etc.).
3333
* When USB CDC is enabled, Serial refers to SerialUSB, otherwise it refers to Serial1.
3434
* Leave pin A30 floating (or use external pullup) during reset.
35-
* Tone available on TC5. DO NOT connect voltages higher than 3.3V!
35+
* DO NOT connect voltages higher than 3.3V!
36+
* Tone available on TC5.
3637
```
3738

3839
## Pins descriptions for the MattairTech MT-D21E

variants/MT_D21E/variant.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ static const uint8_t SCL1 = PIN_WIRE1_SCL;
294294

295295
#define I2S_DEVICE 0
296296
#define I2S_CLOCK_GENERATOR 3
297-
#define PIN_I2S_SD (9u)
298-
#define PIN_I2S_SCK (1u)
299-
#define PIN_I2S_FS (0u)
297+
#define PIN_I2S_SD (7u)
298+
#define PIN_I2S_SCK (10u)
299+
#define PIN_I2S_FS (11u)
300300

301301
#ifdef __cplusplus
302302
}
@@ -320,6 +320,8 @@ extern SERCOM sercom3;
320320

321321
extern Uart Serial1;
322322
extern Uart Serial2;
323+
extern Uart Serial3;
324+
extern Uart Serial4;
323325

324326
#endif
325327

@@ -362,4 +364,4 @@ extern Uart Serial2;
362364
#define Serial Serial1
363365
#endif
364366

365-
#endif /* _VARIANT_ARDUINO_ZERO_ */
367+
#endif /* _VARIANT_MATTAIRTECH_MT_D21E_ */

variants/MT_D21E_revB/README.md

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ USB D+ (D/L)(+), CAN RX (C) TC51 25 | A25 | | Vin | L21 installed. 5V i
3333
functions (ie: digitalRead(), analogRead(), analogWrite(), attachInterrupt(), etc.).
3434
* When USB CDC is enabled, Serial refers to SerialUSB, otherwise it refers to Serial1.
3535
* Leave pin A30 floating (or use external pullup) during reset.
36-
* Tone available on TC5. DO NOT connect voltages higher than 3.3V!
36+
* Tone available on TC5.
3737
3838
+ This alternate function is enabled by default (+M functions enabled only when a memory
3939
device is installed). Thus, the associated header pin cannot be used. Solder jumpers
@@ -46,6 +46,60 @@ Silkscreen Legend:
4646
Bottom: A circled pin means analog function
4747
```
4848

49+
## COM Arrangement When Using "L21 Only" Options
50+
51+
The following applies only to the L21 and only when using menu options with (L21 only).
52+
If using the L21 with the other options, use the above ASCII diagram.
53+
54+
The additional options are:
55+
56+
* FOUR_UART_ONE_WIRE_ONE_SPI
57+
* FIVE_UART_NO_WIRE_ONE_SPI
58+
* FIVE_UART_ONE_WIRE_NO_SPI
59+
* SIX_UART_NO_WIRE_NO_SPI
60+
61+
```
62+
-------------------
63+
| A0 RST |
64+
| A1 Gnd |
65+
| A2 Vbat |
66+
| A3 A31 |
67+
| A4 A30 |
68+
| A5 NC |
69+
| A6 NC |
70+
| A7 A27 | CS (MEM)
71+
TX3 | A8 A23 | SS/RX5
72+
RX3 | A9 A22 | MISO/TX5
73+
TX1 | A10 A19 | SCK
74+
RX1 | A11 A18 | MOSI
75+
TX2 | A14 A17 | SCL/RX5/RX6
76+
RX2 | A15 A16 | SDA/TX5/TX6
77+
| NC NC |
78+
| NC NC |
79+
| Vbus 3.3V|
80+
USB/TX4 | A24 _____ Vcc |
81+
USB/RX4 | A25 | | Vin |
82+
| Gnd | USB | Gnd |
83+
-------------------
84+
85+
* If the memory device is installed, it is connected to SPI (A18, A19, and A22).
86+
If selecting an option without SPI, then A22 will become TX5. Be sure to keep the
87+
memory device CS pin high. You can disconnect A27 from CS by desoldering J13.
88+
* Serial4 is shared with the USB pins. Thus, USB cannot be used is using Serial4. Be
89+
sure to disconnect the USB connector D- and D+ pins by desoldering J4 and J7.
90+
* It is not necessary to use all serial instances, and they can be skipped. For
91+
example, with the FIVE_UART_NO_WIRE_ONE_SPI option, USB can still be used by NOT
92+
calling Serial4.begin(), thus not enabling the Serial4 peripheral. However, Serial5
93+
can still be used.
94+
* Serial5 can be located either on pins A16/A17 or A22/A23. If SPI is enabled, then
95+
Serial5 is on pins A16/A17, otherwise it is on pins A22/A23.
96+
* SERCOM5 has low-power capabilities and can run in power domain PD0, at the expense
97+
of DMA support and a few other features (see core README.md). It is available in two
98+
locations only, A24/A25 and A22/A23. If SPI is enabled, then SERCOM5 is connected to
99+
Serial4 on A24/A25 (must disable USB), otherwise, it uses Serial5 on A22/A23.
100+
* When USB CDC is enabled, Serial refers to SerialUSB, otherwise it refers to Serial1.
101+
```
102+
49103

50104
## Pins descriptions for the MattairTech MT-D21E (rev B)
51105
```
@@ -70,7 +124,7 @@ Arduino | Silk | Port | Alternate Function | Comments (! means not used with thi
70124
15 | A15 | PA15 | Xout, RX2/SCK1 | !EIC/EXTINT[15] SERCOM2/PAD[3] TC3/WO[1] !TCC0/WO[5] Xout
71125
16 | A16 | PA16 | SDA/TX4 w/pullup | EIC/EXTINT[0] PTC/X[4] SERCOM1/PAD[0] SERCOM3/PAD[0] TCC2/WO[0] !TCC0/WO[6]
72126
17 | A17 | PA17 | SCL/RX4 w/pullup | EIC/EXTINT[1] PTC/X[5] SERCOM1/PAD[1] SERCOM3/PAD[1] TCC2/WO[1] !TCC0/WO[7]
73-
18 | A18 | PA18 | SPI | EIC/EXTINT[2] PTC/X[6] !SERCOM1/PAD[2] SERCOM3/PAD[2] !TC3/WO[0] !TCC0/WO[2]
127+
18 | A18 | PA18 | MOSI | EIC/EXTINT[2] PTC/X[6] !SERCOM1/PAD[2] SERCOM3/PAD[2] !TC3/WO[0] !TCC0/WO[2]
74128
19 | A19 | PA19 | SCK | EIC/EXTINT[3] PTC/X[7] !SERCOM1/PAD[3] SERCOM3/PAD[3] !TC3/WO[1] !TCC0/WO[3]
75129
20 | --- | ---- | NOT A PIN | NOT A PIN
76130
21 | --- | ---- | NOT A PIN | NOT A PIN
@@ -95,6 +149,7 @@ Arduino | Silk | Port | Alternate Function | Comments (! means not used with thi
95149
* TC5(D21) is available on these pins otherwise. The tone library uses TC5.
96150
* A0 and A1 are by default connected to the 32.768KHz crystal.
97151
* Leave pin A30 floating (or use external pullup) during reset.
152+
* This table does not list "L21 Only" COM configurations.
98153
```
99154

100155

@@ -146,10 +201,10 @@ Arduino | Silk | Port | Alternate Function | Comments (! means not used with thi
146201
* 14 pins can be configured with external interrupts.
147202

148203
* **SERCOM**
149-
* 4 SERCOM are available.
150-
* Up to 4 UART instances
151-
* Up to 2 SPI instances
152-
* Up to 2 WIRE (I2C) instances
204+
* 4 SERCOM are available (6 on the L21E).
205+
* Up to 4 UART instances (6 on the L21E).
206+
* Up to 2 SPI instances.
207+
* Up to 2 WIRE (I2C) instances.
153208
* The WIRE pullup resistors are enabled by default.
154209

155210

@@ -211,7 +266,7 @@ now calls pinPeripheral() with the desired mode. Note that this field is not use
211266
select between the two peripherals possible with each of the SERCOM and TIMER functions.
212267
PeripheralAttribute is now used for this.
213268

214-
### PeripheralAttribute:
269+
### PeripheralAttribute
215270
This is an 8-bit bitfield used for various peripheral configuration. It is primarily
216271
used to select between the two peripherals possible with each of the SERCOM and TIMER
217272
functions. TIMER pins are individual, while SERCOM uses a group of two to four pins.

0 commit comments

Comments
 (0)