Skip to content

Commit 639f220

Browse files
committed
boards: Add Arduino MKRZero
Built upon the existing SoC for Atmel's SAMD21 MCU but with support enabled for two newly added peripherals: - I2C port (SERCOM) - External Interrupt Controller Signed-off-by: Madani Lainani <[email protected]>
1 parent 38160b4 commit 639f220

File tree

12 files changed

+496
-0
lines changed

12 files changed

+496
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if(CONFIG_PINMUX_SAM0)
2+
zephyr_library()
3+
zephyr_library_sources(pinmux.c)
4+
endif()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Kconfig - Arduino MKRZero Board configuration
2+
#
3+
# Copyright (c) 2018 Madani Lainani.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
config BOARD_ARDUINO_MKRZERO
7+
bool "Arduino MKRZero"
8+
depends on SOC_PART_NUMBER_SAMD21G18A
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Kconfig - Arduino MKRZero board configuration
2+
#
3+
# Copyright (c) 2018 Madani Lainani.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
if BOARD_ARDUINO_MKRZERO
7+
8+
config BOARD
9+
default "arduino_mkrzero"
10+
11+
endif # BOARD_ARDUINO_MKRZERO
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2018 Madani Lainani.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
#include <atmel/samd21.dtsi>
9+
#include <dt-bindings/i2c/i2c.h>
10+
11+
/ {
12+
model = "Arduino MKRZero";
13+
compatible = "arduino,mkrzero", "atmel,samd21g18a", "atmel,samd21";
14+
15+
chosen {
16+
zephyr,console = &sercom5;
17+
zephyr,sram = &sram0;
18+
zephyr,flash = &flash0;
19+
};
20+
};
21+
22+
&sercom0 {
23+
status = "ok";
24+
compatible = "atmel,sam0-i2c";
25+
clock-frequency = <I2C_BITRATE_STANDARD>;
26+
};
27+
28+
&sercom1 {
29+
status = "ok";
30+
compatible = "atmel,sam0-spi";
31+
#address-cells = <1>;
32+
#size-cells = <0>;
33+
};
34+
35+
&sercom5 {
36+
status = "ok";
37+
compatible = "atmel,sam0-uart";
38+
current-speed = <115200>;
39+
};
40+
41+
&flash0 {
42+
partitions {
43+
compatible = "fixed-partitions";
44+
#address-cells = <1>;
45+
#size-cells = <1>;
46+
47+
/*
48+
* The final 16 KiB is reserved for the application
49+
* and is used by NFFS if enabled.
50+
*/
51+
52+
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
53+
storage_partition: partition@3c000 {
54+
label = "storage";
55+
reg = <0x0003c000 0x00004000>;
56+
};
57+
#endif
58+
};
59+
};
60+
61+
&usb0 {
62+
status = "ok";
63+
};
64+
65+
&eic0 {
66+
status = "ok";
67+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
identifier: arduino_mkrzero
2+
name: Arduino MKRZero
3+
type: mcu
4+
arch: arm
5+
ram: 32
6+
flash: 256
7+
toolchain:
8+
- zephyr
9+
- gccarmemb
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
CONFIG_ARM=y
2+
CONFIG_SOC_FAMILY_SAM0=y
3+
CONFIG_SOC_SERIES_SAMD21=y
4+
CONFIG_SOC_PART_NUMBER_SAMD21G18A=y
5+
CONFIG_BOARD_ARDUINO_MKRZERO=y
6+
CONFIG_CORTEX_M_SYSTICK=y
7+
CONFIG_CONSOLE=y
8+
CONFIG_UART_CONSOLE=y
9+
CONFIG_SERIAL=y
10+
CONFIG_UART_SAM0=y
11+
CONFIG_UART_INTERRUPT_DRIVEN=y
12+
CONFIG_GPIO=y
13+
CONFIG_GPIO_SAM0=y
14+
CONFIG_WATCHDOG=y
15+
CONFIG_WDT_SAM0=y
16+
CONFIG_SOC_ATMEL_SAMD_XOSC32K=y
17+
CONFIG_SOC_ATMEL_SAMD_XOSC32K_AS_MAIN=y
18+
CONFIG_SPI=y
19+
CONFIG_SPI_SAM0=y
20+
21+
# The below definition is not used in the SAM0 SERCOM SPI driver code. Its sole
22+
# purpose seems to be reflecting the board DTS configuration in the
23+
# configuration interface.
24+
CONFIG_SPI_1=y
25+
CONFIG_I2C=y
26+
CONFIG_I2C_SAM0=y
27+
28+
# The below definition is not used in the SAM0 SERCOM I2C driver code. Its sole
29+
# purpose seems to be reflecting the board DTS configuration in the
30+
# configuration interface.
31+
CONFIG_I2C_0=y
32+
CONFIG_PINMUX=y
33+
CONFIG_PINMUX_SAM0=y
34+
CONFIG_USB=y
35+
CONFIG_USB_DC_SAM0=y
36+
37+
# External Interrupt Controller
38+
# CONFIG_EIC_SAM0=y
39+
40+
# Map External interrupt 2 to pin A1
41+
# CONFIG_GPIO_SAM0_PORTB_EXTINT_2=y
42+
# CONFIG_GPIO_SAM0_PORTB_EXTINT_2_PIN=2
43+
44+
# FXAS21002C gyroscope I2C address on the Adafruit Precision NXP 9-DOF breakout
45+
# board
46+
# CONFIG_FXAS21002_I2C_NAME="SERCOM0"
47+
# CONFIG_FXAS21002_I2C_ADDRESS=0x21
48+
# CONFIG_FXAS21002_RANGE=3
49+
50+
# CONFIG_FXAS21002_GPIO_NAME="PORTB"
51+
# CONFIG_FXAS21002_GPIO_PIN=2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2018 Madani Lainani.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)

boards/arm/arduino_mkrzero/board.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2018 Madani Lainani.
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+
/* On-board LED on PB08 */
13+
#define LED0_GPIO_PORT CONFIG_GPIO_SAM0_PORTB_LABEL
14+
#define LED0_GPIO_PIN 8
15+
16+
/* Default rise time in nanoseconds, based on 4.7K ohm pull up resistors */
17+
#define CONFIG_I2C_SAM0_SERCOM0_RISE_TIME_NS 125
18+
19+
#define CONFIG_SPI_SAM0_SERCOM1_PADS \
20+
(SERCOM_SPI_CTRLA_DIPO(3) | SERCOM_SPI_CTRLA_DOPO(0))
21+
22+
#define CONFIG_UART_SAM0_SERCOM5_PADS \
23+
(SERCOM_USART_CTRLA_RXPO(3) | SERCOM_USART_CTRLA_TXPO(1))
24+
25+
#endif /* __INC_BOARD_H */
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
.. _arduino_mkrzero:
2+
3+
Arduino MKRZero
4+
###############
5+
6+
Overview
7+
********
8+
9+
The Arduino MKRZero is built around Atmel’s SAMD21 MCU, which features
10+
a 32-bit ARM Cortex M0+ core. It comes in a smaller format than the
11+
Arduino Zero based on that same MCU.
12+
13+
.. image:: img/arduino_mkrzero.jpg
14+
:width: 500px
15+
:align: center
16+
:alt: Arduino MKRZero
17+
18+
Hardware
19+
********
20+
21+
- ATSAMD21G18A ARM Cortex-M0+ processor at 48 MHz
22+
- 32.768 kHz crystal oscillator
23+
- 256 KiB flash memory and 32 KiB of RAM
24+
- 1 user LED
25+
- One reset button
26+
- Native USB port
27+
28+
Supported Features
29+
==================
30+
31+
The arduino_mkrzero board configuration supports the following hardware
32+
features:
33+
34+
+-----------+------------+--------------------------------------+
35+
| Interface | Controller | Driver/Component |
36+
+===========+============+======================================+
37+
| NVIC | on-chip | nested vector interrupt controller |
38+
+-----------+------------+--------------------------------------+
39+
| Flash | on-chip | Can be used with NFFS to store files |
40+
+-----------+------------+--------------------------------------+
41+
| SYSTICK | on-chip | systick |
42+
+-----------+------------+--------------------------------------+
43+
| WDT | on-chip | Watchdog |
44+
+-----------+------------+--------------------------------------+
45+
| GPIO | on-chip | I/O ports |
46+
+-----------+------------+--------------------------------------+
47+
| USART | on-chip | Serial ports |
48+
+-----------+------------+--------------------------------------+
49+
| SPI | on-chip | Serial Peripheral Interface ports |
50+
+-----------+------------+--------------------------------------+
51+
| I2C | on-chip | I2C ports (experimental) |
52+
+-----------+------------+--------------------------------------+
53+
| USB | on-chip | USB device |
54+
+-----------+------------+--------------------------------------+
55+
| EIC | on-chip | External Interrupt Controller |
56+
+-----------+------------+--------------------------------------+
57+
58+
Other hardware features are not currently supported by Zephyr.
59+
60+
The default configuration can be found in the Kconfig
61+
:file:`boards/arm/arduino_mkrzero/arduino_mkrzero_defconfig`.
62+
63+
Connections and IOs
64+
===================
65+
66+
The `Arduino store`_ has detailed information about board
67+
connections. Download the `Arduino MKRZero Schematic`_ for more detail.
68+
69+
System Clock
70+
============
71+
72+
The SAMD21 MCU is configured to use the 32.768 kHz external oscillator
73+
with the on-chip PLL generating the 48 MHz system clock. The internal
74+
APB and GCLK unit are set up in the same way as the upstream Arduino
75+
libraries.
76+
77+
Serial Port
78+
===========
79+
80+
The SAMD21 MCU has 6 SERCOM peripherals, each configurable to operate as either:
81+
82+
- USART
83+
- SPI
84+
- I2C
85+
86+
SERCOM5 is configured as Arduino MKRZero's unique UART interface.
87+
88+
SPI Port
89+
========
90+
91+
SERCOM1 is configured as Arduino MKRZero's unique SPI interface.
92+
93+
I2C Port
94+
========
95+
96+
SERCOM0 is configured as Arduino MKRZero's unique I2C interface.
97+
98+
USB Device Port
99+
===============
100+
101+
The SAMD21 MCU has a USB device port that can be used to communicate
102+
with a host PC. See the :ref:`usb-samples` sample applications for
103+
more, such as the :ref:`usb_cdc-acm` sample which sets up a virtual
104+
serial port that echos characters back to the host PC.
105+
106+
EIC
107+
===
108+
109+
The External Interrupt Controller peripheral allows I/O pins to be configured as
110+
interrupt lines. It is enabled from the GPIO driver configuration menu. The
111+
interrupt -to- I/O pin mapping depends on both the MCU device variant pin count
112+
and the peripheral signals multiplexing to the I/O pins for the considered
113+
board. On Atmel SAMD21G for instance, both PA00 and PA16 can be assigned to
114+
external interrupt 0. On the Arduino MKR Zero, which is based on this device
115+
variant, PA00 is used for another purpose which leaves the user with PA16 as the
116+
only choice for this particular external interrupt. The value 16 would thus need
117+
to be configured for external interrupt 0. Below is the mapping table for the
118+
Arduino MKR Zero. Also note that, unlike for other peripherals, the pin
119+
multiplexing is performed by the GPIO driver as part of the I/O pin
120+
configuration, that is, no code is needed in pinmux.c.
121+
122+
+--------+------------+------------+---------+
123+
| EXTINT | MKZero Pin | PORT Group | I/O Pin |
124+
+========+============+============+=========+
125+
| 0 | MOSI | PORTA | 16 |
126+
+--------+------------+------------+---------+
127+
| 1 | SCK | PORTA | 17 |
128+
+--------+------------+------------+---------+
129+
| 2 | A1 | PORTB | 2 |
130+
+--------+------------+------------+---------+
131+
| 3 | A2 | PORTB | 3 |
132+
+--------+------------+------------+---------+
133+
| 4 | D6 | PORTA | 20 |
134+
+--------+------------+------------+---------+
135+
| 5 | D7 | PORTA | 21 |
136+
+--------+------------+------------+---------+
137+
| 6 | D0 | PORTA | 22 |
138+
+--------+------------+------------+---------+
139+
| 7 | D1 | PORTA | 23 |
140+
+--------+------------+------------+---------+
141+
| 10 | D4 | PORTB | 10 |
142+
+--------+------------+------------+---------+
143+
| 11 | D5 | PORTB | 11 |
144+
+--------+------------+------------+---------+
145+
146+
147+
Programming and Debugging
148+
*************************
149+
150+
Debugging and programming the Arduino MKRZero requires using the
151+
Atmel-ICE development tool with OpenOCD.
152+
153+
Flashing
154+
========
155+
156+
#. Build the Zephyr kernel and the :ref:`hello_world` sample application:
157+
158+
.. zephyr-app-commands::
159+
:zephyr-app: samples/hello_world
160+
:board: arduino_mkrzero
161+
:goals: build
162+
:compact:
163+
164+
#. Connect the Arduino MKRZero to your host computer using the USB debug
165+
port.
166+
167+
#. Run your favorite terminal program to listen for output. Under Linux the
168+
terminal should be :code:`/dev/ttyACM0`. For example:
169+
170+
.. code-block:: console
171+
172+
$ minicom -D /dev/ttyACM0 -o
173+
174+
The -o option tells minicom not to send the modem initialization
175+
string. Connection should be configured as follows:
176+
177+
- Speed: 115200
178+
- Data: 8 bits
179+
- Parity: None
180+
- Stop bits: 1
181+
182+
#. To flash an image:
183+
184+
.. zephyr-app-commands::
185+
:zephyr-app: samples/hello_world
186+
:board: arduino_mkrzero
187+
:goals: flash
188+
:compact:
189+
190+
You should see "Hello World! arm" in your terminal.
191+
192+
References
193+
**********
194+
195+
.. target-notes::
196+
197+
.. _Arduino Store:
198+
https://store.arduino.cc/arduino-mkrzero
199+
200+
.. _Arduino MKRZero Schematic:
201+
https://www.arduino.cc/en/uploads/Main/ArduinoMKRZero-schematic.pdf
29.3 KB
Loading

0 commit comments

Comments
 (0)