Skip to content

Commit ebce1b6

Browse files
0xB0Dgalak
authored andcommitted
boards: arm: atsamd21: Add SAMD21 XPlained board
This patch adds support of the SAMD21 XPlained board. The board has a similar pinout to the SAMD20 XPlained with a different pin-mapping. Signed-off-by: Bryan O'Donoghue <[email protected]>
1 parent 15522fc commit ebce1b6

13 files changed

+404
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2018 Bryan O'Donoghue
2+
# SPDX-License-Identifier: Apache-2.0
3+
if(CONFIG_PINMUX_SAM0)
4+
zephyr_library()
5+
zephyr_library_sources(pinmux.c)
6+
endif()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Kconfig - SAM D21 Xplained Pro Board configuration
2+
#
3+
# Copyright (c) 2018 Bryan O'Donoghue
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
config BOARD_ATSAMD21_XPRO
7+
bool "SAM D21 Xplained Pro"
8+
depends on SOC_PART_NUMBER_SAMD21J18A
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Kconfig - SAM D21 Xplained Pro board configuration
2+
#
3+
# Copyright (c) 2018 Bryan O'Donoghue
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
if BOARD_ATSAMD21_XPRO
7+
8+
config BOARD
9+
default "atsamd21_xpro"
10+
11+
endif # BOARD_ATSAMD21_XPRO
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2018 Bryan O'Donoghue
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
#include <atmel/samd21.dtsi>
9+
10+
/ {
11+
model = "SAM D21 Xplained Pro";
12+
compatible = "atsamd21,xpro", "atmel,samd21j18a", "atmel,samd21";
13+
14+
chosen {
15+
zephyr,console = &sercom3;
16+
zephyr,sram = &sram0;
17+
zephyr,flash = &flash0;
18+
};
19+
};
20+
21+
&sercom0 {
22+
status = "ok";
23+
compatible = "atmel,sam0-uart";
24+
current-speed = <9600>;
25+
};
26+
27+
&sercom1 {
28+
status = "ok";
29+
compatible = "atmel,sam0-uart";
30+
current-speed = <115200>;
31+
};
32+
33+
&sercom3 {
34+
status = "ok";
35+
compatible = "atmel,sam0-uart";
36+
current-speed = <115200>;
37+
};
38+
39+
&sercom5 {
40+
status = "ok";
41+
compatible = "atmel,sam0-spi";
42+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) 2018 Bryan O'Donoghue
2+
# SPDX-License-Identifier: Apache-2.0
3+
identifier: atsamd21_xpro
4+
name: SAM D21 Xplained Pro
5+
type: mcu
6+
arch: arm
7+
ram: 32
8+
flash: 256
9+
toolchain:
10+
- zephyr
11+
- gnuarmemb
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2018 Bryan O'Donoghue
2+
# SPDX-License-Identifier: Apache-2.0
3+
CONFIG_ARM=y
4+
CONFIG_SOC_FAMILY_SAM0=y
5+
CONFIG_SOC_SERIES_SAMD21=y
6+
CONFIG_SOC_PART_NUMBER_SAMD21J18A=y
7+
CONFIG_BOARD_ATSAMD21_XPRO=y
8+
CONFIG_CORTEX_M_SYSTICK=y
9+
CONFIG_CONSOLE=y
10+
CONFIG_UART_CONSOLE=y
11+
CONFIG_SERIAL=y
12+
CONFIG_UART_SAM0=y
13+
CONFIG_UART_INTERRUPT_DRIVEN=y
14+
CONFIG_GPIO=y
15+
CONFIG_GPIO_SAM0=y
16+
CONFIG_WATCHDOG=y
17+
CONFIG_WDT_SAM0=y
18+
CONFIG_SOC_ATMEL_SAMD_XOSC32K=y
19+
CONFIG_SOC_ATMEL_SAMD_XOSC32K_AS_MAIN=y
20+
CONFIG_SPI=y
21+
CONFIG_SPI_SAM0=y
22+
CONFIG_PINMUX=y
23+
CONFIG_PINMUX_SAM0=y

