Skip to content

Commit fbdd3bb

Browse files
pyhyskartben
authored andcommitted
boards: Add Adafruit Trinkey QT2040 board
Tested with the commands mentioned in the index.rst page. Signed-off-by: Jonas Berg <[email protected]>
1 parent f05f886 commit fbdd3bb

10 files changed

+344
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Jonas Berg
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_ADAFRUIT_TRINKEY_QT2040
5+
select RP2_FLASH_W25Q080
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Jonas Berg
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_ADAFRUIT_TRINKEY_QT2040
5+
select SOC_RP2040
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2022 Peter Johanson
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if BOARD_ADAFRUIT_TRINKEY_QT2040
5+
6+
if I2C_DW
7+
8+
config I2C_DW_CLOCK_SPEED
9+
default 125
10+
11+
endif # I2C_DW
12+
13+
config USB_SELF_POWERED
14+
default n
15+
16+
source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig"
17+
18+
endif # BOARD_ADAFRUIT_TRINKEY_QT2040
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/*
2+
* Copyright (c) 2021 Yonatan Schachter
3+
* Copyright (c) 2022 Peter Johanson
4+
* Copyright (c) 2025 Jonas Berg
5+
*
6+
* SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
/dts-v1/;
10+
11+
#include <raspberrypi/rpi_pico/rp2040.dtsi>
12+
#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
13+
#include <zephyr/dt-bindings/input/input-event-codes.h>
14+
#include <zephyr/dt-bindings/led/led.h>
15+
16+
/ {
17+
model = "Adafruit Trinkey QT2040";
18+
compatible = "adafruit,trinkey_qt2040";
19+
20+
chosen {
21+
zephyr,sram = &sram0;
22+
zephyr,flash = &flash0;
23+
zephyr,flash-controller = &ssi;
24+
zephyr,code-partition = &code_partition;
25+
};
26+
27+
aliases {
28+
watchdog0 = &wdt0;
29+
led-strip = &ws2812;
30+
sw0 = &user_button;
31+
};
32+
33+
gpio_keys {
34+
compatible = "gpio-keys";
35+
36+
user_button: button {
37+
label = "User";
38+
gpios = <&gpio0 12 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
39+
zephyr,code = <INPUT_KEY_0>;
40+
};
41+
};
42+
43+
stemma_connector: stemma_connector {
44+
compatible = "stemma-qt-connector";
45+
#gpio-cells = <2>;
46+
gpio-map-mask = <0xffffffff 0xffffffc0>;
47+
gpio-map-pass-thru = <0 0x3f>;
48+
gpio-map = <0 0 &gpio0 17 0>,
49+
<1 0 &gpio0 16 0>;
50+
};
51+
};
52+
53+
&pinctrl {
54+
i2c0_default: i2c0_default {
55+
group1 {
56+
pinmux = <I2C0_SDA_P16>, <I2C0_SCL_P17>;
57+
input-enable;
58+
};
59+
};
60+
61+
ws2812_pio0_default: ws2812_pio0_default {
62+
ws2812 {
63+
pinmux = <PIO0_P27>;
64+
};
65+
};
66+
};
67+
68+
&flash0 {
69+
reg = <0x10000000 DT_SIZE_M(8)>;
70+
71+
partitions {
72+
compatible = "fixed-partitions";
73+
#address-cells = <1>;
74+
#size-cells = <1>;
75+
76+
/* Reserved memory for the second stage bootloader */
77+
second_stage_bootloader: partition@0 {
78+
label = "second_stage_bootloader";
79+
reg = <0x00000000 0x100>;
80+
read-only;
81+
};
82+
83+
/*
84+
* Usable flash. Starts at 0x100, after the bootloader. The partition
85+
* size is 8 MB minus the 0x100 bytes taken by the bootloader.
86+
*/
87+
code_partition: partition@100 {
88+
label = "code-partition";
89+
reg = <0x100 (DT_SIZE_M(8) - 0x100)>;
90+
read-only;
91+
};
92+
};
93+
};
94+
95+
&gpio0 {
96+
status = "okay";
97+
};
98+
99+
zephyr_i2c: &i2c0 {
100+
status = "okay";
101+
pinctrl-0 = <&i2c0_default>;
102+
pinctrl-names = "default";
103+
clock-frequency = <I2C_BITRATE_FAST>;
104+
};
105+
106+
&timer {
107+
status = "okay";
108+
};
109+
110+
&wdt0 {
111+
status = "okay";
112+
};
113+
114+
&pio0 {
115+
status = "okay";
116+
117+
pio-ws2812 {
118+
compatible = "worldsemi,ws2812-rpi_pico-pio";
119+
status = "okay";
120+
pinctrl-0 = <&ws2812_pio0_default>;
121+
pinctrl-names = "default";
122+
bit-waveform = <3>, <3>, <4>;
123+
124+
ws2812: ws2812 {
125+
status = "okay";
126+
gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>;
127+
chain-length = <1>;
128+
color-mapping = <LED_COLOR_ID_GREEN
129+
LED_COLOR_ID_RED
130+
LED_COLOR_ID_BLUE>;
131+
reset-delay = <280>;
132+
frequency = <800000>;
133+
};
134+
};
135+
};
136+
137+
zephyr_udc0: &usbd {
138+
status = "okay";
139+
};
140+
141+
&vreg {
142+
regulator-always-on;
143+
regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
144+
};
145+
146+
&xosc {
147+
startup-delay-multiplier = <64>;
148+
};
149+
150+
#include <../boards/common/usb/cdc_acm_serial.dtsi>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
identifier: adafruit_trinkey_qt2040
2+
name: Adafruit Trinkey QT2040
3+
type: mcu
4+
arch: arm
5+
flash: 8192
6+
ram: 264
7+
toolchain:
8+
- zephyr
9+
- gnuarmemb
10+
supported:
11+
- clock
12+
- counter
13+
- dma
14+
- flash
15+
- gpio
16+
- hwinfo
17+
- i2c
18+
- usb
19+
- watchdog
20+
- zephyr_i2c
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2025 Jonas Berg
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_BUILD_OUTPUT_UF2=y
5+
CONFIG_CLOCK_CONTROL=y
6+
CONFIG_GPIO=y
7+
CONFIG_PIO_RPI_PICO=y
8+
CONFIG_RESET=y
9+
CONFIG_UART_INTERRUPT_DRIVEN=y
10+
CONFIG_USE_DT_CODE_PARTITION=y
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright (c) 2023 TOKITA Hiroshi
3+
4+
board_runner_args(uf2 "--board-id=RPI-RP2")
5+
6+
include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: adafruit_trinkey_qt2040
3+
full_name: Trinkey QT2040
4+
vendor: adafruit
5+
socs:
6+
- name: rp2040
28.5 KB
Loading
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
.. zephyr:board:: adafruit_trinkey_qt2040
2+
3+
Overview
4+
********
5+
6+
The `Adafruit Trinkey QT2040`_ board is based on the RP2040 microcontroller from Raspberry
7+
Pi Ltd. The board has a Stemma QT connector for easy sensor usage, and has a USB type A connector.
8+
The board outline is similar to many Adafruit Stemma QT shields.
9+
10+
11+
Hardware
12+
********
13+
14+
- Microcontroller Raspberry Pi RP2040, with a max frequency of 133 MHz
15+
- Dual ARM Cortex M0+ cores
16+
- 264 kByte SRAM
17+
- 8 Mbyte QSPI flash
18+
- USB type A connector
19+
- Reset and boot buttons
20+
- RGB LED (Neopixel)
21+
- Stemma QT I2C connector
22+
23+
24+
Default Zephyr Peripheral Mapping
25+
=================================
26+
27+
.. rst-class:: rst-columns
28+
29+
- Boot/User button: GPIO12
30+
- RGB LED: GPIO27
31+
- I2C0_SDA : GPIO16
32+
- I2C0_SCL : GPIO17
33+
34+
Note that no serial port pins (RX or TX) are exposed. By default this board
35+
uses USB for terminal output.
36+
37+
The Boot/User button will pull down the QSPI chip-select line (via a diode) for entering
38+
the built-in USB bootloader at startup. The devicetree file enables an in-chip pull-up
39+
resistor for the Boot/User button so it can be used during runtime, for example
40+
via the :zephyr:code-sample:`input-dump` or the :zephyr:code-sample:`button` sample.
41+
However these samples are somewhat unreliable, as there might be lots of interrupts. This
42+
can be solved by using a stronger external pull-up via the TP4 test point on the back of the PCB,
43+
for example 10 kOhm to +3.3 Volt.
44+
45+
See also `pinout`_ and `schematic`_.
46+
47+
48+
Supported Features
49+
==================
50+
51+
.. zephyr:board-supported-hw::
52+
53+
54+
Programming and Debugging
55+
*************************
56+
57+
.. zephyr:board-supported-runners::
58+
59+
The Adafruit Trinkey QT2040 board does not expose the SWDIO and SWCLK pins, so programming
60+
must be done via the USB port. Press and hold the BOOT button, and then press the RST button,
61+
and the device will appear as a USB mass storage unit. Building your application will result
62+
in a :file:`build/zephyr/zephyr.uf2` file. Drag and drop the file to the USB mass storage unit,
63+
and the board will be reprogrammed.
64+
65+
For more details on programming RP2040-based boards, see :ref:`rpi_pico_programming_and_debugging`.
66+
67+
68+
Flashing
69+
========
70+
71+
To build and flash the :zephyr:code-sample:`led-strip` application, which will blink the
72+
on-board RGB LED in different colors, use this command:
73+
74+
.. zephyr-app-commands::
75+
:zephyr-app: samples/drivers/led/led_strip
76+
:board: adafruit_trinkey_qt2040
77+
:goals: build flash
78+
79+
Try also the :zephyr:code-sample:`dining-philosophers` sample to verify USB console output.
80+
Samples where text is printed only just at startup, for example :zephyr:code-sample:`hello_world`,
81+
are difficult to use as the text is already printed once you connect to the newly created
82+
USB console endpoint.
83+
84+
It is easy to connect a sensor shield via the Stemma QT I2C connector, for example
85+
the ``adafruit_lis3dh`` shield. Run the :zephyr:code-sample:`accel_polling` sample:
86+
87+
.. zephyr-app-commands::
88+
:zephyr-app: samples/sensor/accel_polling/
89+
:board: adafruit_trinkey_qt2040
90+
:shield: adafruit_lis3dh
91+
:goals: build flash
92+
93+
or the :zephyr:code-sample:`sensor_shell` sample:
94+
95+
.. zephyr-app-commands::
96+
:zephyr-app: samples/sensor/sensor_shell/
97+
:board: adafruit_trinkey_qt2040
98+
:shield: adafruit_lis3dh
99+
:goals: build flash
100+
101+
Read the values from the accelerometer via the shell:
102+
103+
.. code-block:: console
104+
105+
uart:~$ sensor get lis3dh@18
106+
channel type=0(accel_x) index=0 shift=4 num_samples=1 value=22974328296ns (0.000000)
107+
channel type=1(accel_y) index=0 shift=4 num_samples=1 value=22974328296ns (-0.114912)
108+
channel type=2(accel_z) index=0 shift=4 num_samples=1 value=22974328296ns (9.882431)
109+
channel type=3(accel_xyz) index=0 shift=4 num_samples=1 value=22974328296ns, (0.000000, -0.114912, 9.882431)
110+
111+
112+
References
113+
**********
114+
115+
.. target-notes::
116+
117+
.. _Adafruit Trinkey QT2040:
118+
https://learn.adafruit.com/adafruit-trinkey-qt2040
119+
120+
.. _pinout:
121+
https://learn.adafruit.com/adafruit-trinkey-qt2040/pinouts
122+
123+
.. _schematic:
124+
https://learn.adafruit.com/adafruit-trinkey-qt2040/downloads

0 commit comments

Comments
 (0)