Commit 2a9d10e8 authored by Jonas Berg's avatar Jonas Berg Committed by Anas Nashif
Browse files

boards: Add Adafruit Metro RP2040

Product photo from https://learn.adafruit.com/assets/123296


with the license CC BY-SA 3.0

Tested with the samples mentioned in the index.rst page.

Signed-off-by: default avatarJonas Berg <jonas.s.t.berg@gmail.com>
parent d58792d3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
# Copyright (c) 2025 Jonas Berg
# SPDX-License-Identifier: Apache-2.0

config BOARD_ADAFRUIT_METRO_RP2040
	select RP2_FLASH_W25Q080
+5 −0
Original line number Diff line number Diff line
# Copyright (c) 2025 Jonas Berg
# SPDX-License-Identifier: Apache-2.0

config BOARD_ADAFRUIT_METRO_RP2040
	select SOC_RP2040
+16 −0
Original line number Diff line number Diff line
# Copyright (c) 2022 Peter Johanson
# SPDX-License-Identifier: Apache-2.0

if BOARD_ADAFRUIT_METRO_RP2040

if I2C_DW

config I2C_DW_CLOCK_SPEED
	default 125

endif # I2C_DW

config USB_SELF_POWERED
	default n

endif # BOARD_ADAFRUIT_METRO_RP2040
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2025 Jonas Berg
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>

&pinctrl {
	uart0_default: uart0_default {
		group1 {
			pinmux = <UART0_TX_P0>;
		};

		group2 {
			pinmux = <UART0_RX_P1>;
			input-enable;
		};
	};

	i2c0_default: i2c0_default {
		group1 {
			pinmux = <I2C0_SDA_P16>;
			input-enable;
		};

		group2 {
			pinmux = <I2C0_SCL_P17>;
			input-enable;
		};
	};

	spi0_default: spi0_default {
		group1 {
			/* Pin GPIO23 is used as CS (no pinmux available) */
			pinmux = <SPI0_TX_P19>, <SPI0_SCK_P18>;
		};

		group2 {
			pinmux = <SPI0_RX_P20>;
			input-enable;
		};
	};

	adc_default: adc_default {
		group1 {
			pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
			input-enable;
		};
	};

	ws2812_pio0_default: ws2812_pio0_default {
		ws2812 {
			pinmux = <PIO0_P14>;
		};
	};
};
+212 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2021 Yonatan Schachter
 * Copyright (c) 2022 Peter Johanson
 * Copyright (c) 2025 Jonas Berg
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/dts-v1/;

#include <raspberrypi/rpi_pico/rp2040.dtsi>
#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/led/led.h>
#include "adafruit_metro_rp2040-pinctrl.dtsi"
#include "arduino_r3_connector.dtsi"

/ {
	model = "Adafruit Metro RP2040";
	compatible = "adafruit,metro_rp2040";

	chosen {
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,flash-controller = &ssi;
		zephyr,console = &uart0;
		zephyr,shell-uart = &uart0;
		zephyr,code-partition = &code_partition;
	};

	aliases {
		watchdog0 = &wdt0;
		led-strip = &ws2812;
		led0 = &red_led;
		sdhc0 = &sdhc0;
	};

	zephyr,user {
		io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>;
	};

	leds: leds {
		compatible = "gpio-leds";

		red_led: red_led {
			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
			label = "Red LED";
		};
	};

	stemma_connector: stemma_connector {
		compatible = "stemma-qt-connector";
		#gpio-cells = <2>;
		gpio-map-mask = <0xffffffff 0xffffffc0>;
		gpio-map-pass-thru = <0 0x3f>;
		gpio-map = <0 0 &gpio0 17 0>, /* SCL */
			<1 0 &gpio0 16 0>; /* SDA */
	};
};

&flash0 {
	reg = <0x10000000 DT_SIZE_M(16)>;

	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		/* Reserved memory for the second stage bootloader */
		second_stage_bootloader: partition@0 {
			label = "second_stage_bootloader";
			reg = <0x00000000 0x100>;
			read-only;
		};

		/*
		 * Usable flash. Starts at 0x100, after the bootloader. The partition
		 * size is 16 MB minus the 0x100 bytes taken by the bootloader.
		 */
		code_partition: partition@100 {
			label = "code-partition";
			reg = <0x100 (DT_SIZE_M(16) - 0x100)>;
			read-only;
		};
	};
};

&gpio0 {
	status = "okay";
};

&uart0 {
	current-speed = <115200>;
	status = "okay";
	pinctrl-0 = <&uart0_default>;
	pinctrl-names = "default";
};

zephyr_i2c: &i2c0 {
	status = "okay";
	pinctrl-0 = <&i2c0_default>;
	pinctrl-names = "default";
	clock-frequency = <I2C_BITRATE_FAST>;
};

&spi0 {
	pinctrl-0 = <&spi0_default>;
	pinctrl-names = "default";
	status = "okay";
	cs-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;

	sdhc0: sdhc@0 {
		compatible = "zephyr,sdhc-spi-slot";
		reg = <0>;
		status = "okay";
		spi-max-frequency = <12000000>;

		mmc {
			compatible = "zephyr,sdmmc-disk";
			disk-name = "SD";
			status = "okay";
		};
	};
};

&adc {
	status = "okay";
	pinctrl-0 = <&adc_default>;
	pinctrl-names = "default";
	#address-cells = <1>;
	#size-cells = <0>;

	channel@0 {
		reg = <0>;
		zephyr,gain = "ADC_GAIN_1";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,resolution = <12>;
	};

	channel@1 {
		reg = <1>;
		zephyr,gain = "ADC_GAIN_1";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,resolution = <12>;
	};

	channel@2 {
		reg = <2>;
		zephyr,gain = "ADC_GAIN_1";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,resolution = <12>;
	};

	channel@3 {
		reg = <3>;
		zephyr,gain = "ADC_GAIN_1";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,resolution = <12>;
	};
};

&timer {
	status = "okay";
};

&wdt0 {
	status = "okay";
};

&pio0 {
	status = "okay";

	pio-ws2812 {
		compatible = "worldsemi,ws2812-rpi_pico-pio";
		status = "okay";
		pinctrl-0 = <&ws2812_pio0_default>;
		pinctrl-names = "default";
		bit-waveform = <3>, <3>, <4>;

		ws2812: ws2812 {
			status = "okay";
			gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
			chain-length = <1>;
			color-mapping = <LED_COLOR_ID_GREEN
				LED_COLOR_ID_RED
				LED_COLOR_ID_BLUE>;
			reset-delay = <280>;
			frequency = <800000>;
		};
	};
};

zephyr_udc0: &usbd {
	status = "okay";
};

&die_temp {
	status = "okay";
};

&vreg {
	regulator-always-on;
	regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
};

&xosc {
	startup-delay-multiplier = <64>;
};
Loading