boards/arm/atsamd21_xpro/board.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2018 Bryan O'Donoghue
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)

boards/arm/atsamd21_xpro/board.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2018 Bryan O'Donoghue
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef __INC_BOARD_H
8+
#define __INC_BOARD_H
9+
10+
#include <soc.h>
11+
12+
/* SERCOM0 on RX=PA11, TX=PA10 */
13+
#define CONFIG_UART_SAM0_SERCOM0_PADS \
14+
(SERCOM_USART_CTRLA_RXPO(3) | SERCOM_USART_CTRLA_TXPO(2))
15+
16+
/* SERCOM1 ON RX=PA19, TX=PA16 */
17+
#define CONFIG_UART_SAM0_SERCOM1_PADS \
18+
(SERCOM_USART_CTRLA_RXPO(3) | SERCOM_USART_CTRLA_TXPO(0))
19+
20+
/* SERCOM3 ON RX=PA23, TX=PA22 */
21+
#define CONFIG_UART_SAM0_SERCOM3_PADS \
22+
(SERCOM_USART_CTRLA_RXPO(1) | SERCOM_USART_CTRLA_TXPO(0))
23+
24+
/* SPI SERCOM5 on MISO=PB16/pad 0, MOSI=PB22/pad 2, SCK=PB23/pad 3 */
25+
#define CONFIG_SPI_SAM0_SERCOM5_PADS \
26+
(SERCOM_SPI_CTRLA_DIPO(0) | SERCOM_SPI_CTRLA_DOPO(2))
27+
28+
#define BOARD_YELLOW_LED_GPIO_PORT CONFIG_GPIO_SAM0_PORTB_LABEL
29+
#define BOARD_YELLOW_LED_GPIO_PIN 30
30+
31+
/* Aliases to make the basic samples work. */
32+
#define LED0_GPIO_PORT BOARD_YELLOW_LED_GPIO_PORT
33+
#define LED0_GPIO_PIN BOARD_YELLOW_LED_GPIO_PIN
34+
35+
#endif /* __INC_BOARD_H */
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
.. _atsamd21_xpro:
2+
3+
SAM D21 Xplained Pro Evaluation Kit
4+
###################################
5+
6+
Overview
7+
********
8+
9+
The SAM D21 Xplained Pro evaluation kit is ideal for evaluation and
10+
prototyping with the SAM D21 Cortex®-M0+ processor-based
11+
microcontrollers. The kit includes Atmel’s Embedded Debugger (EDBG),
12+
which provides a full debug interface without the need for additional
13+
hardware.
14+
15+
.. image:: img/ATSAMD21-XPRO.png
16+
:width: 500px
17+
:align: center
18+
:alt: ATSAMD21-XPRO
19+
20+
Hardware
21+
********
22+
23+
- ATSAMD21J18 ARM Cortex-M0+ processor at 48 MHz
24+
- 32.768 kHz crystal oscillator
25+
- 256 KiB flash memory and 32 KiB of RAM
26+
- One yellow user LED
27+
- One mechanical user push button
28+
- One reset button
29+
- On-board USB based EDBG unit with serial console
30+
31+
Supported Features
32+
==================
33+
34+
The atsamd21_xpro board configuration supports the following hardware
35+
features:
36+
37+
+-----------+------------+--------------------------------------+
38+
| Interface | Controller | Driver/Component |
39+
+===========+============+======================================+
40+
| NVIC | on-chip | nested vector interrupt controller |
41+
+-----------+------------+--------------------------------------+
42+
| Flash | on-chip | Can be used with NFFS to store files |
43+
+-----------+------------+--------------------------------------+
44+
| SYSTICK | on-chip | systick |
45+
+-----------+------------+--------------------------------------+
46+
| WDT | on-chip | Watchdog |
47+
+-----------+------------+--------------------------------------+
48+
| GPIO | on-chip | I/O ports |
49+
+-----------+------------+--------------------------------------+
50+
| USART | on-chip | Serial ports |
51+
+-----------+------------+--------------------------------------+
52+
| SPI | on-chip | Serial Peripheral Interface ports |
53+
+-----------+------------+--------------------------------------+
54+
55+
Other hardware features are not currently supported by Zephyr.
56+
57+
The default configuration can be found in the Kconfig
58+
``boards/arm/atsamd21_xpro/atsamd21_xpro_defconfig``.
59+
60+
Pin Mapping
61+
===========
62+
63+
The SAM D21 Xplained Pro evaluation kit has 3 GPIO controllers. These
64+
controllers are responsible for pin muxing, input/output, pull-up, etc.
65+
66+
For mode details please refer to `SAM D21 Family Datasheet`_ and the `SAM D21
67+
Xplained Pro Schematic`_.
68+
69+
.. image:: img/ATSAMD21-XPRO-pinout.png
70+
:width: 500px
71+
:align: center
72+
:alt: ATSAMD21-XPRO-pinout
73+
74+
Default Zephyr Peripheral Mapping:
75+
----------------------------------
76+
- SERCOM0 USART TX : PA10
77+
- SERCOM0 USART RX : PA11
78+
- SERCOM1 USART TX : PA16
79+
- SERCOM1 USART RX : PA19
80+
- SERCOM3 USART TX : PA22
81+
- SERCOM3 USART RX : PA23
82+
- SERCOM5 SPI MISO : PB16
83+
- SERCOM5 SPI MOSI : PB22
84+
- SERCOM5 SPI SCK : PB23
85+
- GPIO SPI CS : PB17
86+
- GPIO LED0 : PB30
87+
88+
System Clock
89+
============
90+
91+
The SAMD21 MCU is configured to use the 32.768 kHz external oscillator
92+
with the on-chip PLL generating the 48 MHz system clock.
93+
94+
Serial Port
95+
===========
96+
97+
The SAMD21 MCU has six SERCOM based USARTs with three configured as USARTs in
98+
this BSP. SERCOM3 is the default Zephyr console.
99+
100+
- SERCOM0 9600 8n1
101+
- SERCOM1 115200 8n1
102+
- SERCOM3 115200 8n1 connected to the onboard Atmel Embedded Debugger (EDBG)
103+
104+
SPI Port
105+
========
106+
107+
The SAMD21 MCU has 6 SERCOM based SPIs. On the SAM D21 Xplained Pro,
108+
SERCOM5 is connected to an 8 megabit SPI flash.
109+
110+
Programming and Debugging
111+
*************************
112+
113+
The SAM D21 Xplained Pro comes with a Atmel Embedded Debugger (EDBG). This
114+
provides a debug interface to the SAMD21 chip and is supported by
115+
OpenOCD.
116+
117+
Flashing
118+
========
119+
120+
#. Build the Zephyr kernel and the ``hello_world`` sample application:
121+
122+
.. zephyr-app-commands::
123+
:zephyr-app: samples/hello_world
124+
:board: atsamd21_xpro
125+
:goals: build
126+
:compact:
127+
128+
#. Connect the SAM D21 Xplained Pro to your host computer using the USB debug
129+
port.
130+
131+
#. Run your favorite terminal program to listen for output. Under Linux the
132+
terminal should be :code:`/dev/ttyACM0`. For example:
133+
134+
.. code-block:: console
135+
136+
$ minicom -D /dev/ttyACM0 -o
137+
138+
The -o option tells minicom not to send the modem initialization
139+
string. Connection should be configured as follows:
140+
141+
- Speed: 115200
142+
- Data: 8 bits
143+
- Parity: None
144+
- Stop bits: 1
145+
146+
#. To flash an image:
147+
148+
.. zephyr-app-commands::
149+
:zephyr-app: samples/hello_world
150+
:board: atsamd21_xpro
151+
:goals: flash
152+
:compact:
153+
154+
You should see "Hello World! arm" in your terminal.
155+
156+
References
157+
**********
158+
159+
.. target-notes::
160+
161+
.. _Microchip website:
162+
http://www.microchip.com/DevelopmentTools/ProductDetails.aspx?PartNO=ATSAMD21-XPRO
163+
164+
.. _SAM D21 Family Datasheet:
165+
http://ww1.microchip.com/downloads/en/DeviceDoc/SAM-D21-Family-Datasheet-DS40001882C.pdf
166+
167+
.. _SAM D21 Xplained Pro Schematic:
168+
http://ww1.microchip.com/downloads/en/DeviceDoc/SAMD21-Xplained-Pro_Design-Documentation.zip
Loading
Loading

boards/arm/atsamd21_xpro/pinmux.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2018 Bryan O'Donoghue
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <init.h>
8+
#include <pinmux.h>
9+
10+
static int board_pinmux_init(struct device *dev)
11+
{
12+
struct device *muxa = device_get_binding(CONFIG_PINMUX_SAM0_A_LABEL);
13+
struct device *muxb = device_get_binding(CONFIG_PINMUX_SAM0_B_LABEL);
14+
15+
ARG_UNUSED(dev);
16+
17+
#if CONFIG_UART_SAM0_SERCOM0_BASE_ADDRESS
18+
/* SERCOM0 on RX=PA11, TX=PA10 */
19+
pinmux_pin_set(muxa, 11, PINMUX_FUNC_C);
20+
pinmux_pin_set(muxa, 10, PINMUX_FUNC_C);
21+
#endif
22+
#if CONFIG_UART_SAM0_SERCOM1_BASE_ADDRESS
23+
/* SERCOM3 ON RX=PA19, TX=PA16 */
24+
pinmux_pin_set(muxa, 19, PINMUX_FUNC_C);
25+
pinmux_pin_set(muxa, 16, PINMUX_FUNC_C);
26+
#endif
27+
#if CONFIG_UART_SAM0_SERCOM2_BASE_ADDRESS
28+
#error Pin mapping is not configured
29+
#endif
30+
#if CONFIG_UART_SAM0_SERCOM3_BASE_ADDRESS
31+
/* SERCOM3 ON RX=PA23, TX=PA22 */
32+
pinmux_pin_set(muxa, 23, PINMUX_FUNC_C);
33+
pinmux_pin_set(muxa, 22, PINMUX_FUNC_C);
34+
#endif
35+
#if CONFIG_UART_SAM0_SERCOM4_BASE_ADDRESS
36+
#error Pin mapping is not configured
37+
#endif
38+
#if CONFIG_UART_SAM0_SERCOM5_BASE_ADDRESS
39+
#error Pin mapping is not configured
40+
#endif
41+
42+
#if CONFIG_SPI_SAM0_SERCOM0_BASE_ADDRESS
43+
#error Pin mapping is not configured
44+
#endif
45+
#if CONFIG_SPI_SAM0_SERCOM1_BASE_ADDRESS
46+
#error Pin mapping is not configured
47+
#endif
48+
#if CONFIG_SPI_SAM0_SERCOM2_BASE_ADDRESS
49+
#error Pin mapping is not configured
50+
#endif
51+
#if CONFIG_SPI_SAM0_SERCOM3_BASE_ADDRESS
52+
#error Pin mapping is not configured
53+
#endif
54+
#if CONFIG_SPI_SAM0_SERCOM4_BASE_ADDRESS
55+
#error Pin mapping is not configured
56+
#endif
57+
#if CONFIG_SPI_SAM0_SERCOM5_BASE_ADDRESS
58+
/* SPI SERCOM5 on MISO=PB16/pad 0, MOSI=PB22/pad 2, SCK=PB23/pad 3 */
59+
pinmux_pin_set(muxb, 16, PINMUX_FUNC_C);
60+
pinmux_pin_set(muxb, 22, PINMUX_FUNC_D);
61+
pinmux_pin_set(muxb, 23, PINMUX_FUNC_D);
62+
#endif
63+
64+
#ifdef CONFIG_USB_DC_SAM0
65+
/* USB DP on PA25, USB DM on PA24 */
66+
pinmux_pin_set(muxa, 25, PINMUX_FUNC_G);
67+
pinmux_pin_set(muxa, 24, PINMUX_FUNC_G);
68+
#endif
69+
return 0;
70+
}
71+
72+
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);

0 commit comments

Comments
 (0)