diff --git a/Documentation/platforms/arm/samd2l2/boards/xiao-seeeduino/index.rst b/Documentation/platforms/arm/samd2l2/boards/xiao-seeeduino/index.rst new file mode 100644 index 0000000000000..5c35151b2a3c8 --- /dev/null +++ b/Documentation/platforms/arm/samd2l2/boards/xiao-seeeduino/index.rst @@ -0,0 +1,138 @@ +======================== +Seeed Studio Xiao SAMD21 +======================== + +The `Seeed Studio Xiao SAM21 `_ is the first of the XIAO family, and is a +general purpose, low-power and tiny board. It can be referred to as the "Seeed Studio Xiao SAMD21" or the "Xiao +Seeeduino". + +.. figure:: seeed-xiao-samd21.jpg + :align: center + +Features +======== + +* ATSAMD21G18A-MU microcontroller chip @48MHz +* 256KB flash +* 32KB SRAM +* 14 pins (11 analog, 11 digital) +* 10 PWM interfaces +* 1 DAC output pin +* Serial wire debug interface +* 1 I2C interface +* 1 SPI interface +* 1 UART interface +* USBC interface +* Serial communication indicator LEDs for TX and RX (blue) +* Power indicator LED (green) +* Blinkable LED (yellow) + +Serial Console +============== + +By default, the serial console appears on the board's UART interface. Pin 9 is +TX and pin 7 is RX. + +Pin Mapping +=========== + +Pins are numbered anticlockwise from the USB connector. + +===== ======== ======================================== +Pin Signal Notes +===== ======== ======================================== +0 PA2 A0/D0/DAC +1 PA4 A1/D1 +2 PA10 A2/D2 +3 PA11 A3/D3 +4 PA8 A4/D4/SDA (I2C) +5 PA9 A5/D5/SCL (I2C) +6 PB08 A6/D6/TX (UART) +7 PB09 A7/D7/RX (UART) +8 PA7 A8/D8/SCK (SPI) +9 PA5 A9/D9/MISO (SPI) +10 PA6 A10/D10/MOSI (SPI) +11 3V3 +12 GND +13 5V You can supply 5V power on this pin too. +===== ======== ======================================== + +There are also four pads on the back side of the board. SWCLK, SWDIO for serial +wire debugging, and RST and GND for resetting the board. These same two pins are +also exposed on the top of the board. + +Power Supply +============ + +The board can be powered through a USB-C connection. It can also be supplied 5V +power through it's 5V power pin. + +There is an additional two pads for powering the board (VIN and GND) on the back +side. The board accepts anywhere between 3.3V and 5V. + +Installation +============ + +To build NuttX for the Xiao Seeduino, you can use the following configuration +commands within the cloned ``nuttx`` repository: + +.. code-block:: console + + $ ./tools/configure.sh xiao-seeeduino:nsh + $ make + +This will generate a ``nuttx.hex`` file. To put the program on your board, you +can choose from one of the following: + +1. Convert the hex file to a uf2 file using the `Microsoft uf2 tool `_: + + .. code-block:: console + + $ git clone https://github.com/microsoft/uf2.git + $ cd uf2/utils + $ python uf2conv.py -f 0x68ed2b88 -b 0x2000 nuttx.hex -o nuttx.uf2 + + Then, plug your board into the host computer using the USB-C interface. Short + the RST (reset) pad with ground twice in a row quickly. The board will be + detected as mass storage under the name "Arduino", and its orange LED will be + pulsing slowly. You can then copy the UF2 file to the drive/storage device + which appears. Once the file is done copying, the board will auto-eject and + you will have an NSH console on the UART pins! + + .. todo:: + Maybe this process should be part of the post-build scripts, since the + Microsoft UF2 tools is MIT licensed. + +2. Flash the hex file using the ``bossac`` tool. You can find the source for it + `here `_, or you can install it on Arch + Linux via the AUR with this command: + + .. code-block:: console + + $ yay -S bossa + + Then, plug your Seeduino in via USB-C to the host computer and short the RST + (reset) and ground pins twice in a row quickly. The board will be detected as + mass storage under the name "Arduino", and its orange LED should be pulsing. + You can then run the following command: + + .. code-block:: console + + $ sudo stty -F 1200 + $ sudo bossac -i -d --port= -i -w -v nuttx.hex -R + + .. todo:: + The ``bossac`` utility doesn't actually work for programming in my testing + yet. It is what the Arduino IDE uses but I haven't managed to get the + commmand line working. Using the commands listed above does actually + detect the board but the programming itself fails with "Flash command + failed". This needs more debugging. + +Configurations +============== + +nsh +--- + +Basic NuttShell configuration with the console enabled on the UART interface at +115200 bps. Comes with "Hello world" demo. diff --git a/Documentation/platforms/arm/samd2l2/boards/xiao-seeeduino/seeed-xiao-samd21.jpg b/Documentation/platforms/arm/samd2l2/boards/xiao-seeeduino/seeed-xiao-samd21.jpg new file mode 100644 index 0000000000000..c0e6a12b1a997 Binary files /dev/null and b/Documentation/platforms/arm/samd2l2/boards/xiao-seeeduino/seeed-xiao-samd21.jpg differ diff --git a/boards/Kconfig b/boards/Kconfig index e98058c9e6a65..c123b7729c3d9 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -2329,6 +2329,15 @@ config ARCH_BOARD_SAMD21_XPLAINED This board features the ATSAMD21J18A MCU (Cortex-M0+ with 256KB of FLASH and 32KB of SRAM). +config ARCH_BOARD_XIAO_SEEEDUINO + bool "Seeed Studio XIAO SAMD21" + depends on ARCH_CHIP_SAMD21J18A + select ARCH_HAVE_LEDS + ---help--- + The port of NuttX to the Seeed Studio XIAO SAMD21 board. + This board features the ATSAMD21J18A MCU (Cortex-M0+ with 256KB of FLASH + and 32KB of SRAM) in a tiny footprint. + config ARCH_BOARD_SAME54_XPLAINED_PRO bool "Atmel SAME54-Xplained Pro development board" depends on ARCH_CHIP_SAME54P20 @@ -3467,6 +3476,7 @@ config ARCH_BOARD default "sama5d4-ek" if ARCH_BOARD_SAMA5D4_EK default "samd20-xplained" if ARCH_BOARD_SAMD20_XPLAINED default "samd21-xplained" if ARCH_BOARD_SAMD21_XPLAINED + default "xiao-seeeduino" if ARCH_BOARD_XIAO_SEEEDUINO default "same54-xplained-pro" if ARCH_BOARD_SAME54_XPLAINED_PRO default "saml21-xplained" if ARCH_BOARD_SAML21_XPLAINED default "sam3u-ek" if ARCH_BOARD_SAM3UEK @@ -3945,6 +3955,9 @@ endif if ARCH_BOARD_SAMD21_XPLAINED source "boards/arm/samd2l2/samd21-xplained/Kconfig" endif +if ARCH_BOARD_XIAO_SEEEDUINO +source "boards/arm/samd2l2/xiao-seeeduino/Kconfig" +endif if ARCH_BOARD_SAME54_XPLAINED_PRO source "boards/arm/samd5e5/same54-xplained-pro/Kconfig" endif diff --git a/boards/arm/samd2l2/xiao-seeeduino/Kconfig b/boards/arm/samd2l2/xiao-seeeduino/Kconfig new file mode 100644 index 0000000000000..2d9fa0fa92197 --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/Kconfig @@ -0,0 +1,12 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_XIAO_SEEEDUINO + +menu "XIAO Seeeduino" + +endmenu # XIAO Seeeduino + +endif # ARCH_BOARD_XIAO_SEEEDUINO diff --git a/boards/arm/samd2l2/xiao-seeeduino/configs/nsh/defconfig b/boards/arm/samd2l2/xiao-seeeduino/configs/nsh/defconfig new file mode 100644 index 0000000000000..e961f34749069 --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/configs/nsh/defconfig @@ -0,0 +1,59 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_DISABLE_POSIX_TIMERS is not set +# CONFIG_NSH_DISABLEBG is not set +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLE_CMP is not set +# CONFIG_NSH_DISABLE_DD is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXIT is not set +# CONFIG_NSH_DISABLE_GET is not set +# CONFIG_NSH_DISABLE_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_ITEF is not set +# CONFIG_NSH_DISABLE_LOOPS is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +# CONFIG_NSH_DISABLE_MKRD is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PUT is not set +# CONFIG_NSH_DISABLE_SEMICOLON is not set +# CONFIG_NSH_DISABLE_UNAME is not set +# CONFIG_NSH_DISABLE_WGET is not set +# CONFIG_NSH_DISABLE_XD is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="xiao-seeeduino" +CONFIG_ARCH_BOARD_XIAO_SEEEDUINO=y +CONFIG_ARCH_CHIP="samd2l2" +CONFIG_ARCH_CHIP_SAMD21J18A=y +CONFIG_ARCH_CHIP_SAMD2X=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=3410 +CONFIG_BUILTIN=y +CONFIG_DEFAULT_SMALL=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=1536 +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=1536 +CONFIG_PTHREAD_STACK_DEFAULT=1536 +CONFIG_RAM_SIZE=32768 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SAMD2L2_SERCOM4=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=18 +CONFIG_START_MONTH=10 +CONFIG_START_YEAR=2024 +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_USART4_RXBUFSIZE=64 +CONFIG_USART4_SERIAL_CONSOLE=y +CONFIG_USART4_TXBUFSIZE=64 diff --git a/boards/arm/samd2l2/xiao-seeeduino/include/board.h b/boards/arm/samd2l2/xiao-seeeduino/include/board.h new file mode 100644 index 0000000000000..961bf6a0e5101 --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/include/board.h @@ -0,0 +1,410 @@ +/**************************************************************************** + * boards/arm/samd2l2/xiao-seeeduino/include/board.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_SAMD2L2_XIAO_SEEEDUINO_INCLUDE_BOARD_H +#define __BOARDS_ARM_SAMD2L2_XIAO_SEEEDUINO_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#ifndef __ASSEMBLY__ +# include +# ifdef CONFIG_SAMD2L2_GPIOIRQ +# include +# endif +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* Overview + * + * OSC8M Output = 8MHz + * `- GCLK1 Input = 8MHz Prescaler = 1 output = 8MHz + * `- DFLL Input = 8MHz Multiplier = 6 output = 48MHz + * `- GCLK0 Input = 48MHz Prescaler = 1 output = 48MHz + * `- PM Input = 48Mhz CPU divider = 1 CPU frequency = 48MHz + * APBA divider = 1 APBA frequency = 48MHz + * APBB divider = 1 APBB frequency = 48MHz + * APBC divider = 1 APBC frequency = 48MHz + * + * The SAMD21 Xplained Pro has one on-board crystal: + * + * XC101 32.768KHz XOSC32 + * + * REVISIT: Not currently used, may want to use as GCLK1 source with + * DFLL multiplier of ((48000000+16384)/32768) = 1465 which would yield + * a clock of 48,005,120 MHz. + */ + +/* XOSC Configuration -- Not available + * + * BOARD_XOSC_ENABLE - Boolean (defined / not defined) + * BOARD_XOSC_FREQUENCY - In Hz + * BOARD_XOSC_STARTUPTIME - See SYSCTRL_XOSC_STARTUP_* definitions + * BOARD_XOSC_ISCRYSTAL - Boolean (defined / not defined) + * BOARD_XOSC_AMPGC - Boolean (defined / not defined) + * BOARD_XOSC_ONDEMAND - Boolean (defined / not defined) + * BOARD_XOSC_RUNINSTANDBY - Boolean (defined / not defined) + */ + +#undef BOARD_XOSC_ENABLE +#define BOARD_XOSC_FREQUENCY 12000000UL +#define BOARD_XOSC_STARTUPTIME SYSCTRL_XOSC_STARTUP_1S +#define BOARD_XOSC_ISCRYSTAL 1 +#define BOARD_XOSC_AMPGC 1 +#define BOARD_XOSC_ONDEMAND 1 +#undef BOARD_XOSC_RUNINSTANDBY + +/* XOSC32 Configuration -- Not used + * + * BOARD_XOSC32K_ENABLE - Boolean (defined / not defined) + * BOARD_XOSC32K_FREQUENCY - In Hz + * BOARD_XOSC32K_STARTUPTIME - See SYSCTRL_XOSC32K_STARTUP_* definitions + * BOARD_XOSC32K_ISCRYSTAL - Boolean (defined / not defined) + * BOARD_XOSC32K_AAMPEN - Boolean (defined / not defined) + * BOARD_XOSC32K_EN1KHZ - Boolean (defined / not defined) + * BOARD_XOSC32K_EN32KHZ - Boolean (defined / not defined) + * BOARD_XOSC32K_ONDEMAND - Boolean (defined / not defined) + * BOARD_XOSC32K_RUNINSTANDBY - Boolean (defined / not defined) + */ + +#undef BOARD_XOSC32K_ENABLE +#define BOARD_XOSC32K_FREQUENCY 32768 /* 32.768KHz XTAL */ +#define BOARD_XOSC32K_STARTUPTIME SYSCTRL_XOSC32K_STARTUP_2S +#define BOARD_XOSC32K_ISCRYSTAL 1 +#define BOARD_XOSC32K_AAMPEN 1 +#undef BOARD_XOSC32K_EN1KHZ +#define BOARD_XOSC32K_EN32KHZ 1 +#define BOARD_XOSC32K_ONDEMAND 1 +#undef BOARD_XOSC32K_RUNINSTANDBY + +/* OSC32 Configuration -- not used + * + * BOARD_OSC32K_ENABLE - Boolean (defined / not defined) + * BOARD_OSC32K_FREQUENCY - In Hz + * BOARD_OSC32K_STARTUPTIME - See SYSCTRL_OSC32K_STARTUP_* definitions + * BOARD_OSC32K_EN1KHZ - Boolean (defined / not defined) + * BOARD_OSC32K_EN32KHZ - Boolean (defined / not defined) + * BOARD_OSC32K_ONDEMAND - Boolean (defined / not defined) + * BOARD_OSC32K_RUNINSTANDBY - Boolean (defined / not defined) + */ + +#undef BOARD_OSC32K_ENABLE +#define BOARD_OSC32K_FREQUENCY 32768 /* 32.768kHz internal oscillator */ +#define BOARD_OSC32K_STARTUPTIME SYSCTRL_OSC32K_STARTUP_4MS +#define BOARD_OSC32K_EN1KHZ 1 +#define BOARD_OSC32K_EN32KHZ 1 +#define BOARD_OSC32K_ONDEMAND 1 +#undef BOARD_OSC32K_RUNINSTANDBY + +/* OSC8M Configuration -- always enabled + * + * BOARD_OSC8M_PRESCALER - See SYSCTRL_OSC8M_PRESC_DIV* definitions + * BOARD_OSC8M_ONDEMAND - Boolean (defined / not defined) + * BOARD_OSC8M_RUNINSTANDBY - Boolean (defined / not defined) + */ + +#define BOARD_OSC8M_PRESCALER SYSCTRL_OSC8M_PRESC_DIV1 +#define BOARD_OSC8M_ONDEMAND 1 +#undef BOARD_OSC8M_RUNINSTANDBY + +#define BOARD_OSC8M_FREQUENCY 8000000 /* 8MHz high-accuracy internal oscillator */ + +/* OSCULP32K Configuration -- not used. */ + +#define BOARD_OSCULP32K_FREQUENCY 32000 /* 32kHz ultra-low-power internal oscillator */ + +/* Digital Frequency Locked Loop configuration. In closed-loop mode, the + * DFLL output frequency (Fdfll) is given by: + * + * Fdfll = DFLLmul * Frefclk + * = 6 * 8000000 = 48MHz + * + * Where the reference clock is Generic Clock Channel 0 output of GLCK1. + * GCLCK1 provides OSC8M, undivided. + * + * When operating in open-loop mode, the output frequency of the DFLL will + * be determined by the values written to the DFLL Coarse Value bit group + * and the DFLL Fine Value bit group in the DFLL Value register. + * + * BOARD_DFLL_OPENLOOP - Boolean (defined / not defined) + * BOARD_DFLL_TRACKAFTERFINELOCK - Boolean (defined / not defined) + * BOARD_DFLL_KEEPLOCKONWAKEUP - Boolean (defined / not defined) + * BOARD_DFLL_ENABLECHILLCYCLE - Boolean (defined / not defined) + * BOARD_DFLL_QUICKLOCK - Boolean (defined / not defined) + * BOARD_DFLL_ONDEMAND - Boolean (defined / not defined) + * + * Closed loop mode only: + * BOARD_DFLL_GCLKGEN - GCLK index + * BOARD_DFLL_MULTIPLIER - Value + * BOARD_DFLL_MAXCOARSESTEP - Value + * BOARD_DFLL_MAXFINESTEP - Value + * + * BOARD_DFLL_FREQUENCY - The resulting frequency + */ + +#define BOARD_DFLL_ENABLE 1 +#define BOARD_DFLL_OPENLOOP 1 +#undef BOARD_DFLL_ONDEMAND +#undef BOARD_DFLL_RUNINSTANDBY + +/* DFLL closed loop mode configuration */ + +#define BOARD_DFLL_SRCGCLKGEN 1 +#define BOARD_DFLL_MULTIPLIER 6 +#define BOARD_DFLL_QUICKLOCK 1 +#define BOARD_DFLL_TRACKAFTERFINELOCK 1 +#define BOARD_DFLL_KEEPLOCKONWAKEUP 1 +#define BOARD_DFLL_ENABLECHILLCYCLE 1 +#define BOARD_DFLL_MAXCOARSESTEP (0x1f / 4) +#define BOARD_DFLL_MAXFINESTEP (0xff / 4) + +#define BOARD_DFLL_FREQUENCY (48000000) + +/* GCLK Configuration + * + * Global enable/disable. + * + * BOARD_GCLK_ENABLE - Boolean (defined / not defined) + * + * For n=1-7: + * BOARD_GCLKn_ENABLE - Boolean (defined / not defined) + * + * For n=0-8: + * BOARD_GCLKn_RUN_IN_STANDBY - Boolean (defined / not defined) + * BOARD_GCLKn_CLOCK_SOURCE - See GCLK_GENCTRL_SRC_* definitions + * BOARD_GCLKn_PRESCALER - Value + * BOARD_GCLKn_OUTPUT_ENABLE - Boolean (defined / not defined) + */ + +#define BOARD_GCLK_ENABLE 1 + +/* GCLK generator 0 (Main Clock) - Source is the DFLL */ + +#undef BOARD_GCLK0_RUN_IN_STANDBY +#define BOARD_GCLK0_CLOCK_SOURCE GCLK_GENCTRL_SRC_DFLL48M +#define BOARD_GCLK0_PRESCALER 1 +#undef BOARD_GCLK0_OUTPUT_ENABLE +#define BOARD_GCLK0_FREQUENCY (BOARD_DFLL_FREQUENCY / BOARD_GCLK0_PRESCALER) + +/* Configure GCLK generator 1 - Drives the DFLL */ + +#define BOARD_GCLK1_ENABLE 1 +#undef BOARD_GCLK1_RUN_IN_STANDBY +#define BOARD_GCLK1_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC8M +#define BOARD_GCLK1_PRESCALER 1 +#undef BOARD_GCLK1_OUTPUT_ENABLE +#define BOARD_GCLK1_FREQUENCY (BOARD_OSC8M_FREQUENCY / BOARD_GCLK1_PRESCALER) + +/* Configure GCLK generator 2 (RTC) */ + +#undef BOARD_GCLK2_ENABLE +#undef BOARD_GCLK2_RUN_IN_STANDBY +#define BOARD_GCLK2_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC32K +#define BOARD_GCLK2_PRESCALER 32 +#undef BOARD_GCLK2_OUTPUT_ENABLE +#define BOARD_GCLK2_FREQUENCY (BOARD_OSC8M_FREQUENCY / BOARD_GCLK2_PRESCALER) + +/* Configure GCLK generator 3 */ + +#undef BOARD_GCLK3_ENABLE +#undef BOARD_GCLK3_RUN_IN_STANDBY +#define BOARD_GCLK3_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC8M +#define BOARD_GCLK3_PRESCALER 1 +#undef BOARD_GCLK3_OUTPUT_ENABLE +#define BOARD_GCLK3_FREQUENCY (BOARD_OSC8M_FREQUENCY / BOARD_GCLK3_PRESCALER) + +/* Configure GCLK generator 4 */ + +#undef BOARD_GCLK4_ENABLE +#undef BOARD_GCLK4_RUN_IN_STANDBY +#define BOARD_GCLK4_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC8M +#define BOARD_GCLK4_PRESCALER 1 +#undef BOARD_GCLK4_OUTPUT_ENABLE +#define BOARD_GCLK4_FREQUENCY (BOARD_OSC8M_FREQUENCY / BOARD_GCLK4_PRESCALER) + +/* Configure GCLK generator 5 */ + +#undef BOARD_GCLK5_ENABLE +#undef BOARD_GCLK5_RUN_IN_STANDBY +#define BOARD_GCLK5_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC8M +#define BOARD_GCLK5_PRESCALER 1 +#undef BOARD_GCLK5_OUTPUT_ENABLE +#define BOARD_GCLK5_FREQUENCY (BOARD_OSC8M_FREQUENCY / BOARD_GCLK5_PRESCALER) + +/* Configure GCLK generator 6 */ + +#undef BOARD_GCLK6_ENABLE +#undef BOARD_GCLK6_RUN_IN_STANDBY +#define BOARD_GCLK6_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC8M +#define BOARD_GCLK6_PRESCALER 1 +#undef BOARD_GCLK6_OUTPUT_ENABLE +#define BOARD_GCLK6_FREQUENCY (BOARD_OSC8M_FREQUENCY / BOARD_GCLK6_PRESCALER) + +/* Configure GCLK generator 7 */ + +#undef BOARD_GCLK7_ENABLE +#undef BOARD_GCLK7_RUN_IN_STANDBY +#define BOARD_GCLK7_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC8M +#define BOARD_GCLK7_PRESCALER 1 +#undef BOARD_GCLK7_OUTPUT_ENABLE +#define BOARD_GCLK7_FREQUENCY (BOARD_OSC8M_FREQUENCY / BOARD_GCLK7_PRESCALER) + +/* The source of the main clock is always GCLK_MAIN. Also called GCLKGEN[0], + * this is the clock feeding the Power Manager. + * The Power Manager, in turn, generates main clock which is divided down to + * produce the CPU, AHB, and APB clocks. + * + * The main clock is initially OSC8M divided by 8. + */ + +#define BOARD_GCLK_MAIN_FREQUENCY BOARD_GCLK0_FREQUENCY + +/* Main clock dividers + * + * BOARD_CPU_DIVIDER - See PM_CPUSEL_CPUDIV_* definitions + * BOARD_CPU_FREQUENCY - In Hz + * BOARD_CPU_FAILDECT - Boolean (defined / not defined) + * BOARD_APBA_DIVIDER - See M_APBASEL_APBADIV_* definitions + * BOARD_APBA_FREQUENCY - In Hz + * BOARD_APBB_DIVIDER - See M_APBBSEL_APBBDIV_* definitions + * BOARD_APBB_FREQUENCY - In Hz + * BOARD_APBC_DIVIDER - See M_APBCSEL_APBCDIV_* definitions + * BOARD_APBC_FREQUENCY - In Hz + */ + +#define BOARD_CPU_FAILDECT 1 +#define BOARD_CPU_DIVIDER PM_CPUSEL_CPUDIV_1 +#define BOARD_APBA_DIVIDER PM_APBASEL_APBADIV_1 +#define BOARD_APBB_DIVIDER PM_APBBSEL_APBBDIV_1 +#define BOARD_APBC_DIVIDER PM_APBCSEL_APBCDIV_1 + +/* Resulting frequencies */ + +#define BOARD_MCK_FREQUENCY (BOARD_GCLK_MAIN_FREQUENCY) +#define BOARD_CPU_FREQUENCY (BOARD_MCK_FREQUENCY) +#define BOARD_PBA_FREQUENCY (BOARD_MCK_FREQUENCY) +#define BOARD_PBB_FREQUENCY (BOARD_MCK_FREQUENCY) +#define BOARD_PBC_FREQUENCY (BOARD_MCK_FREQUENCY) +#define BOARD_PBD_FREQUENCY (BOARD_MCK_FREQUENCY) + +/* FLASH wait states + * + * Vdd Range Wait states Maximum Operating Frequency + * ------------- -------------- --------------------------- + * 1.62V to 2.7V 0 14 MHz + * 1 28 MHz + * 2 42 MHz + * 3 48 MHz + * 2.7V to 3.63V 0 24 MHz + * 1 48 MHz + */ + +#if 0 /* REVISIT -- should not be necessary */ +# define BOARD_FLASH_WAITSTATES 1 +#else +# define BOARD_FLASH_WAITSTATES 2 +#endif + +/* SERCOM definitions *******************************************************/ + +/* This is the source clock generator for the GCLK_SERCOM_SLOW clock that is + * common to all SERCOM modules. + */ + +#define BOARD_SERCOM05_SLOW_GCLKGEN 0 + +/* The SERCOM4 USART is available on the pins below. + * + * PIN EXT1 GPIO Function + * ---- ---- ------------------ + * 13 PB09 SERCOM4 / USART RX + * 14 PB08 SERCOM4 / USART TX + * 19 GND N/A + * 20 VCC N/A + * + * If you have a TTL to RS-232 converter then this is the most convenient + * serial console to use (because you don't lose the console device each time + * you lose the USB connection). It is the default in all of the SAMD21 + * configurations. + */ + +#define BOARD_SERCOM4_GCLKGEN 0 +#define BOARD_SERCOM4_SLOW_GCLKGEN BOARD_SERCOM05_SLOW_GCLKGEN + +#if defined(CONFIG_USART4_SERIAL_CONSOLE) +# define BOARD_SERCOM4_MUXCONFIG (USART_CTRLA_RXPAD1 | USART_CTRLA_TXPAD0_1) +# define BOARD_SERCOM4_PINMAP_PAD0 PORT_SERCOM4_PAD0_3 /* USART TX */ +# define BOARD_SERCOM4_PINMAP_PAD1 PORT_SERCOM4_PAD1_3 /* USART RX */ +# define BOARD_SERCOM4_PINMAP_PAD2 0 +# define BOARD_SERCOM4_PINMAP_PAD3 0 +#endif /* CONFIG_USART4_SERIAL_CONSOLE */ + +#define BOARD_SERCOM4_FREQUENCY BOARD_GCLK0_FREQUENCY + +/* USB definitions **********************************************************/ + +/* This is the source clock generator for the GCLK_USB clock + */ + +#define BOARD_USB_GCLKGEN 0 +#define BOARD_USB_FREQUENCY BOARD_GCLK0_FREQUENCY + +/* default USB Pad calibration (not used yet by USB driver) */ + +#define BOARD_USB_PADCAL_P 29 +#define BOARD_USB_PADCAL_N 5 +#define BOARD_USB_PADCAL_TRIM 3 + +/* LED definitions **********************************************************/ + +/* LED index values for use with board_userled() */ + +#define BOARD_STATUS_LED 0 +#define BOARD_NLEDS 1 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_STATUS LED_BIT (1 << BOARD_STATUS_LED) + +/* When CONFIG_ARCH_LEDS is defined in the NuttX configuration, NuttX will + * control the LED as defined below. Thus if the LED is statically on, NuttX + * has successfully booted and is, apparently, running normally. + * If the LED is flashing at approximately 2Hz, then a fatal error + * has been detected and the system has halted. + */ + +#define LED_STARTED 0 /* STATUS LED=OFF */ +#define LED_HEAPALLOCATE 0 /* STATUS LED=OFF */ +#define LED_IRQSENABLED 0 /* STATUS LED=OFF */ +#define LED_STACKCREATED 1 /* STATUS LED=ON */ +#define LED_INIRQ 2 /* STATUS LED=no change */ +#define LED_SIGNAL 2 /* STATUS LED=no change */ +#define LED_ASSERTION 2 /* STATUS LED=no change */ +#define LED_PANIC 3 /* STATUS LED=flashing */ + +#endif /* __BOARDS_ARM_SAMD2L2_XIAO_SEEEDUINO_INCLUDE_BOARD_H */ diff --git a/boards/arm/samd2l2/xiao-seeeduino/scripts/Make.defs b/boards/arm/samd2l2/xiao-seeeduino/scripts/Make.defs new file mode 100644 index 0000000000000..a90a9c5d1ba20 --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/scripts/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# boards/arm/samd2l2/xiao-seeeduino/scripts/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs + +LDSCRIPT = flash.ld +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 diff --git a/boards/arm/samd2l2/xiao-seeeduino/scripts/flash.ld b/boards/arm/samd2l2/xiao-seeeduino/scripts/flash.ld new file mode 100644 index 0000000000000..d276d4098df45 --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/scripts/flash.ld @@ -0,0 +1,112 @@ +/**************************************************************************** + * boards/arm/samd2l2/xiao-seeeduino/scripts/flash.ld + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* The ATSAMD21J18A has 256KB of FLASH beginning at address 0x0000:0000 and + * 32KB of SRAM beginning at address 0x2000:0000 + * However, the XIAO Seeeduino has its UF2 bootloader in the first 8KB. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x00002000, LENGTH = 248K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o) .ctors)) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : { + *(.ARM.extab*) + } >flash + + .ARM.exidx : { + __exidx_start = ABSOLUTE(.); + *(.ARM.exidx*) + __exidx_end = ABSOLUTE(.); + } >flash + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + _eronly = LOADADDR(.data); + + .ramfunc ALIGN(4): { + _sramfuncs = ABSOLUTE(.); + *(.ramfunc .ramfunc.*) + _eramfuncs = ABSOLUTE(.); + } > sram AT > flash + + _framfuncs = LOADADDR(.ramfunc); + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/samd2l2/xiao-seeeduino/src/Makefile b/boards/arm/samd2l2/xiao-seeeduino/src/Makefile new file mode 100644 index 0000000000000..cab39390b0362 --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/src/Makefile @@ -0,0 +1,33 @@ +############################################################################ +# boards/arm/samd2l2/xiao-seeeduino/src/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +CSRCS = sam_boot.c + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += sam_autoleds.c +endif + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += sam_appinit.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/samd2l2/xiao-seeeduino/src/sam_appinit.c b/boards/arm/samd2l2/xiao-seeeduino/src/sam_appinit.c new file mode 100644 index 0000000000000..f951d6497c5e4 --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/src/sam_appinit.c @@ -0,0 +1,71 @@ +/**************************************************************************** + * boards/arm/samd2l2/xiao-seeeduino/src/sam_appinit.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +#include "sam_config.h" +#include "xiao-seeeduino.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ + return OK; +} diff --git a/boards/arm/samd2l2/xiao-seeeduino/src/sam_autoleds.c b/boards/arm/samd2l2/xiao-seeeduino/src/sam_autoleds.c new file mode 100644 index 0000000000000..57c724e7acdb7 --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/src/sam_autoleds.c @@ -0,0 +1,142 @@ +/**************************************************************************** + * boards/arm/samd2l2/xiao-seeeduino/src/sam_autoleds.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* When CONFIG_ARCH_LEDS is defined in the NuttX configuration, NuttX will + * control the LED as follows: + * + * SYMBOL Meaning LED + * ------------------- ----------------------- ------ + * LED_STARTED NuttX has been started OFF + * LED_HEAPALLOCATE Heap has been allocated OFF + * LED_IRQSENABLED Interrupts enabled OFF + * LED_STACKCREATED Idle stack created ON + * LED_INIRQ In an interrupt** N/C + * LED_SIGNAL In a signal handler*** N/C + * LED_ASSERTION An assertion failed N/C + * LED_PANIC The system has crashed FLASH + * + * Thus if the LED is statically on, NuttX has successfully booted and is, + * apparently, running normally. If the LED is flashing at approximately + * 2Hz, then a fatal error has been detected and the system has halted. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "sam_port.h" +#include "xiao-seeeduino.h" + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + sam_configport(PORT_STATUS_LED); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + bool ledstate = true; + + switch (led) + { + case 0: /* LED_STARTED: NuttX has been started STATUS LED=OFF + * LED_HEAPALLOCATE: Heap has been allocated STATUS LED=OFF + * LED_IRQSENABLED: Interrupts enabled STATUS LED=OFF + */ + + break; /* Leave ledstate == true to turn OFF */ + + default: + case 2: /* LED_INIRQ: In an interrupt STATUS LED=N/C + * LED_SIGNAL: In a signal handler STATUS LED=N/C + * LED_ASSERTION: An assertion failed STATUS LED=N/C + */ + + return; /* Return to leave STATUS LED unchanged */ + + case 3: /* LED_PANIC: The system has crashed STATUS LED=FLASH */ + case 1: /* LED_STACKCREATED: Idle stack created STATUS LED=ON */ + + ledstate = false; /* Set ledstate == false to turn ON */ + break; + } + + sam_portwrite(PORT_STATUS_LED, ledstate); +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + switch (led) + { + /* These should not happen and are ignored */ + + default: + case 0: /* LED_STARTED: NuttX has been started STATUS LED=OFF + * LED_HEAPALLOCATE: Heap has been allocated STATUS LED=OFF + * LED_IRQSENABLED: Interrupts enabled STATUS LED=OFF + */ + + case 1: /* LED_STACKCREATED: Idle stack created STATUS LED=ON */ + + /* These result in no-change */ + + case 2: /* LED_INIRQ: In an interrupt STATUS LED=N/C + * LED_SIGNAL: In a signal handler STATUS LED=N/C + * LED_ASSERTION: An assertion failed STATUS LED=N/C + */ + + return; /* Return to leave STATUS LED unchanged */ + + /* Turn STATUS LED off set driving the output high */ + + case 3: /* LED_PANIC: The system has crashed STATUS LED=FLASH */ + sam_portwrite(PORT_STATUS_LED, true); + break; + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm/samd2l2/xiao-seeeduino/src/sam_boot.c b/boards/arm/samd2l2/xiao-seeeduino/src/sam_boot.c new file mode 100644 index 0000000000000..8f7f041242156 --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/src/sam_boot.c @@ -0,0 +1,64 @@ +/**************************************************************************** + * boards/arm/samd2l2/xiao-seeeduino/src/sam_boot.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#include "sam_config.h" +#include "xiao-seeeduino.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_boardinitialize + * + * Description: + * All SAM3U architectures must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have been + * initialized. + * + ****************************************************************************/ + +void sam_boardinitialize(void) +{ + /* Configure on-board LEDs if LED support has been selected. */ + +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif +} diff --git a/boards/arm/samd2l2/xiao-seeeduino/src/xiao-seeeduino.h b/boards/arm/samd2l2/xiao-seeeduino/src/xiao-seeeduino.h new file mode 100644 index 0000000000000..d15dce7480e7c --- /dev/null +++ b/boards/arm/samd2l2/xiao-seeeduino/src/xiao-seeeduino.h @@ -0,0 +1,89 @@ +/**************************************************************************** + * boards/arm/samd2l2/xiao-seeeduino/src/xiao-seeeduino.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_SAMD2L2_XIAO_SEEEDUINO_SRC_XIAO_SEEEDUINO_H +#define __BOARDS_ARM_SAMD2L2_XIAO_SEEEDUINO_SRC_XIAO_SEEEDUINO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include + +#include +#include + +#include "sam_config.h" +#include "sam_pinmap.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LEDs: + * There are three LEDs on board the SAMD21 Xplained Pro board: The EDBG + * controls two of the LEDs, a power LED and a status LED. There is only + * one user controllable LED, a yellow LED labelled STATIS near the SAMD21 + * USB connector. + * + * This LED is controlled by PB30 and the LED can be activated by driving + * PB30 to GND. + * + * When CONFIG_ARCH_LEDS is defined in the NuttX configuration, NuttX will + * control the LED as follows: + * + * SYMBOL Meaning LED + * ------------------- ----------------------- ------ + * LED_STARTED NuttX has been started OFF + * LED_HEAPALLOCATE Heap has been allocated OFF + * LED_IRQSENABLED Interrupts enabled OFF + * LED_STACKCREATED Idle stack created ON + * LED_INIRQ In an interrupt N/C + * LED_SIGNAL In a signal handler N/C + * LED_ASSERTION An assertion failed N/C + * LED_PANIC The system has crashed FLASH + * + * Thus if the LED is statically on, NuttX has successfully booted and is, + * apparently, running normally. If the LED is flashing at approximately + * 2Hz, then a fatal error has been detected and the system has halted. + */ + +#define PORT_STATUS_LED (PORT_OUTPUT | PORT_PULL_NONE | PORT_OUTPUT_SET | \ + PORTA | PORT_PIN4) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions Definitions + ****************************************************************************/ + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_SAMD2L2_XIAO_SEEEDUINO_SRC_XIAO_SEEEDUINO_H */