diff --git a/boards/arm/atsamr34_xpro/Kconfig.board b/boards/arm/atsamr34_xpro/Kconfig.board new file mode 100644 index 00000000000..d586efcbc7e --- /dev/null +++ b/boards/arm/atsamr34_xpro/Kconfig.board @@ -0,0 +1,8 @@ +# SAM R34 Xplained Pro board configuration + +# Copyright (c) 2021 Argentum Systems Ltd. +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_ATSAMR34_XPRO + bool "SAM R34 Xplained Pro" + depends on SOC_PART_NUMBER_SAMR34J18B diff --git a/boards/arm/atsamr34_xpro/Kconfig.defconfig b/boards/arm/atsamr34_xpro/Kconfig.defconfig new file mode 100644 index 00000000000..e327820655a --- /dev/null +++ b/boards/arm/atsamr34_xpro/Kconfig.defconfig @@ -0,0 +1,8 @@ +# SAM R34 Xplained Pro board configuration + +# Copyright (c) 2021 Argentum Systems Ltd. +# SPDX-License-Identifier: Apache-2.0 + +config BOARD + default "atsamr34_xpro" + depends on BOARD_ATSAMR34_XPRO diff --git a/boards/arm/atsamr34_xpro/atsamr34_xpro-pinctrl.dtsi b/boards/arm/atsamr34_xpro/atsamr34_xpro-pinctrl.dtsi new file mode 100644 index 00000000000..cee83fd2c85 --- /dev/null +++ b/boards/arm/atsamr34_xpro/atsamr34_xpro-pinctrl.dtsi @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Argentum Systems Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +&pinctrl { + tcc0_default: tcc0_default { + group1 { + pinmux = ; + }; + }; + + sercom0_default: sercom0_default { + group1 { + pinmux = , + ; + }; + }; + + sercom1_default: sercom1_default { + group1 { + pinmux = , + ; + }; + }; + + sercom4_default: sercom4_default { + group1 { + pinmux = , + , + , + ; + }; + }; + + sercom5_default: sercom5_default { + group1 { + pinmux = , + , + ; + }; + }; +}; diff --git a/boards/arm/atsamr34_xpro/atsamr34_xpro.dts b/boards/arm/atsamr34_xpro/atsamr34_xpro.dts new file mode 100644 index 00000000000..7620e180222 --- /dev/null +++ b/boards/arm/atsamr34_xpro/atsamr34_xpro.dts @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2021 Argentum Systems Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "atsamr34_xpro-pinctrl.dtsi" + +/ { + model = "SAM R34 Xplained Pro"; + compatible = "atsamr34,xpro", "atmel,samr34j18b", "atmel,samr34"; + + chosen { + zephyr,console = &sercom0; + zephyr,shell-uart = &sercom0; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + /* These aliases are provided for compatibility with samples */ + aliases { + led0 = &led0; + pwm-led0 = &pwm_led0; + sw0 = &user_button; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&porta 19 GPIO_ACTIVE_LOW>; + label = "Yellow LED"; + }; + }; + + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&tcc0 3 PWM_MSEC(20)>; + }; + }; + + buttons { + compatible = "gpio-keys"; + user_button: button_0 { + gpios = <&porta 28 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "SW0"; + }; + }; +}; + +&cpu0 { + clock-frequency = <48000000>; +}; + +&adc { + status = "okay"; +}; + +&tcc0 { + status = "okay"; + compatible = "atmel,sam0-tcc-pwm"; + /* Gives a maximum period of 1.4s */ + prescaler = <4>; + #pwm-cells = <2>; + + pinctrl-0 = <&tcc0_default>; + pinctrl-names = "default"; +}; + +&sercom0 { + status = "okay"; + compatible = "atmel,sam0-uart"; + current-speed = <115200>; + rxpo = <1>; + txpo = <0>; + + pinctrl-0 = <&sercom0_default>; + pinctrl-names = "default"; +}; + +&sercom1 { + status = "okay"; + compatible = "atmel,sam0-i2c"; + clock-frequency = ; + #address-cells = <1>; + #size-cells = <0>; + + pinctrl-0 = <&sercom1_default>; + pinctrl-names = "default"; +}; + +/* SERCOM4 is used for the internal LoRa radio */ +&sercom4 { + status = "okay"; + + pinctrl-0 = <&sercom4_default>; + pinctrl-names = "default"; +}; +&lora { + tcxo-power-gpios = <&porta 9 GPIO_ACTIVE_HIGH>; /* TCXO_PWR */ + tcxo-power-startup-delay-ms = <5>; + rfi-enable-gpios = <&porta 13 GPIO_ACTIVE_HIGH>; /* BAND_SEL */ + rfo-enable-gpios = <&porta 13 GPIO_ACTIVE_HIGH>; /* BAND_SEL */ +}; + +&sercom5 { + status = "okay"; + compatible = "atmel,sam0-spi"; + dipo = <0>; + dopo = <1>; + #address-cells = <1>; + #size-cells = <0>; + + pinctrl-0 = <&sercom5_default>; + pinctrl-names = "default"; +}; + +zephyr_udc0: &usb0 { + status = "okay"; +}; diff --git a/boards/arm/atsamr34_xpro/atsamr34_xpro.yaml b/boards/arm/atsamr34_xpro/atsamr34_xpro.yaml new file mode 100644 index 00000000000..706734e3601 --- /dev/null +++ b/boards/arm/atsamr34_xpro/atsamr34_xpro.yaml @@ -0,0 +1,23 @@ +# Copyright (c) 2021 Argentum Systems Ltd. +# SPDX-License-Identifier: Apache-2.0 +identifier: atsamr34_xpro +name: SAM R34 Xplained Pro +type: mcu +arch: arm +ram: 32 +flash: 256 +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - counter + - dma + - gpio + - i2c + - pwm + - spi + - usb_cdc + - usb_device + - watchdog diff --git a/boards/arm/atsamr34_xpro/atsamr34_xpro_defconfig b/boards/arm/atsamr34_xpro/atsamr34_xpro_defconfig new file mode 100644 index 00000000000..18e081418c0 --- /dev/null +++ b/boards/arm/atsamr34_xpro/atsamr34_xpro_defconfig @@ -0,0 +1,16 @@ +# Copyright (c) 2021 Argentum Systems Ltd. +# SPDX-License-Identifier: Apache-2.0 +CONFIG_SOC_SERIES_SAMR34=y +CONFIG_SOC_PART_NUMBER_SAMR34J18B=y +CONFIG_BOARD_ATSAMR34_XPRO=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_CORTEX_M_SYSTICK=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_UART_SAM0=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_GPIO=y +CONFIG_GPIO_SAM0=y +CONFIG_SOC_ATMEL_SAML_XOSC32K=y +CONFIG_SOC_ATMEL_SAML_XOSC32K_AS_MAIN=y diff --git a/boards/arm/atsamr34_xpro/board.cmake b/boards/arm/atsamr34_xpro/board.cmake new file mode 100644 index 00000000000..45c97a245e7 --- /dev/null +++ b/boards/arm/atsamr34_xpro/board.cmake @@ -0,0 +1,4 @@ +# Copyright (c) 2021 Argentum Systems Ltd. +# SPDX-License-Identifier: Apache-2.0 + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/boards/arm/atsamr34_xpro/doc/img/atsamr34-xpro-pinout.png b/boards/arm/atsamr34_xpro/doc/img/atsamr34-xpro-pinout.png new file mode 100644 index 00000000000..0818688ef96 Binary files /dev/null and b/boards/arm/atsamr34_xpro/doc/img/atsamr34-xpro-pinout.png differ diff --git a/boards/arm/atsamr34_xpro/doc/img/atsamr34-xpro.png b/boards/arm/atsamr34_xpro/doc/img/atsamr34-xpro.png new file mode 100644 index 00000000000..04e06ee89f6 Binary files /dev/null and b/boards/arm/atsamr34_xpro/doc/img/atsamr34-xpro.png differ diff --git a/boards/arm/atsamr34_xpro/doc/index.rst b/boards/arm/atsamr34_xpro/doc/index.rst new file mode 100644 index 00000000000..56879c364df --- /dev/null +++ b/boards/arm/atsamr34_xpro/doc/index.rst @@ -0,0 +1,220 @@ + .. _atsamr34_xpro: + +SAM R34 Xplained Pro Evaluation Kit +################################### + +Overview +******** + +The SAM R34 Xplained Pro evaluation kit is ideal for evaluation and +prototyping with the SAM R34 Cortex®-M0+ processor-based +microcontrollers. The kit includes Atmel’s Embedded Debugger (EDBG), +which provides a full debug interface without the need for additional +hardware. + +The SAMR34 and SAMR35 parts are produced as a System-in-Package (SiP), +including both a SAML21 die, and a Semtech SX1276 LoRa radio die. + +This board is also referred to as DM320111. + +.. image:: img/atsamr34-xpro.png + :width: 500px + :align: center + :alt: ATSAMR34-XPRO + +Hardware +******** + +- ATSAMR34J18 ARM Cortex-M0+ processor at 48 MHz +- 32.768 kHz crystal oscillator +- 256 KiB flash memory, 32 KiB of SRAM, 8KB Low Power SRAM +- One yellow user LED +- One mechanical user push button +- One reset button +- On-board USB based EDBG unit with serial console + +Supported Features +================== + +The atsamr34_xpro board configuration supports the following hardware +features: + +.. list-table:: + :header-rows: 1 + + * - Interface + - Controller + - Driver / Component + * - NVIC + - on-chip + - nested vector interrupt controller + * - Flash + - on-chip + - Can be used with LittleFS to store files + * - SYSTICK + - on-chip + - systick + * - WDT + - on-chip + - Watchdog + * - GPIO + - on-chip + - I/O ports + * - PWM + - on-chip + - Pulse Width Modulation + * - USART + - on-chip + - Serial ports + * - I2C + - on-chip + - I2C ports + * - SPI + - on-chip + - Serial Peripheral Interface ports + * - TRNG + - on-chip + - True Random Number Generator + +The following hardware features are supported by Zephyr, but not yet fully +supported by the SOC: + +.. list-table:: + :header-rows: 1 + + * - Interface + - Controller + - Driver / Component + * - LoRa Radio + - on-chip + - Internal SX1276 LoRa Radio + +Other hardware features are not currently supported by Zephyr. + +The default configuration can be found in the Kconfig +``boards/arm/atsamr34_xpro/atsamr34_xpro_defconfig``. + +Pin Mapping +=========== + +The SAM R34 Xplained Pro evaluation kit has 3 GPIO controllers. These +controllers are responsible for pin muxing, input/output, pull-up, etc. + +For mode details please refer to `SAM R34 Family Datasheet`_ and the `SAM R34 +Xplained Pro Schematic`_. + +.. image:: img/atsamr34-xpro-pinout.png + :width: 500px + :align: center + :alt: ATSAMR34-XPRO-pinout + +Default Zephyr Peripheral Mapping: +---------------------------------- +- SERCOM0 UART TX : PA04 +- SERCOM0 UART RX : PA05 +- SERCOM1 I2C SDA : PA16 +- SERCOM1 I2C SCL : PA17 +- SERCOM4 SPI MISO : PC19 +- SERCOM4 SPI MOSI : PB30 +- SERCOM4 SPI SCK : PC18 +- SERCOM4 GPIO CS : PB31 +- SERCOM5 SPI MISO : PB02 +- SERCOM5 SPI MOSI : PB22 +- SERCOM5 SPI SCK : PB23 +- SERCOM5 GPIO CS0 : PA23 +- SERCOM5 GPIO CS1 : PA14 +- USB DP : PA25 +- USB DM : PA24 +- GPIO/PWM LED0 : PA19 + +System Clock +============ + +The SAMR34 MCU is configured to use the 32.768 kHz external oscillator +with the on-chip PLL generating the 48 MHz system clock. + +Serial Port +=========== + +The SAMR34 MCU has six SERCOM based USARTs with one configured as USART in +this BSP. SERCOM0 is the default Zephyr console. + +- SERCOM0 115200 8n1 - connected to the onboard Atmel Embedded Debugger (EDBG) + +PWM +=== + +The SAMR34 MCU has 3 TCC based PWM units with up to 4 outputs each and a period +of 24 bits or 16 bits. If :code:`CONFIG_PWM_SAM0_TCC` is enabled then LED0 is +driven by TCC0 instead of by GPIO. + +SPI Port +======== + +The SAMR34 MCU has 6 SERCOM based SPIs, with two configured as SPI in this BSP. + +- SERCOM4 - connected to the internal LoRa radio +- SERCOM5 - connected to EXT1 and EXT3 + +Programming and Debugging +************************* + +The SAM R34 Xplained Pro comes with a Atmel Embedded Debugger (EDBG). This +provides a debug interface to the SAMR34 chip and is supported by +OpenOCD. + +Flashing +======== + +#. Build the Zephyr kernel and the ``hello_world`` sample application: + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: atsamr34_xpro + :goals: build + :compact: + +#. Connect the SAM R34 Xplained Pro to your host computer using the USB debug + port. + +#. Run your favorite terminal program to listen for output. Under Linux the + terminal should be :code:`/dev/ttyACM0`. For example: + + .. code-block:: console + + $ picocom -b 115200 /dev/ttyACM0 + + - Speed: 115200 + - Data: 8 bits + - Parity: None + - Stop bits: 1 + +#. To flash an image: + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: atsamr34_xpro + :goals: flash + :compact: + + You should see "Hello World! atsamr34_xpro" in your terminal. + +References +********** + +.. target-notes:: + +.. _Microchip website: + https://www.microchip.com/en-us/development-tool/dm320111 + +.. _SAM L21 Family Datasheet: + https://ww1.microchip.com/downloads/en/DeviceDoc/SAM_L21_Family_DataSheet_DS60001477C.pdf + +.. _SAM R34 Family Datasheet: + https://ww1.microchip.com/downloads/en/DeviceDoc/SAM-R34-R35-Low-Power-LoRa-Sub-GHz-SiP-Data-Sheet-DS70005356C.pdf + +.. _SAM R34 Xplained Pro Schematic: + https://ww1.microchip.com/downloads/Secure/en/DeviceDoc/SAMR34_SiP_Reference_Design_Package_V3.0.exe + +.. _Semtech SX1276: + https://www.semtech.com/products/wireless-rf/lora-transceivers/sx1276 diff --git a/boards/arm/atsamr34_xpro/support/openocd.cfg b/boards/arm/atsamr34_xpro/support/openocd.cfg new file mode 100644 index 00000000000..2e7f31036c7 --- /dev/null +++ b/boards/arm/atsamr34_xpro/support/openocd.cfg @@ -0,0 +1,24 @@ +# Copyright (c) 2021 Argentum Systems Ltd. +# SPDX-License-Identifier: Apache-2.0 +source [find interface/cmsis-dap.cfg] +transport select swd + +# chip name +set CHIPNAME at91samr34j18 +set ENDIAN little +set CPUTAPID 0x0bc11477 + +source [find target/at91samdXX.cfg] + +reset_config trst_and_srst separate + +$_TARGETNAME configure -event gdb-attach { + echo "Debugger attaching: halting execution" + reset halt + gdb_breakpoint_override hard +} + +$_TARGETNAME configure -event gdb-detach { + echo "Debugger detaching: resuming execution" + resume +} diff --git a/samples/drivers/adc/boards/atsamr34_xpro.overlay b/samples/drivers/adc/boards/atsamr34_xpro.overlay new file mode 100644 index 00000000000..5bb568b683a --- /dev/null +++ b/samples/drivers/adc/boards/atsamr34_xpro.overlay @@ -0,0 +1,39 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2021 Argentum Systems Ltd. + */ + +#include + +/ { + zephyr,user { + /* EXT-1, pin 3 ADC(+) */ + io-channels = <&adc 6>; + }; +}; + +&pinctrl { + adc_default: adc_default { + group1 { + pinmux = ; + }; + }; +}; + +&adc { + #address-cells = <1>; + #size-cells = <0>; + + pinctrl-0 = <&adc_default>; + pinctrl-names = "default"; + + channel@6 { + reg = <6>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + zephyr,input-positive = <6>; + }; +}; diff --git a/tests/drivers/uart/uart_async_api/boards/atsamr34_xpro.overlay b/tests/drivers/uart/uart_async_api/boards/atsamr34_xpro.overlay new file mode 100644 index 00000000000..0e7a6c43b62 --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/atsamr34_xpro.overlay @@ -0,0 +1,40 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2021 Argentum Systems Ltd. + */ + +&dmac { + status = "okay"; +}; + +&sercom0 { + /* configure DMA channels for async operation */ + dmas = <&dmac 0 0x01>, <&dmac 1 0x02>; + dma-names = "rx", "tx"; +}; + +&pinctrl { + sercom2_default: sercom2_default { + group1 { + pinmux = ; + }; + }; +}; +&sercom2 { + status = "okay"; + compatible = "atmel,sam0-uart"; + current-speed = <115200>; + + /* internally loop-back Tx and Rx on PAD0 */ + rxpo = <0>; + txpo = <0>; + + /* configure DMA channels for async operation */ + dmas = <&dmac 0 0x05>, <&dmac 1 0x06>; + dma-names = "rx", "tx"; + + /* PAD0 must be configured to allow working loop-back */ + pinctrl-0 = <&sercom2_default>; + pinctrl-names = "default"; +}; diff --git a/tests/drivers/uart/uart_async_api/src/test_uart.h b/tests/drivers/uart/uart_async_api/src/test_uart.h index 2c02b8e61f7..a73266fda8c 100644 --- a/tests/drivers/uart/uart_async_api/src/test_uart.h +++ b/tests/drivers/uart/uart_async_api/src/test_uart.h @@ -34,6 +34,8 @@ #define UART_DEVICE_DEV DT_NODELABEL(sercom3) #elif defined(CONFIG_BOARD_ATSAML21_XPRO) #define UART_DEVICE_NAME DT_NODELABEL(sercom1) +#elif defined(CONFIG_BOARD_ATSAMR34_XPRO) +#define UART_DEVICE_NAME DT_NODELABEL(sercom2) #elif defined(CONFIG_BOARD_ATSAME54_XPRO) #define UART_DEVICE_DEV DT_NODELABEL(sercom1) #elif defined(CONFIG_BOARD_NUCLEO_F103RB) || \ diff --git a/tests/drivers/uart/uart_async_api/testcase.yaml b/tests/drivers/uart/uart_async_api/testcase.yaml index 2398e65285d..1da27797769 100644 --- a/tests/drivers/uart/uart_async_api/testcase.yaml +++ b/tests/drivers/uart/uart_async_api/testcase.yaml @@ -2,7 +2,7 @@ common: platform_exclude: seeeduino_xiao serpente arduino_nano_33_iot atsamr21_xpro adafruit_itsybitsy_m4_express atsame54_xpro atsamd21_xpro adafruit_trinket_m0 arduino_nano_33_iot arduino_zero atsamd21_xpro adafruit_feather_m0_basic_proto - arduino_mkrzero atsaml21_xpro + arduino_mkrzero atsaml21_xpro atsamr34_xpro tests: drivers.uart.async_api: