board: samc21: add support for SAMC21N Xplained Pro Board
Add basic support board with SAMC21N soc including SPI, UART, I2C, ADC, Flash, Leds. Signed-off-by: Kamil Serwus <kserwus@gmail.com>
This commit is contained in:
parent
cad62fae61
commit
278120acb6
12 changed files with 513 additions and 0 deletions
8
boards/arm/atsamc21n_xpro/Kconfig.board
Normal file
8
boards/arm/atsamc21n_xpro/Kconfig.board
Normal file
|
@ -0,0 +1,8 @@
|
|||
# SAM C21N Xplained Pro Board configuration
|
||||
|
||||
# Copyright (c) 2022 Kamil Serwus
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD_ATSAMC21N_XPRO
|
||||
bool "SAM C21N Xplained Pro"
|
||||
depends on SOC_PART_NUMBER_SAMC21N18A
|
8
boards/arm/atsamc21n_xpro/Kconfig.defconfig
Normal file
8
boards/arm/atsamc21n_xpro/Kconfig.defconfig
Normal file
|
@ -0,0 +1,8 @@
|
|||
# SAM C21N Xplained Pro board configuration
|
||||
|
||||
# Copyright (c) 2022 Kamil Serwus
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD
|
||||
default "atsamc21n_xpro"
|
||||
depends on BOARD_ATSAMC21N_XPRO
|
64
boards/arm/atsamc21n_xpro/atsamc21n_xpro-pinctrl.dtsi
Normal file
64
boards/arm/atsamc21n_xpro/atsamc21n_xpro-pinctrl.dtsi
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Kamil Serwus
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <dt-bindings/pinctrl/samc21n-pinctrl.h>
|
||||
|
||||
&pinctrl {
|
||||
|
||||
pwm_default: pwm_default {
|
||||
group1 {
|
||||
pinmux = <PC5F_TCC2_WO1>;
|
||||
};
|
||||
};
|
||||
|
||||
adc0_default: adc0_default {
|
||||
group1 {
|
||||
pinmux = <PB9B_ADC0_AIN3>;
|
||||
};
|
||||
};
|
||||
|
||||
adc1_default: adc1_default {
|
||||
group1 {
|
||||
pinmux = <PA8B_ADC1_AIN10>;
|
||||
};
|
||||
};
|
||||
|
||||
sercom0_uart_default: sercom0_uart_default {
|
||||
group1 {
|
||||
pinmux = <PB25C_SERCOM0_PAD1>,
|
||||
<PB24C_SERCOM0_PAD0>;
|
||||
};
|
||||
};
|
||||
|
||||
sercom1_i2c_default: sercom1_i2c_default {
|
||||
group1 {
|
||||
pinmux = <PA16C_SERCOM1_PAD0>,
|
||||
<PA17C_SERCOM1_PAD1>;
|
||||
};
|
||||
};
|
||||
|
||||
sercom2_uart_default: sercom1_uart_default {
|
||||
group1 {
|
||||
pinmux = <PA13C_SERCOM2_PAD1>,
|
||||
<PA12C_SERCOM2_PAD0>;
|
||||
};
|
||||
};
|
||||
|
||||
sercom4_uart_default: sercom4_uart_default {
|
||||
group1 {
|
||||
pinmux = <PB11D_SERCOM4_PAD3>,
|
||||
<PB10D_SERCOM4_PAD2>;
|
||||
};
|
||||
};
|
||||
|
||||
sercom5_spi_default: sercom5_spi_default {
|
||||
group1 {
|
||||
pinmux = <PB0D_SERCOM5_PAD2>,
|
||||
<PB2D_SERCOM5_PAD0>,
|
||||
<PB1D_SERCOM5_PAD3>;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
153
boards/arm/atsamc21n_xpro/atsamc21n_xpro.dts
Normal file
153
boards/arm/atsamc21n_xpro/atsamc21n_xpro.dts
Normal file
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Kamil Serwus
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
#include <atmel/samc21x18.dtsi>
|
||||
#include "atsamc21n_xpro-pinctrl.dtsi"
|
||||
|
||||
/ {
|
||||
model = "SAM C21N Xplained Pro";
|
||||
compatible = "atsamc21n,xpro", "atmel,samc21n18a", "atmel,samc21";
|
||||
|
||||
chosen {
|
||||
zephyr,console = &sercom4;
|
||||
zephyr,shell-uart = &sercom4;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
|
||||
/* These aliases are provided for compatibility with samples */
|
||||
aliases {
|
||||
led0 = &led0;
|
||||
pwm-led0 = &pwm_led0;
|
||||
sw0 = &user_button;
|
||||
i2c-0 = &sercom1;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
led0: led_0 {
|
||||
gpios = <&portc 05 GPIO_ACTIVE_LOW>;
|
||||
label = "Yellow LED";
|
||||
};
|
||||
};
|
||||
|
||||
pwmleds {
|
||||
compatible = "pwm-leds";
|
||||
pwm_led0: pwm_led_0 {
|
||||
pwms = <&tcc2 1 PWM_MSEC(20)>;
|
||||
};
|
||||
};
|
||||
|
||||
buttons {
|
||||
compatible = "gpio-keys";
|
||||
user_button: button_0 {
|
||||
gpios = <&portb 19 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||
label = "User Button";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
&cpu0 {
|
||||
clock-frequency = <48000000>;
|
||||
};
|
||||
|
||||
&adc0 {
|
||||
status = "okay";
|
||||
pinctrl-0 = <&adc0_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
&adc1 {
|
||||
pinctrl-0 = <&adc1_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
&tcc2 {
|
||||
status = "okay";
|
||||
compatible = "atmel,sam0-tcc-pwm";
|
||||
prescaler = <256>;
|
||||
#pwm-cells = <2>;
|
||||
|
||||
pinctrl-0 = <&pwm_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
&sercom0 {
|
||||
status = "okay";
|
||||
compatible = "atmel,sam0-uart";
|
||||
current-speed = <9600>;
|
||||
rxpo = <1>;
|
||||
txpo = <0>;
|
||||
|
||||
pinctrl-0 = <&sercom0_uart_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
&sercom1 {
|
||||
status = "okay";
|
||||
compatible = "atmel,sam0-i2c";
|
||||
clock-frequency = <I2C_BITRATE_FAST>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
pinctrl-0 = <&sercom1_i2c_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
&sercom2 {
|
||||
status = "okay";
|
||||
compatible = "atmel,sam0-uart";
|
||||
current-speed = <115200>;
|
||||
rxpo = <1>;
|
||||
txpo = <0>;
|
||||
|
||||
pinctrl-0 = <&sercom2_uart_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
&sercom4 {
|
||||
status = "okay";
|
||||
compatible = "atmel,sam0-uart";
|
||||
current-speed = <115200>;
|
||||
rxpo = <3>;
|
||||
txpo = <1>;
|
||||
|
||||
pinctrl-0 = <&sercom4_uart_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
&sercom5 {
|
||||
status = "okay";
|
||||
compatible = "atmel,sam0-spi";
|
||||
dipo = <0>;
|
||||
dopo = <2>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
pinctrl-0 = <&sercom5_spi_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
&flash0 {
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/*
|
||||
* The final 16 KiB is reserved for the application.
|
||||
* Storage partition will be used by FCB/LittleFS/NVS
|
||||
* if enabled.
|
||||
*/
|
||||
storage_partition: partition@3c000 {
|
||||
label = "storage";
|
||||
reg = <0x0003c000 0x00004000>;
|
||||
};
|
||||
};
|
||||
};
|
18
boards/arm/atsamc21n_xpro/atsamc21n_xpro.yaml
Normal file
18
boards/arm/atsamc21n_xpro/atsamc21n_xpro.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Copyright (c) 2022 Kamil Serwus
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
identifier: atsamc21n_xpro
|
||||
name: SAM C21N Xplained Pro
|
||||
type: mcu
|
||||
arch: arm
|
||||
ram: 32
|
||||
flash: 256
|
||||
toolchain:
|
||||
- zephyr
|
||||
- gnuarmemb
|
||||
- xtools
|
||||
supported:
|
||||
- adc
|
||||
- gpio
|
||||
- i2c
|
||||
- pwm
|
||||
- spi
|
11
boards/arm/atsamc21n_xpro/atsamc21n_xpro_defconfig
Normal file
11
boards/arm/atsamc21n_xpro/atsamc21n_xpro_defconfig
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Copyright (c) 2022 Kamil Serwus
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
CONFIG_SOC_SERIES_SAMC21=y
|
||||
CONFIG_SOC_PART_NUMBER_SAMC21N18A=y
|
||||
CONFIG_BOARD_ATSAMC21N_XPRO=y
|
||||
CONFIG_BUILD_OUTPUT_HEX=y
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
CONFIG_GPIO=y
|
4
boards/arm/atsamc21n_xpro/board.cmake
Normal file
4
boards/arm/atsamc21n_xpro/board.cmake
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) 2022 Kamil Serwus
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
|
BIN
boards/arm/atsamc21n_xpro/doc/img/atsamc21n_xpro.jpg
Normal file
BIN
boards/arm/atsamc21n_xpro/doc/img/atsamc21n_xpro.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
187
boards/arm/atsamc21n_xpro/doc/index.rst
Normal file
187
boards/arm/atsamc21n_xpro/doc/index.rst
Normal file
|
@ -0,0 +1,187 @@
|
|||
.. _atsamc21n_xpro:
|
||||
|
||||
SAM C21N Xplained Pro Evaluation Kit
|
||||
####################################
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
The SAM C21N Xplained Pro evaluation kit is ideal for evaluation and
|
||||
prototyping with the SAM C21N 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.
|
||||
|
||||
.. image:: img/atsamc21n_xpro.jpg
|
||||
:align: center
|
||||
:alt: ATSAMC21N-XPRO
|
||||
|
||||
Hardware
|
||||
********
|
||||
|
||||
- ATSAMC21N18A ARM Cortex-M0+ processor at 48 MHz
|
||||
- 32.768 kHz crystal oscillator
|
||||
- 256 KiB flash memory, 32 KiB of RAM, 8KB RRW flash
|
||||
- One yellow user LED
|
||||
- One mechanical user push button
|
||||
- One reset button
|
||||
- One QTouch® button
|
||||
- On-board USB based EDBG unit with serial console
|
||||
- Two CAN transceivers
|
||||
|
||||
Supported Features
|
||||
==================
|
||||
|
||||
The atsamc21n_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
|
||||
* - ADC
|
||||
- on-chip
|
||||
- Analog to Digital Converter
|
||||
* - 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
|
||||
|
||||
Other hardware features are not currently supported by Zephyr.
|
||||
|
||||
The default configuration can be found in the Kconfig
|
||||
``boards/arm/atsamc21n_xpro/atsamc21n_xpro_defconfig``.
|
||||
|
||||
Pin Mapping
|
||||
===========
|
||||
|
||||
The SAM C21N Xplained Pro evaluation kit has 4 GPIO controllers. These
|
||||
controllers are responsible for pin muxing, input/output, pull-up, etc.
|
||||
|
||||
For mode details please refer to `SAM C21 Family Datasheet`_ and the `SAM C21N
|
||||
Xplained Pro Schematic`_.
|
||||
|
||||
Default Zephyr Peripheral Mapping:
|
||||
----------------------------------
|
||||
- ADC0 : PB09
|
||||
- ADC1 : PA08
|
||||
- SERCOM0 USART TX : PB24
|
||||
- SERCOM0 USART RX : PB25
|
||||
- SERCOM1 I2C SDA : PA16
|
||||
- SERCOM1 I2C SCL : PA17
|
||||
- SERCOM2 USART TX : PA12
|
||||
- SERCOM2 USART RX : PA13
|
||||
- SERCOM4 USART TX : PB10
|
||||
- SERCOM4 USART RX : PB11
|
||||
- SERCOM5 SPI MISO : PB00
|
||||
- SERCOM5 SPI MOSI : PB02
|
||||
- SERCOM5 SPI SCK : PB01
|
||||
- GPIO/PWM LED0 : PC05
|
||||
|
||||
System Clock
|
||||
============
|
||||
|
||||
The SAMC21 MCU is configured to use the 32.768 kHz internal oscillator
|
||||
with the on-chip internal oscillator generating the 48 MHz system clock.
|
||||
|
||||
Serial Port
|
||||
===========
|
||||
|
||||
The SAMC21 MCU has eight SERCOM based USARTs with three configured as USARTs in
|
||||
this BSP. SERCOM4 is the default Zephyr console.
|
||||
|
||||
- SERCOM0 9600 8n1
|
||||
- SERCOM2 115200 8n1
|
||||
- SERCOM4 115200 8n1 connected to the onboard Atmel Embedded Debugger (EDBG)
|
||||
|
||||
PWM
|
||||
===
|
||||
|
||||
The SAMC21 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 TCC2 instead of by GPIO.
|
||||
|
||||
Programming and Debugging
|
||||
*************************
|
||||
|
||||
The SAM C21N Xplained Pro comes with a Atmel Embedded Debugger (EDBG). This
|
||||
provides a debug interface to the SAMC21 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: atsamc21n_xpro
|
||||
:goals: build
|
||||
:compact:
|
||||
|
||||
#. Connect the SAM C21N 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
|
||||
|
||||
$ minicom -D /dev/ttyACM0 -o
|
||||
|
||||
The -o option tells minicom not to send the modem initialization
|
||||
string. Connection should be configured as follows:
|
||||
|
||||
- Speed: 115200
|
||||
- Data: 8 bits
|
||||
- Parity: None
|
||||
- Stop bits: 1
|
||||
|
||||
#. To flash an image:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/hello_world
|
||||
:board: atsamc21n_xpro
|
||||
:goals: flash
|
||||
:compact:
|
||||
|
||||
You should see "Hello World! atsamc21n_xpro" in your terminal.
|
||||
|
||||
References
|
||||
**********
|
||||
|
||||
.. target-notes::
|
||||
|
||||
.. _Microchip website:
|
||||
https://www.microchip.com/en-us/development-tool/ATSAMC21N-XPRO
|
||||
|
||||
.. _SAM C21 Family Datasheet:
|
||||
https://ww1.microchip.com/downloads/aemDocuments/documents/MCU32/ProductDocuments/DataSheets/SAM-C20-C21-Family-Data-Sheet-DS60001479J.pdf
|
||||
|
||||
.. _SAM C21N Xplained Pro Schematic:
|
||||
https://ww1.microchip.com/downloads/en/DeviceDoc/ATSAMC21N_Xplained_Pro_Design_Files.zip
|
7
boards/arm/atsamc21n_xpro/pre_dt_board.cmake
Normal file
7
boards/arm/atsamc21n_xpro/pre_dt_board.cmake
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Copyright (c) 2021 Linaro Limited
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Suppress "unique_unit_address_if_enabled" to handle the following overlaps:
|
||||
# - /soc/pinmux@41004400 & /soc/gpio@41004400
|
||||
# - /soc/pinmux@41004480 & /soc/gpio@41004480
|
||||
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")
|
25
boards/arm/atsamc21n_xpro/support/openocd.cfg
Normal file
25
boards/arm/atsamc21n_xpro/support/openocd.cfg
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Copyright (c) 2018 Bryan O'Donoghue
|
||||
# Copyright (c) 2022 Kamil Serwus
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
source [find interface/cmsis-dap.cfg]
|
||||
transport select swd
|
||||
|
||||
# chip name
|
||||
set CHIPNAME at91samc21n18a
|
||||
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
|
||||
}
|
28
samples/drivers/adc/boards/atsamc21n_xpro.overlay
Normal file
28
samples/drivers/adc/boards/atsamc21n_xpro.overlay
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 Argentum Systems Ltd.
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/adc/adc.h>
|
||||
|
||||
/ {
|
||||
zephyr,user {
|
||||
/* EXT-1, pin 3 ADC(+) */
|
||||
io-channels = <&adc0 3>;
|
||||
};
|
||||
};
|
||||
|
||||
&adc0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
channel@3 {
|
||||
reg = <3>;
|
||||
zephyr,gain = "ADC_GAIN_1";
|
||||
zephyr,reference = "ADC_REF_INTERNAL";
|
||||
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
|
||||
zephyr,resolution = <12>;
|
||||
zephyr,input-positive = <3>;
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue