Skip to content

Commit 4f9864b

Browse files
nzmichaelhgalak
authored andcommitted
boards: add the Adafruit Trinket M0.
The Trinket M0 is a tiny SAMD21 based board with USB, UART, SPI, and an on-board RGB LED. Signed-off-by: Michael Hope <[email protected]>
1 parent 4d72e48 commit 4f9864b

File tree

11 files changed

+372
-0
lines changed

11 files changed

+372
-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 - Adafruit Trinket M0 board configuration
2+
#
3+
# Copyright (c) 2018 Google LLC.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
config BOARD_ADAFRUIT_TRINKET_M0
7+
bool "Adafruit Trinket M0"
8+
depends on SOC_PART_NUMBER_SAMD21E18A
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Kconfig - Adafruit Trinket M0 board configuration
2+
#
3+
# Copyright (c) 2018 Google LLC.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
if BOARD_ADAFRUIT_TRINKET_M0
7+
8+
config BOARD
9+
default adafruit_trinket_m0
10+
11+
endif
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2018 Google LLC.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
#include <atmel/samd21.dtsi>
9+
10+
/ {
11+
model = "Adafruit Trinket M0";
12+
compatible = "adafruit,trinket-m0", "atmel,samd21e18a", "atmel,samd21";
13+
14+
chosen {
15+
zephyr,console = &sercom0;
16+
zephyr,sram = &sram0;
17+
zephyr,flash = &flash0;
18+
zephyr,code-partition = &code_partition;
19+
};
20+
};
21+
22+
&sercom0 {
23+
status = "ok";
24+
current-speed = <115200>;
25+
};
26+
27+
&sercom2 {
28+
status = "ok";
29+
current-speed = <115200>;
30+
};
31+
32+
/* Drives the on-board DotStar LED */
33+
&spi1 {
34+
status = "ok";
35+
};
36+
37+
&flash0 {
38+
partitions {
39+
compatible = "fixed-partitions";
40+
#address-cells = <1>;
41+
#size-cells = <1>;
42+
43+
boot_partition: partition@0 {
44+
label = "uf2";
45+
reg = <0x00000000 0x2000>;
46+
read-only;
47+
};
48+
49+
code_partition: partition@2000 {
50+
label = "code";
51+
reg = <0x2000 0x3A000>;
52+
read-only;
53+
};
54+
55+
/*
56+
* The final 16 KiB is reserved for the application
57+
* and is used by NFFS if enabled.
58+
*/
59+
60+
#if defined(CONFIG_FILE_SYSTEM_NFFS)
61+
nffs_partition: partition@3c000 {
62+
label = "nffs";
63+
reg = <0x0003c000 0x00004000>;
64+
};
65+
#endif
66+
};
67+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
identifier: adafruit_trinket_m0
2+
name: Adafruit Trinket M0
3+
type: mcu
4+
arch: arm
5+
ram: 32
6+
flash: 256
7+
toolchain:
8+
- zephyr
9+
- gccarmemb
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CONFIG_ARM=y
2+
CONFIG_SOC_FAMILY_SAM0=y
3+
CONFIG_SOC_SERIES_SAMD21=y
4+
CONFIG_SOC_PART_NUMBER_SAMD21E18A=y
5+
CONFIG_BOARD_ADAFRUIT_TRINKET_M0=y
6+
CONFIG_SOC_ATMEL_SAMD_OSC8M_AS_MAIN=y
7+
CONFIG_CORTEX_M_SYSTICK=y
8+
CONFIG_CONSOLE=y
9+
CONFIG_UART_CONSOLE=y
10+
CONFIG_SERIAL=y
11+
CONFIG_UART_SAM0=y
12+
CONFIG_UART_INTERRUPT_DRIVEN=y
13+
CONFIG_GPIO=y
14+
CONFIG_GPIO_SAM0=y
15+
CONFIG_WATCHDOG=y
16+
CONFIG_WDT_SAM0=y
17+
CONFIG_SPI=y
18+
CONFIG_SPI_SAM0=y
19+
CONFIG_SPI_1=y
20+
CONFIG_SPI_1_IRQ_PRI=0
21+
CONFIG_SPI_LEGACY_API=n
22+
CONFIG_PINMUX=y
23+
CONFIG_PINMUX_SAM0=y
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2018 Google LLC.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
include(${ZEPHYR_BASE}/boards/common/bossac.board.cmake)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2018 Google LLC.
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+
/* LED on PA10 */
13+
#define LED0_GPIO_PORT CONFIG_GPIO_SAM0_PORTA_LABEL
14+
#define LED0_GPIO_PIN 10
15+
16+
#define CONFIG_UART_SAM0_SERCOM0_PADS \
17+
(SERCOM_USART_CTRLA_RXPO(3) | SERCOM_USART_CTRLA_TXPO(1))
18+
#define CONFIG_UART_SAM0_SERCOM2_PADS \
19+
(SERCOM_USART_CTRLA_RXPO(1) | SERCOM_USART_CTRLA_TXPO(0))
20+
21+
#define CONFIG_SPI_SAM0_SERCOM0_PADS \
22+
(SERCOM_SPI_CTRLA_DIPO(0) | SERCOM_SPI_CTRLA_DOPO(1))
23+
24+
#define CONFIG_SPI_SAM0_SERCOM1_PADS \
25+
(SERCOM_SPI_CTRLA_DIPO(2) | SERCOM_SPI_CTRLA_DOPO(0))
26+
27+
#endif /* __INC_BOARD_H */
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
.. _adafruit_trinket_m0:
2+
3+
Adafruit Trinket M0
4+
###################
5+
6+
Overview
7+
********
8+
9+
The Adafruit Trinket M0 is a tiny (27 mm x 15 mm) ARM development
10+
board with an onboard RGB LED, USB port, and range of I/O broken out
11+
onto 5 pins.
12+
13+
.. image:: img/adafruit_trinket_m0.png
14+
:width: 500px
15+
:align: center
16+
:alt: Adafruit Trinket M0
17+
18+
Hardware
19+
********
20+
21+
- ATSAMD21E18A ARM Cortex-M0+ processor at 48 MHz
22+
- 256 KiB flash memory and 32 KiB of RAM
23+
- Internal trimmed 8 MHz oscillator
24+
- A user LED
25+
- An RGB DotStar LED
26+
- Native USB port
27+
- One reset button
28+
29+
Supported Features
30+
==================
31+
32+
The adafruit_trinket_m0 board configuration supports the following hardware
33+
features:
34+
35+
+-----------+------------+--------------------------------------+
36+
| Interface | Controller | Driver/Component |
37+
+===========+============+======================================+
38+
| NVIC | on-chip | nested vector interrupt controller |
39+
+-----------+------------+--------------------------------------+
40+
| Flash | on-chip | Can be used with NFFS to store files |
41+
+-----------+------------+--------------------------------------+
42+
| SYSTICK | on-chip | systick |
43+
+-----------+------------+--------------------------------------+
44+
| WDT | on-chip | Watchdog |
45+
+-----------+------------+--------------------------------------+
46+
| GPIO | on-chip | I/O ports |
47+
+-----------+------------+--------------------------------------+
48+
| USART | on-chip | Serial ports |
49+
+-----------+------------+--------------------------------------+
50+
| SPI | on-chip | Serial Peripheral Interface ports |
51+
+-----------+------------+--------------------------------------+
52+
53+
Other hardware features are not currently supported by Zephyr.
54+
55+
The default configuration can be found in the Kconfig file
56+
:file:`boards/arm/adafruit_trinket_m0/adafruit_trinket_m0_defconfig`.
57+
58+
Connections and IOs
59+
===================
60+
61+
The `Adafruit Trinket M0 Learn site`_ has detailed information about
62+
the board including `pinouts`_ and the `schematic`_.
63+
64+
System Clock
65+
============
66+
67+
The SAMD21 MCU is configured to use the 8 MHz internal oscillator
68+
with the on-chip PLL generating the 48 MHz system clock. The internal
69+
APB and GCLK unit are set up in the same way as the upstream Arduino
70+
libraries.
71+
72+
Serial Port
73+
===========
74+
75+
The SAMD21 MCU has 6 SERCOM based USARTs. On the Trinket, SERCOM0 is
76+
the Zephyr console and is available on pins 3 (RX) and 4 (TX).
77+
SERCOM2 is available on pins 2 (RX) and 0 (TX).
78+
79+
SPI Port
80+
========
81+
82+
The SAMD21 MCU has 6 SERCOM based SPIs. On the Trinket, SPI1 is used
83+
to drive the DotStar RGB LED. SERCOM0 can be put into SPI mode and
84+
used to connect to devices over pin 2 (MISO), pin 4 (MOSI), and pin 3
85+
(SCK).
86+
87+
Programming and Debugging
88+
*************************
89+
90+
The Trinket M0 ships the BOSSA compatible UF2 bootloader. The
91+
bootloader can be entered by quickly tapping the reset button twice.
92+
93+
Flashing
94+
========
95+
96+
#. Build the Zephyr kernel and the :ref:`hello_world` sample application:
97+
98+
.. zephyr-app-commands::
99+
:zephyr-app: samples/hello_world
100+
:board: adafruit_trinket_m0
101+
:goals: build
102+
:compact:
103+
104+
#. Connect the Trinket M0 to your host computer using USB
105+
106+
#. Connect a 3.3 V USB to serial adapter to the board and to the
107+
host. See the `Serial Port`_ section above for the board's pin
108+
connections.
109+
110+
#. Run your favorite terminal program to listen for output. Under Linux the
111+
terminal should be :code:`/dev/ttyACM0`. For example:
112+
113+
.. code-block:: console
114+
115+
$ minicom -D /dev/ttyACM0 -o
116+
117+
The -o option tells minicom not to send the modem initialization
118+
string. Connection should be configured as follows:
119+
120+
- Speed: 115200
121+
- Data: 8 bits
122+
- Parity: None
123+
- Stop bits: 1
124+
125+
#. Tap the reset button twice quickly to enter bootloader mode
126+
127+
#. Flash the image:
128+
129+
.. zephyr-app-commands::
130+
:zephyr-app: samples/hello_world
131+
:board: adafruit_trinket_m0
132+
:goals: flash
133+
:compact:
134+
135+
You should see "Hello World! arm" in your terminal.
136+
137+
References
138+
**********
139+
140+
.. target-notes::
141+
142+
.. _Adafruit Trinket M0 Learn site:
143+
https://learn.adafruit.com/adafruit-trinket-m0-circuitpython-arduino
144+
145+
.. _pinouts:
146+
https://learn.adafruit.com/assets/49778
147+
148+
.. _schematic:
149+
https://learn.adafruit.com/assets/45723
Loading

0 commit comments

Comments
 (0)