boards/arm/samd2l2/arduino-m0: Add initial board support for the Arduino M0.
This commit is contained in:
parent
8eafe880dc
commit
35227fb873
@ -216,6 +216,8 @@ nuttx/
|
||||
| | | `- sama5d4-ek/
|
||||
| | | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/boards/arm/sama5/sama5d4-ek/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
||||
| | |- samd2l2/
|
||||
| | | |- arduino-m0/
|
||||
| | | | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/boards/arm/samd2l2/arduino-m0/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
||||
| | | |- samd20-xplained/
|
||||
| | | | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/boards/arm/samd2l2/samd20-xplained/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
||||
| | | |- samd21-xplained/
|
||||
|
@ -1921,6 +1921,8 @@ nuttx/
|
||||
| | | `- sama5d4-ek/
|
||||
| | | `- README.txt
|
||||
| | |- samd2l2/
|
||||
| | | |- arduino-m0/
|
||||
| | | | `- README.txt
|
||||
| | | |- samd20-xplained/
|
||||
| | | | `- README.txt
|
||||
| | | |- samd21-xplained/
|
||||
|
@ -35,6 +35,14 @@ config ARCH_BOARD_ARDUINO_DUE
|
||||
This options selects the Arduino DUE board featuring the Atmel
|
||||
ATSAM3X8E MCU running at 84 MHz.
|
||||
|
||||
config ARCH_BOARD_ARDUINO_M0
|
||||
bool "Arduino M0"
|
||||
depends on ARCH_CHIP_SAMD21G18A
|
||||
select ARCH_HAVE_LEDS
|
||||
---help---
|
||||
This options selects the Arduino M0 board featuring the Atmel
|
||||
ATSAMD21 MCU.
|
||||
|
||||
config ARCH_BOARD_AVR32DEV1
|
||||
bool "Atmel AVR32DEV1 board"
|
||||
depends on ARCH_CHIP_AT32UC3B0256
|
||||
@ -1906,6 +1914,7 @@ config ARCH_BOARD
|
||||
default "amber" if ARCH_BOARD_AMBER
|
||||
default "arduino-mega2560" if ARCH_BOARD_ARDUINO_MEGA2560
|
||||
default "arduino-due" if ARCH_BOARD_ARDUINO_DUE
|
||||
default "arduino-m0" if ARCH_BOARD_ARDUINO_M0
|
||||
default "avr32dev1" if ARCH_BOARD_AVR32DEV1
|
||||
default "axoloti" if ARCH_BOARD_AXOLOTI
|
||||
default "bambino-200e" if ARCH_BOARD_BAMBINO_200E
|
||||
@ -2281,6 +2290,9 @@ endif
|
||||
if ARCH_BOARD_ARDUINO_DUE
|
||||
source "boards/arm/sam34/arduino-due/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_ARDUINO_M0
|
||||
source "boards/arm/samd2l2/arduino-m0/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_FLIPNCLICK_SAM3X
|
||||
source "boards/arm/sam34/flipnclick-sam3x/Kconfig"
|
||||
endif
|
||||
|
8
boards/arm/samd2l2/arduino-m0/Kconfig
Normal file
8
boards/arm/samd2l2/arduino-m0/Kconfig
Normal file
@ -0,0 +1,8 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if ARCH_BOARD_ARDUINO_M0
|
||||
|
||||
endif
|
143
boards/arm/samd2l2/arduino-m0/README.txt
Normal file
143
boards/arm/samd2l2/arduino-m0/README.txt
Normal file
@ -0,0 +1,143 @@
|
||||
README
|
||||
======
|
||||
|
||||
This README discusses issues unique to NuttX configurations for the
|
||||
Arduino M0. I used a compatible board called Wemos SAMD21 M0 board,
|
||||
but there are other equivalent boards, like the RobotDyn SAMD21 M0.
|
||||
|
||||
Unfortunately because the Arduino.cc vs Arduino.org conflict in the past,
|
||||
we have three types of boards: Arduino Zero, Arduino M0 and Arduino M0 Pro.
|
||||
|
||||
The Wemos SAMD21 M0 is compatible with Arduino M0, but not exactly a clone.
|
||||
|
||||
You have two options to program it: using the SWD (EDBG) connector that
|
||||
comes in the board or the Arduino M0 bootloader that comes flashed on it.
|
||||
Currently only SWD programming is supported. Bootloader skip area should be
|
||||
implemented to avoid overwriting the bootloader area.
|
||||
|
||||
The board uses the ATSAMD21G18A MCU and can work over the Native USB Port.
|
||||
|
||||
Contents
|
||||
========
|
||||
|
||||
- STATUS/ISSUES
|
||||
- LEDs
|
||||
- Serial Consoles
|
||||
- Configurations
|
||||
|
||||
STATUS/ISSUES
|
||||
=============
|
||||
|
||||
Because the Arduino M0 doesn't have a 12MHz crystal, it uses the internal
|
||||
RC oscillator.
|
||||
|
||||
LEDs
|
||||
====
|
||||
|
||||
There is one yellow LED available on the Arduino M0 and it can be turned
|
||||
on and off. The LED can be activated by driving the connected
|
||||
PA17 I/O line to high level.
|
||||
|
||||
When CONFIG_ARCH_LEDS is defined in the NuttX configuration, NuttX will
|
||||
control the LED as follows:
|
||||
|
||||
SYMBOL Meaning LED0
|
||||
------------------- ----------------------- ------
|
||||
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 is LED is statically on, NuttX has successfully booted and is,
|
||||
apparently, running normally. If LED is flashing at approximately
|
||||
2Hz, then a fatal error has been detected and the system has halted.
|
||||
|
||||
Serial Consoles
|
||||
===============
|
||||
|
||||
SERCOM5
|
||||
------
|
||||
|
||||
SERCOM5 is available on pins PB22 (TXD) and PB23 (RXD). You will need to
|
||||
solder a two pins header to RXD and TXD labels, near to ICSP pin header.
|
||||
|
||||
PIN GPIO Function
|
||||
---- ---- ------------------
|
||||
37 PB22 SERCOM5 / USART RX
|
||||
38 PB23 SERCOM5 / USART TX
|
||||
|
||||
If you have a 3.3V USB/Serial adapter 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 these
|
||||
configurations. An option is to use the virtual COM port.
|
||||
|
||||
Native USB Port
|
||||
---------------
|
||||
|
||||
You can access the NSH shell directly using the USB connector. All you need
|
||||
to do is use the "usbnsh" board profile.
|
||||
|
||||
Configurations
|
||||
==============
|
||||
|
||||
Each Arduino M0 configuration is maintained in a sub-directory and
|
||||
can be selected as follow:
|
||||
|
||||
tools/configure.sh arduino-m0:<subdir>
|
||||
|
||||
Before building, make sure the PATH environment variable include the
|
||||
correct path to the directory than holds your toolchain binaries.
|
||||
|
||||
And then build NuttX by simply typing the following. At the conclusion of
|
||||
the make, the nuttx binary will reside in an ELF file called, simply, nuttx.
|
||||
|
||||
make
|
||||
|
||||
The <subdir> that is provided above as an argument to the tools/configure.sh
|
||||
must be is one of the following.
|
||||
|
||||
NOTE: These configurations use the mconf-based configuration tool. To
|
||||
change any of these configurations using that tool, you should:
|
||||
|
||||
a. Build and install the kconfig-mconf tool. See nuttx/README.txt
|
||||
see additional README.txt files in the NuttX tools repository.
|
||||
|
||||
b. Execute 'make menuconfig' in nuttx/ in order to start the
|
||||
reconfiguration process.
|
||||
|
||||
NOTES:
|
||||
|
||||
1. These configurations use the mconf-based configuration tool. To
|
||||
change any of these configurations using that tool, you should:
|
||||
|
||||
a. Build and install the kconfig-mconf tool. See nuttx/README.txt
|
||||
see additional README.txt files in the NuttX tools repository.
|
||||
|
||||
b. Execute 'make menuconfig' in nuttx/ in order to start the
|
||||
reconfiguration process.
|
||||
|
||||
Configuration sub-directories
|
||||
-----------------------------
|
||||
|
||||
nsh:
|
||||
This configuration directory will built the NuttShell. See NOTES above
|
||||
and below:
|
||||
|
||||
NOTES:
|
||||
|
||||
1. This configuration is set up to build on Windows using the Cygwin
|
||||
environment using the CodeSourcery toolchain. This can be easily
|
||||
changed as described above under "Configurations."
|
||||
|
||||
2. By default, this configuration provides a serial console on SERCOM5
|
||||
at 115200 8N1 via RXD/TXD pads:
|
||||
|
||||
PIN EXT3 GPIO Function
|
||||
---- ---- ------------------
|
||||
37 PB22 SERCOM5 / USART RX
|
||||
38 PB23 SERCOM5 / USART TX
|
||||
|
71
boards/arm/samd2l2/arduino-m0/configs/nsh/defconfig
Normal file
71
boards/arm/samd2l2/arduino-m0/configs/nsh/defconfig
Normal file
@ -0,0 +1,71 @@
|
||||
#
|
||||
# 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_WGET is not set
|
||||
# CONFIG_NSH_DISABLE_XD is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="arduino-m0"
|
||||
CONFIG_ARCH_BOARD_ARDUINO_M0=y
|
||||
CONFIG_ARCH_CHIP="samd2l2"
|
||||
CONFIG_ARCH_CHIP_SAMD21G18A=y
|
||||
CONFIG_ARCH_CHIP_SAMD2X=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=3410
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEFAULT_SMALL=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=4
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=1536
|
||||
CONFIG_RAM_SIZE=32768
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SAMD2L2_SERCOM3=y
|
||||
CONFIG_SAMD2L2_SERCOM4=y
|
||||
CONFIG_SAMD2L2_SERCOM5=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=21
|
||||
CONFIG_START_MONTH=6
|
||||
CONFIG_START_YEAR=2015
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
|
||||
CONFIG_USART3_RXBUFSIZE=64
|
||||
CONFIG_USART3_TXBUFSIZE=64
|
||||
CONFIG_USART4_RXBUFSIZE=64
|
||||
CONFIG_USART4_TXBUFSIZE=64
|
||||
CONFIG_USART5_SERIAL_CONSOLE=y
|
||||
CONFIG_USERMAIN_STACKSIZE=1536
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WDOG_INTRESERVE=0
|
532
boards/arm/samd2l2/arduino-m0/include/board.h
Normal file
532
boards/arm/samd2l2/arduino-m0/include/board.h
Normal file
@ -0,0 +1,532 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samd2l2/arduino-m0/include/board.h
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BOARDS_ARM_SAMD2L2_ARDUINO_M0_INCLUDE_BOARD_H
|
||||
#define __BOARDS_ARM_SAMD2L2_ARDUINO_M0_INCLUDE_BOARD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
# ifdef CONFIG_SAMD2L2_GPIOIRQ
|
||||
# include <arch/irq.h>
|
||||
# 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 Arduino M0 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_FRQUENCY - In Hz
|
||||
* BOARD_CPU_FAILDECT - Boolean (defined / not defined)
|
||||
* BOARD_APBA_DIVIDER - See M_APBASEL_APBADIV_* definitions
|
||||
* BOARD_APBA_FRQUENCY - In Hz
|
||||
* BOARD_APBB_DIVIDER - See M_APBBSEL_APBBDIV_* definitions
|
||||
* BOARD_APBB_FRQUENCY - In Hz
|
||||
* BOARD_APBC_DIVIDER - See M_APBCSEL_APBCDIV_* definitions
|
||||
* BOARD_APBC_FRQUENCY - 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
|
||||
|
||||
/* SERCOM0 SPI is available on EXT1
|
||||
*
|
||||
* PIN PORT SERCOM FUNCTION
|
||||
* --- ------------------ -----------
|
||||
* 15 PA5 SERCOM0 PAD1 SPI SS
|
||||
* 16 PA6 SERCOM0 PAD2 SPI MOSI
|
||||
* 17 PA4 SERCOM0 PAD0 SPI MISO
|
||||
* 18 PA7 SERCOM0 PAD3 SPI SCK
|
||||
*/
|
||||
|
||||
#define BOARD_SERCOM0_GCLKGEN 0
|
||||
#define BOARD_SERCOM0_SLOW_GCLKGEN BOARD_SERCOM05_SLOW_GCLKGEN
|
||||
#define BOARD_SERCOM0_MUXCONFIG (SPI_CTRLA_DOPO_DOPAD231 | SPI_CTRLA_DIPAD0)
|
||||
#define BOARD_SERCOM0_PINMAP_PAD0 PORT_SERCOM0_PAD0_2 /* SPI_MISO */
|
||||
#define BOARD_SERCOM0_PINMAP_PAD1 0 /* microSD_SS */
|
||||
#define BOARD_SERCOM0_PINMAP_PAD2 PORT_SERCOM0_PAD2_2 /* SPI_MOSI */
|
||||
#define BOARD_SERCOM0_PINMAP_PAD3 PORT_SERCOM0_PAD3_2 /* SPI_SCK */
|
||||
|
||||
#define BOARD_SERCOM0_FREQUENCY BOARD_GCLK0_FREQUENCY
|
||||
|
||||
/* SERCOM1 SPI is available on EXT2
|
||||
*
|
||||
* PIN PORT SERCOM FUNCTION
|
||||
* --- ------------------ -----------
|
||||
* 15 PA17 SERCOM1 PAD1 SPI SS
|
||||
* 16 PA18 SERCOM1 PAD2 SPI MOSI
|
||||
* 17 PA16 SERCOM1 PAD0 SPI MISO
|
||||
* 18 PA19 SERCOM1 PAD3 SPI SCK
|
||||
*/
|
||||
|
||||
#define BOARD_SERCOM1_GCLKGEN 0
|
||||
#define BOARD_SERCOM1_SLOW_GCLKGEN BOARD_SERCOM05_SLOW_GCLKGEN
|
||||
#define BOARD_SERCOM1_MUXCONFIG (SPI_CTRLA_DOPO_DOPAD231 | SPI_CTRLA_DIPAD0)
|
||||
#define BOARD_SERCOM1_PINMAP_PAD0 PORT_SERCOM1_PAD0_1 /* SPI_MISO */
|
||||
#define BOARD_SERCOM1_PINMAP_PAD1 0 /* microSD_SS */
|
||||
#define BOARD_SERCOM1_PINMAP_PAD2 PORT_SERCOM1_PAD2_1 /* SPI_MOSI */
|
||||
#define BOARD_SERCOM1_PINMAP_PAD3 PORT_SERCOM1_PAD3_1 /* SPI_SCK */
|
||||
|
||||
#define BOARD_SERCOM1_FREQUENCY BOARD_GCLK0_FREQUENCY
|
||||
|
||||
/* The Arduino M0 contains an Embedded Debugger (EDBG) that can be
|
||||
* used to program and debug the ATSAMD21J18A using Serial Wire Debug (SWD).
|
||||
* The Embedded debugger also include a Virtual COM port interface over
|
||||
* SERCOM3. Virtual COM port connections:
|
||||
*
|
||||
* PA22 SERCOM3 PAD[0] / USART TXD
|
||||
* PA23 SERCOM3 PAD[1] / USART RXD
|
||||
*/
|
||||
|
||||
#define BOARD_SERCOM3_GCLKGEN 0
|
||||
#define BOARD_SERCOM3_SLOW_GCLKGEN BOARD_SERCOM05_SLOW_GCLKGEN
|
||||
#define BOARD_SERCOM3_MUXCONFIG (USART_CTRLA_RXPAD1 | USART_CTRLA_TXPAD0_1)
|
||||
#define BOARD_SERCOM3_PINMAP_PAD0 PORT_SERCOM3_PAD0_1 /* USART TX */
|
||||
#define BOARD_SERCOM3_PINMAP_PAD1 PORT_SERCOM3_PAD1_1 /* USART RX */
|
||||
#define BOARD_SERCOM3_PINMAP_PAD2 0
|
||||
#define BOARD_SERCOM3_PINMAP_PAD3 0
|
||||
|
||||
#define BOARD_SERCOM3_FREQUENCY BOARD_GCLK0_FREQUENCY
|
||||
|
||||
/* The SERCOM4 USART is available on connectors EXT1, EXT2, and EXT3
|
||||
*
|
||||
* PIN EXT1 EXT2 EXT3 GPIO Function
|
||||
* ---- ---- ---- ---- ------------------
|
||||
* 13 PB09 PB10 PB10 SERCOM4 / USART RX
|
||||
* 14 PB08 PB11 PB11 SERCOM4 / USART TX
|
||||
* 19 GND GND GND N/A
|
||||
* 20 VCC VCC 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_ARDUINO_M0_USART4_EXT1)
|
||||
# define BOARD_SERCOM4_MUXCONFIG (USART_CTRLA_RXPAD1 | USART_CTRLA_TXPAD0)
|
||||
# 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
|
||||
#elif defined(CONFIG_ARDUINO_M0_USART4_EXT2)
|
||||
# define BOARD_SERCOM4_MUXCONFIG (USART_CTRLA_RXPAD3 | USART_CTRLA_TXPAD2)
|
||||
# define BOARD_SERCOM4_PINMAP_PAD0 0
|
||||
# define BOARD_SERCOM4_PINMAP_PAD1 0
|
||||
# define BOARD_SERCOM4_PINMAP_PAD2 PORT_SERCOM4_PAD2_3 /* USART TX */
|
||||
# define BOARD_SERCOM4_PINMAP_PAD3 PORT_SERCOM4_PAD3_3 /* USART RX */
|
||||
#else /* if defined(CONFIG_ARDUINO_M0_USART4_EXT3) */
|
||||
# define BOARD_SERCOM4_MUXCONFIG (USART_CTRLA_RXPAD3 | USART_CTRLA_TXPAD2)
|
||||
# define BOARD_SERCOM4_PINMAP_PAD0 0
|
||||
# define BOARD_SERCOM4_PINMAP_PAD1 0
|
||||
# define BOARD_SERCOM4_PINMAP_PAD2 PORT_SERCOM4_PAD2_3 /* USART TX */
|
||||
# define BOARD_SERCOM4_PINMAP_PAD3 PORT_SERCOM4_PAD3_3 /* USART RX */
|
||||
#endif
|
||||
|
||||
#define BOARD_SERCOM4_FREQUENCY BOARD_GCLK0_FREQUENCY
|
||||
|
||||
/* SERCOM5 USART used to Serial Console
|
||||
*
|
||||
* PIN PORT SERCOM FUNCTION
|
||||
* --- ------------------ -----------
|
||||
* 31 PB02 SERCOM5 PAD0 USART TXD
|
||||
* 32 PB03 SERCOM5 PAD1 USART RXD
|
||||
*/
|
||||
|
||||
#define BOARD_SERCOM5_GCLKGEN 0
|
||||
#define BOARD_SERCOM5_SLOW_GCLKGEN BOARD_SERCOM05_SLOW_GCLKGEN
|
||||
#define BOARD_SERCOM5_MUXCONFIG (USART_CTRLA_RXPAD3 | USART_CTRLA_TXPAD2)
|
||||
#define BOARD_SERCOM5_PINMAP_PAD0 0
|
||||
#define BOARD_SERCOM5_PINMAP_PAD1 0
|
||||
#define BOARD_SERCOM5_PINMAP_PAD2 PORT_SERCOM5_PAD2_4 /* USART 5 TXD */
|
||||
#define BOARD_SERCOM5_PINMAP_PAD3 PORT_SERCOM5_PAD3_4 /* USART 5 RXD */
|
||||
|
||||
#define BOARD_SERCOM5_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 **********************************************************/
|
||||
|
||||
/* There are three LEDs on board the Arduino M0 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 STATUS near the SAMD21
|
||||
* USB connector.
|
||||
*
|
||||
* This LED is controlled by PC07 and the LED can be activated by driving
|
||||
* the PB30 to GND.
|
||||
*/
|
||||
|
||||
/* 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 */
|
||||
|
||||
/* Button definitions *******************************************************/
|
||||
|
||||
/* Mechanical buttons:
|
||||
*
|
||||
* The Arduino M0 doesn't contain mechanical buttons.
|
||||
*/
|
||||
|
||||
#define NUM_BUTTONS 0
|
||||
|
||||
#endif /* __BOARDS_ARM_SAMD2L2_ARDUINO_M0_INCLUDE_BOARD_H */
|
124
boards/arm/samd2l2/arduino-m0/scripts/Make.defs
Normal file
124
boards/arm/samd2l2/arduino-m0/scripts/Make.defs
Normal file
@ -0,0 +1,124 @@
|
||||
############################################################################
|
||||
# boards/arm/samd2l2/arduino-m0/scripts/Make.defs
|
||||
#
|
||||
# Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include ${TOPDIR}/.config
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
include ${TOPDIR}/arch/arm/src/armv6-m/Toolchain.defs
|
||||
|
||||
LDSCRIPT = flash.ld
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
# Windows-native toolchains
|
||||
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
||||
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
||||
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
|
||||
else
|
||||
# Linux/Cygwin-native toolchain
|
||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||
ARCHSCRIPT = -T$(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
|
||||
endif
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
CPP = $(CROSSDEV)gcc -E
|
||||
LD = $(CROSSDEV)ld
|
||||
STRIP = $(CROSSDEV)strip --strip-unneeded
|
||||
AR = $(ARCROSSDEV)ar rcs
|
||||
NM = $(ARCROSSDEV)nm
|
||||
OBJCOPY = $(CROSSDEV)objcopy
|
||||
OBJDUMP = $(CROSSDEV)objdump
|
||||
|
||||
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
|
||||
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
ARCHOPTIMIZATION = -g
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_DEBUG_NOOPT),y)
|
||||
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
|
||||
endif
|
||||
|
||||
ARCHCFLAGS = -fno-builtin
|
||||
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
|
||||
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
|
||||
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
|
||||
ARCHDEFINES =
|
||||
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
|
||||
|
||||
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
|
||||
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
|
||||
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
|
||||
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
|
||||
|
||||
ASMEXT = .S
|
||||
OBJEXT = .o
|
||||
LIBEXT = .a
|
||||
EXEEXT =
|
||||
|
||||
ifneq ($(CROSSDEV),arm-nuttx-elf-)
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTINCLUDES = -I.
|
||||
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
|
||||
HOSTLDFLAGS =
|
||||
ifeq ($(CONFIG_HOST_WINDOWS),y)
|
||||
HOSTEXEEXT = .exe
|
||||
else
|
||||
HOSTEXEEXT =
|
||||
endif
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
# Windows-native host tools
|
||||
DIRLINK = $(TOPDIR)/tools/copydir.sh
|
||||
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
|
||||
MKDEP = $(TOPDIR)/tools/mkwindeps.sh
|
||||
else
|
||||
# Linux/Cygwin-native host tools
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
|
||||
endif
|
126
boards/arm/samd2l2/arduino-m0/scripts/flash.ld
Normal file
126
boards/arm/samd2l2/arduino-m0/scripts/flash.ld
Normal file
@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samd2l2/arduino-m0/scripts/flash.ld
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* The ATSAMD21J18A has 256KB of FLASH beginning at address 0x0000:0000 and
|
||||
* 32KB of SRAM beginning at address 0x2000:0000
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash (rx) : ORIGIN = 0x00000000, LENGTH = 256K
|
||||
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(.);
|
||||
*(.init_array .init_array.*)
|
||||
_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) }
|
||||
}
|
2
boards/arm/samd2l2/arduino-m0/src/.gitignore
vendored
Normal file
2
boards/arm/samd2l2/arduino-m0/src/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/.depend
|
||||
/Make.dep
|
59
boards/arm/samd2l2/arduino-m0/src/Makefile
Normal file
59
boards/arm/samd2l2/arduino-m0/src/Makefile
Normal file
@ -0,0 +1,59 @@
|
||||
############################################################################
|
||||
# boards/arm/samd2l2/arduino-m0/src/Makefile
|
||||
#
|
||||
# Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
ASRCS =
|
||||
CSRCS = sam_boot.c
|
||||
|
||||
ifeq ($(CONFIG_SAMD2L2_SERCOM0),y)
|
||||
CSRCS += sam_spi.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_LEDS),y)
|
||||
CSRCS += sam_autoleds.c
|
||||
else
|
||||
CSRCS += sam_userleds.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_BUTTONS),y)
|
||||
CSRCS += sam_buttons.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||
CSRCS += sam_appinit.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/boards/Board.mk
|
111
boards/arm/samd2l2/arduino-m0/src/arduino_m0.h
Normal file
111
boards/arm/samd2l2/arduino-m0/src/arduino_m0.h
Normal file
@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samd2l2/arduino-m0/src/arduino_m0.h
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BOARDS_ARM_SAMD2L2_ARDUINO_M0_SRC_ARDUINO_M0_H
|
||||
#define __BOARDS_ARM_SAMD2L2_ARDUINO_M0_SRC_ARDUINO_M0_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "sam_config.h"
|
||||
#include "sam_pinmap.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* LEDs:
|
||||
* There is a LED on board the Arduino M0 board.
|
||||
*
|
||||
* This LED is controlled by PA17 and the LED can be activated by driving
|
||||
* PA17 to High.
|
||||
*
|
||||
* 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_PIN17)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spidev_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select PORT pins for the SAM3U-EK board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void weak_function sam_spidev_initialize(void);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_ARM_SAMD2L2_ARDUINO_M0_SRC_ARDUINO_M0_H */
|
86
boards/arm/samd2l2/arduino-m0/src/sam_appinit.c
Normal file
86
boards/arm/samd2l2/arduino-m0/src/sam_appinit.c
Normal file
@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samd2l2/arduino-m0/src/sam_appinit.c
|
||||
*
|
||||
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "sam_config.h"
|
||||
#include "arduino_m0.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 cold 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;
|
||||
}
|
157
boards/arm/samd2l2/arduino-m0/src/sam_autoleds.c
Normal file
157
boards/arm/samd2l2/arduino-m0/src/sam_autoleds.c
Normal file
@ -0,0 +1,157 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samd2l2/arduino-m0/src/sam_autoleds.c
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* There is a LED on board the Arduino M0 board.
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "sam_port.h"
|
||||
#include "arduino_m0.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_autoled_initialize
|
||||
****************************************************************************/
|
||||
|
||||
void board_autoled_initialize(void)
|
||||
{
|
||||
(void)sam_configport(PORT_STATUS_LED);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_autoled_on
|
||||
****************************************************************************/
|
||||
|
||||
void board_autoled_on(int led)
|
||||
{
|
||||
bool ledstate = false;
|
||||
|
||||
switch (led)
|
||||
{
|
||||
case 0: /* LED_STARTED: NuttX has been started STATUS LED=ON
|
||||
* LED_HEAPALLOCATE: Heap has been allocated STATUS LED=ON
|
||||
* LED_IRQSENABLED: Interrupts enabled STATUS LED=ON
|
||||
*/
|
||||
|
||||
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 = true; /* Set ledstate == false to turn OFF */
|
||||
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, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
92
boards/arm/samd2l2/arduino-m0/src/sam_boot.c
Normal file
92
boards/arm/samd2l2/arduino-m0/src/sam_boot.c
Normal file
@ -0,0 +1,92 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samd2l2/arduino-m0/src/sam_boot.c
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "sam_config.h"
|
||||
#include "arduino_m0.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_boardinitialize
|
||||
*
|
||||
* Description:
|
||||
* All SAMD21 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 SPI chip selects if
|
||||
* 1) SPI is not disabled, and
|
||||
* 2) the weak function
|
||||
* sam_spidev_initialize() has been brought into the link.
|
||||
*/
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI
|
||||
if (sam_spidev_initialize)
|
||||
{
|
||||
sam_spidev_initialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Configure on-board LEDs if LED support has been selected. */
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
board_autoled_initialize();
|
||||
#endif
|
||||
}
|
303
boards/arm/samd2l2/arduino-m0/src/sam_spi.c
Normal file
303
boards/arm/samd2l2/arduino-m0/src/sam_spi.c
Normal file
@ -0,0 +1,303 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samd2l2/arduino-m0/src/sam_spi.c
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
#include "sam_config.h"
|
||||
#include "sam_port.h"
|
||||
#include "sam_spi.h"
|
||||
|
||||
#include "arduino_m0.h"
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spidev_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select PORT pins for the SAMD21 Xplained
|
||||
* Pro board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void weak_function sam_spidev_initialize(void)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spi[n]select, sam_spi[n]status, and sam_spi[n]cmddata
|
||||
*
|
||||
* Description:
|
||||
* These external functions must be provided by board-specific logic. They
|
||||
* include:
|
||||
*
|
||||
* o sam_spi[n]select is a functions to manage the board-specific chip
|
||||
* selects
|
||||
* o sam_spi[n]status and sam_spi[n]cmddata: Implementations of the status
|
||||
* and cmddata methods of the SPI interface defined by struct spi_ops_
|
||||
* (see include/nuttx/spi/spi.h). All other methods including
|
||||
* sam_spibus_initialize()) are provided by common SAMD/L logic.
|
||||
*
|
||||
* Where [n] is the SERCOM number for the SPI module.
|
||||
*
|
||||
* To use this common SPI logic on your board:
|
||||
*
|
||||
* 1. Provide logic in sam_boardinitialize() to configure SPI chip select
|
||||
* pins.
|
||||
* 2. Provide sam_spi[n]select() and sam_spi[n]status() functions in your
|
||||
* board-specific logic. These functions will perform chip selection
|
||||
* and status operations using GPIOs in the way your board is configured.
|
||||
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
|
||||
* sam_spi[n]cmddata() functions in your board-specific logic. This
|
||||
* function will perform cmd/data selection operations using GPIOs in
|
||||
* the way your board is configured.
|
||||
* 3. Add a call to sam_spibus_initialize() in your low level application
|
||||
* initialization logic
|
||||
* 4. The handle returned by sam_spibus_initialize() may then be used to
|
||||
* bind the SPI driver to higher level logic (e.g., calling
|
||||
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
||||
* the SPI MMC/SD driver).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spi[n]select
|
||||
*
|
||||
* Description:
|
||||
* PIO chip select pins may be programmed by the board specific logic in
|
||||
* one of two different ways. First, the pins may be programmed as SPI
|
||||
* peripherals. In that case, the pins are completely controlled by the
|
||||
* SPI driver. This method still needs to be provided, but it may be only
|
||||
* a stub.
|
||||
*
|
||||
* An alternative way to program the PIO chip select pins is as a normal
|
||||
* GPIO output. In that case, the automatic control of the CS pins is
|
||||
* bypassed and this function must provide control of the chip select.
|
||||
* NOTE: In this case, the GPIO output pin does *not* have to be the
|
||||
* same as the NPCS pin normal associated with the chip select number.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - SPI device info
|
||||
* devid - Identifies the (logical) device
|
||||
* selected - TRUE:Select the device, FALSE:De-select the device
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI0
|
||||
void sam_spi0select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool selected)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI1
|
||||
void sam_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool selected)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI2
|
||||
void sam_spi2select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool selected)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI3
|
||||
void sam_spi3select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool selected)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI4
|
||||
void sam_spi4select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool selected)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI5
|
||||
void sam_spi5select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool selected)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spi[n]status
|
||||
*
|
||||
* Description:
|
||||
* Return status information associated with the SPI device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - SPI device info
|
||||
* devid - Identifies the (logical) device
|
||||
*
|
||||
* Returned Value:
|
||||
* Bit-encoded SPI status (see include/nuttx/spi/spi.h.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI0
|
||||
uint8_t sam_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI1
|
||||
uint8_t sam_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI2
|
||||
uint8_t sam_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI3
|
||||
uint8_t sam_spi3status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI4
|
||||
uint8_t sam_spi4status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI5
|
||||
uint8_t sam_spi5status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spi[n]cmddata
|
||||
*
|
||||
* Description:
|
||||
* Some SPI devices require an additional control to determine if the SPI
|
||||
* data being sent is a command or is data. If CONFIG_SPI_CMDDATA then
|
||||
* this function will be called to different be command and data transfers.
|
||||
*
|
||||
* This is often needed, for example, by LCD drivers. Some LCD hardware
|
||||
* may be configured to use 9-bit data transfers with the 9th bit
|
||||
* indicating command or data. That same hardware may be configurable,
|
||||
* instead, to use 8-bit data but to require an additional, board-
|
||||
* specific GPIO control to distinguish command and data. This function
|
||||
* would be needed in that latter case.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - SPI device info
|
||||
* devid - Identifies the (logical) device
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success; a negated errno on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
#ifdef SAMD2L2_HAVE_SPI0
|
||||
int sam_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI1
|
||||
int sam_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI2
|
||||
int sam_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI3
|
||||
int sam_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI4
|
||||
int sam_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMD2L2_HAVE_SPI5
|
||||
int sam_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_SPI_CMDDATA */
|
||||
#endif /* SAMD2L2_HAVE_SPI */
|
118
boards/arm/samd2l2/arduino-m0/src/sam_userleds.c
Normal file
118
boards/arm/samd2l2/arduino-m0/src/sam_userleds.c
Normal file
@ -0,0 +1,118 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samd2l2/arduino-m0/src/sam_userleds.c
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* There is a LED on board the Arduino M0.
|
||||
*
|
||||
* This LED is controlled by PA17 and the LED can be activated by driving PA17
|
||||
* to High.
|
||||
*
|
||||
* When CONFIG_ARCH_LEDS is defined in the NuttX configuration, NuttX will
|
||||
* control the LED. Otherwise, the LED can be controlled from user
|
||||
* applications using the logic in this file.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "sam_port.h"
|
||||
#include "arduino_m0.h"
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_initialize
|
||||
*
|
||||
* Description:
|
||||
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
|
||||
* LEDs. If CONFIG_ARCH_LEDS is not defined, then the
|
||||
* board_userled_initialize() is available to initialize the LED from user
|
||||
* application logic.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled_initialize(void)
|
||||
{
|
||||
(void)sam_configport(PORT_STATUS_LED);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled
|
||||
*
|
||||
* Description:
|
||||
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
|
||||
* LEDs. If CONFIG_ARCH_LEDS is not defined, then the board_userled() is
|
||||
* available to control the LED from user application logic.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if (led == BOARD_STATUS_LED)
|
||||
{
|
||||
sam_portwrite(PORT_STATUS_LED, !ledon);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_all
|
||||
*
|
||||
* Description:
|
||||
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
|
||||
* LEDs.
|
||||
* If CONFIG_ARCH_LEDS is not defined, then the board_userled_all() is
|
||||
* available to control the LED from user application logic. NOTE: since
|
||||
* there is only a single LED on-board, this is function is not very useful.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled_all(uint8_t ledset)
|
||||
{
|
||||
board_userled(BOARD_STATUS_LED, (ledset & BOARD_STATUS_LED_BIT) != 0);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_ARCH_LEDS */
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h
|
||||
*
|
||||
* Copyright (C) 2011-2012, 2015-2016, 2018 Gregory Nutt. All rights
|
||||
* Copyright (C) 2011-2012, 2015-2016, 2018-2019 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user