Add configuration for the SAMD20 Xplained Pro board. Initial check a low-effor, unverified clone of thoe SAM4L Xplained Pro board configuration

This commit is contained in:
Gregory Nutt 2014-02-12 17:21:28 -06:00
parent e82bec827b
commit 23ac55e302
23 changed files with 4057 additions and 8 deletions

View File

@ -301,7 +301,7 @@ NuttX EABI "buildroot" Toolchain
1. You must have already configured Nuttx in <some-dir>/nuttx.
cd tools
./configure.shsam4l-xplained/<sub-dir>
./configure.sh sam4l-xplained/<sub-dir>
2. Download the latest buildroot package into <some-dir>
@ -602,7 +602,7 @@ Configurations
can be selected as follow:
cd tools
./configure.shsam4l-xplained/<subdir>
./configure.sh sam4l-xplained/<subdir>
cd -
. ./setenv.sh

View File

@ -196,7 +196,7 @@
/* LED definitions ******************************************************************/
/* There are three LEDs on board the SAM4L 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 labeled LED0 near the SAM4L USB
* one user controllable LED, a yellow LED labelled LED0 near the SAM4L USB
* connector.
*
* This LED is controlled by PC07 and LED0 can be activated by driving the
@ -214,7 +214,7 @@
/* When CONFIG_ARCH_LEDS is defined in the NuttX configuration, NuttX will
* control LED0 as defined below. Thus if LED0 is statically on, NuttX has
* successfully booted and is, apparently, running normmally. If LED0 is
* successfully booted and is, apparently, running normally. If LED0 is
* flashing at approximately 2Hz, then a fatal error has been detected and the
* system has halted.
*/
@ -245,7 +245,7 @@
* PC24 SW0
*/
/* The STM32F4 Discovery supports one button: */
/* The SAM4l Xplained Pro supports one button: */
#define BUTTON_SW0 0
#define NUM_BUTTONS 1
@ -309,7 +309,7 @@ extern "C" {
*
* Description:
* All SAM3U architectures must provide the following entry point. This entry point
* is called early in the intitialization -- after all memory has been configured
* is called early in the initialization -- after all memory has been configured
* and mapped but before any devices have been initialized.
*
************************************************************************************/

View File

@ -1,5 +1,5 @@
/****************************************************************************
* configs/sam3u-ek/scripts/ld.script
* configs/sam4l-xplained/scripts/ld.script
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -1,5 +1,5 @@
/****************************************************************************
* config/shenzhou/src/sam_mmcsd.c
* config/sam4l-xplained/src/sam_mmcsd.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -0,0 +1,55 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
if ARCH_BOARD_SAMD20_XPLAINED
menu "SAMD20 Xplained Pro Modules"
config SAMD20_XPLAINED_IOMODULE
bool "I/O1 Module"
default n
---help---
The I/O 1 module is attached. This module provides an MMC/SD card
slot.
if SAMD20_XPLAINED_IOMODULE
choice
prompt "I/O1 Module Location"
default SAMD20_XPLAINED_IOMODULE_EXT1
config SAMD20_XPLAINED_IOMODULE_EXT1
bool "EXT1"
config SAMD20_XPLAINED_IOMODULE_EXT2
bool "EXT2"
endchoice
endif
config SAMD20_XPLAINED_OLED1MODULE
bool "OLED1 Module"
default n
---help---
The OLED 1 module is attached. This module provides an OLED plus 3
additional switches and 3 additional LEDs.
if SAMD20_XPLAINED_OLED1MODULE
choice
prompt "OLED1 Module Location"
default SAMD20_XPLAINED_OLED1MODULE_EXT1
config SAMD20_XPLAINED_OLED1MODULE_EXT1
bool "EXT1"
config SAMD20_XPLAINED_OLED1MODULE_EXT2
bool "EXT2"
endchoice
endif
endmenu
endif

View File

@ -0,0 +1,800 @@
README
^^^^^^
This README discusses issues unique to NuttX configurations for the
Atmel SAMD20 Xplained Pro development board. This board features the
ATSAMD20J18A MCU.
The SAMD20 Xplained Pro Starter Kit may be bundled with three modules:
1) I/O1 - An MMC/SD card slot, PWM LED control, ADC light sensor, UART
loopback, TWI AT30TSE758 Temperature sensor.
2) OLED1 - An OLED plus 3 additional switches and 3 additional LEDs
3) PROTO1 - A prototyping board with logic on board (other than power-related
logic).
Contents
^^^^^^^^
- Modules
- Development Environment
- GNU Toolchain Options
- IDEs
- NuttX EABI "buildroot" Toolchain
- LEDs
- Serial Consoles
- SAMD20 Xplained Pro-specific Configuration Options
- Configurations
Modules
^^^^^^^
The SAMD20 Xplained Pro Starter Kit is bundled with four modules:
I/O1
----
The primary function of this module is to provide SD card support, but
the full list of modules features include:
- microSD card connector (SPI interface)
- PWM (LED control)
- ADC (light sensor)
- UART loopback
- TWI AT30TSE758 Temperature sensor with EEPROM
SPI is available on two of the SAMD20 Xplained connectors, EXT1 and EXT2.
They mate with the I/O1 connector as indicated in this table.
I/O1 CONNECTOR
----------------- ---------------------- ---------------------- ------------------------------------
I/O1 EXT1 EXT2 Other use of either pin
----------------- ---------------------- ---------------------- ------------------------------------
1 ID 1 1 Communication line to ID chip on
extension board.
----------------- ---------------------- ---------------------- ------------------------------------
2 GND 2 GND 2 GND
----------------- ---------------------- ---------------------- ------------------------------------
3 LIGHTSENSOR 3 PB00 AIN[8] 3 PA10 AIN[18]
----------------- ---------------------- ---------------------- ------------------------------------
4 LP_OUT 4 PB01 AIN[9] 4 PA11 AIN[19]
----------------- ---------------------- ---------------------- ------------------------------------
5 GPIO1 5 PB06 GPIO 5 PA20 GPIO
----------------- ---------------------- ---------------------- ------------------------------------
6 GPIO2 6 PB07 GPIO 6 PA21 GPIO
----------------- ---------------------- ---------------------- ------------------------------------
7 LED 7 PB02 TC6/WO[0] 7 PA22 TC4/WO[0]
----------------- ---------------------- ---------------------- ------------------------------------
8 LP_IN 8 PB03 TC6/WO[1] 8 PA23 TC4/WO[1]
----------------- ---------------------- ---------------------- ------------------------------------
9 TEMP_ALERT 9 PB04 EXTINT[4] 9 PB14 EXTINT[14]
----------------- ---------------------- ---------------------- ------------------------------------
10 microSD_DETECT 10 PB05 GPIO 10 PB15 GPIO
----------------- ---------------------- ---------------------- ------------------------------------
11 TWI SDA 11 PA08 SERCOM2 PAD[0] 11 PA08 SERCOM2 PAD[0] EXT1, EXT2, EXT3 and EDBG
I²C SDA I²C SDA
----------------- ---------------------- ---------------------- ------------------------------------
12 TWI SCL 12 PA09 SERCOM2 PAD[1] 12 PA09 SERCOM2 PAD[1] EXT2, EXT3 and EDBG
I²C SCL I²C SCL
----------------- ---------------------- ---------------------- ------------------------------------
13 UART RX 13 PB09 SERCOM4 PAD[1] 13 PB13 SERCOM4 PAD[1] The SERCOM4 module is shared between
UART RX UART RX EXT1, 2 and 3 UART's, but uses
different pins
----------------- ---------------------- ---------------------- ------------------------------------
14 UART TX 14 PB08 SERCOM4 PAD[0] 14 PB12 SERCOM4 PAD[0] The SERCOM4 module is shared between
UART TX UART TX EXT1, 2 and 3 UART's, but uses
different pins
----------------- ---------------------- ---------------------- ------------------------------------
15 microSD_SS 15 PA05 SERCOM0 PAD[1] 15 PA17 SERCOM1 PAD[1]
SPI SS SPI SS
----------------- ---------------------- ---------------------- ------------------------------------
16 SPI_MOSI 16 PA06 SERCOM0 PAD[2] 16 PA18 SERCOM1 PAD[2]
SPI MOSI SPI MOSI
----------------- ---------------------- ---------------------- ------------------------------------
17 SPI_MISO 17 PA04 SERCOM0 PAD[0] 17 PA16 SERCOM1 PAD[0]
SPI MISO SPI MISO
----------------- ---------------------- ---------------------- ------------------------------------
18 SPI_SCK 18 PA07 SERCOM0 PAD[3] 18 PA19 SERCOM1 PAD[3]
SPI SCK SPI SCK
----------------- ---------------------- ---------------------- ------------------------------------
19 GND 19 GND GND
----------------- ---------------------- ---------------------- ------------------------------------
20 VCC 20 VCC VCC
----------------- ---------------------- ---------------------- ------------------------------------
The mapping between the I/O1 pins and the SD connector are shown in the
following table.
SD Card Connection
------------------
I/O1 SD PIN Description
---- ---- --- -------------------------------------------------
D2 1 Data line 2 (not used)
15 D3 2 Data line 3. Active low chip select, pulled high
16 CMD 3 Command line, connected to SPI_MOSI.
20 VDD 4
18 CLK 5 Clock line, connected to SPI_SCK.
2/19 GND 6
17 D0 7 Data line 0, connected to SPI_MISO.
D1 8 Data line 1 (not used)
10 SW_A 9 Card detect
2/19 SW_B 10 GND
Card Detect
-----------
When a microSD card is put into the connector SW_A and SW_B are short-
circuited. SW_A is connected to the microSD_DETECT signal. To use this
as a card indicator remember to enable internal pullup in the target
device.
GPIOs
-----
So all that is required to connect the SD is configure the SPI
--- ------------------ ---------------------- -------------------------------------
PIN EXT1 EXT2 Description
--- ------------------ ---------------------- -------------------------------------
15 PA05 SERCOM0 PAD[1] 15 PA17 SERCOM1 PAD[1] Active low chip select OUTPUT, pulled
SPI SS SPI SS high on board.
--- ------------------ ---------------------- -------------------------------------
10 PB05 GPIO 10 PB15 GPIO Active low card detect INPUT, must
use internal pull-up.
--- ------------------ ---------------------- -------------------------------------
Configuration Options:
----------------------
CONFIG_SAMD20_XPLAINED_IOMODULE=y : Informs the system that the
I/O1 module is installed
CONFIG_SAMD20_XPLAINED_IOMODULE_EXT1=y : The module is installed in EXT1
CONFIG_SAMD20_XPLAINED_IOMODULE_EXT2=y : The mdoule is installed in EXT2
See the set-up in the discussion of the nsh configuration below for other
required configuration options.
NOTE: As of this writing, only the SD card slot is supported in the I/O1
module.
OLED1
-----
This module provides an OLED plus 3 additional switches and 3 additional
LEDs.
OLED1 CONNECTOR
----------------- ---------------------- ---------------------- ------------------------------------
OLED1 EXT1 EXT2 Other use of either pin
----------------- ---------------------- ---------------------- ------------------------------------
1 ID 1 1 Communication line to ID chip on
extension board.
----------------- ---------------------- ---------------------- ------------------------------------
2 GND 2 GND 2 GND
----------------- ---------------------- ---------------------- ------------------------------------
3 BUTTON2 3 PB00 AIN[8] 3 PA10 AIN[18]
----------------- ---------------------- ---------------------- ------------------------------------
4 BUTTON3 4 PB01 AIN[9] 4 PA11 AIN[19]
----------------- ---------------------- ---------------------- ------------------------------------
5 DATA_CMD_SEL 5 PB06 GPIO 5 PA20 GPIO
----------------- ---------------------- ---------------------- ------------------------------------
6 LED3 6 PB07 GPIO 6 PA21 GPIO
----------------- ---------------------- ---------------------- ------------------------------------
7 LED1 7 PB02 TC6/WO[0] 7 PA22 TC4/WO[0]
----------------- ---------------------- ---------------------- ------------------------------------
8 LED2 8 PB03 TC6/WO[1] 8 PA23 TC4/WO[1]
----------------- ---------------------- ---------------------- ------------------------------------
9 BUTTON1 9 PB04 EXTINT[4] 9 PB14 EXTINT[14]
----------------- ---------------------- ---------------------- ------------------------------------
10 DISPLAY_RESET 10 PB05 GPIO 10 PB15 GPIO
----------------- ---------------------- ---------------------- ------------------------------------
11 N/C 11 PA08 SERCOM2 PAD[0] 11 PA08 SERCOM2 PAD[0] EXT1, EXT2, EXT3 and EDBG
I²C SDA I²C SDA
----------------- ---------------------- ---------------------- ------------------------------------
12 N/C 12 PA09 SERCOM2 PAD[1] 12 PA09 SERCOM2 PAD[1] EXT2, EXT3 and EDBG
I²C SCL I²C SCL
----------------- ---------------------- ---------------------- ------------------------------------
13 N/C 13 PB09 SERCOM4 PAD[1] 13 PB13 SERCOM4 PAD[1] The SERCOM4 module is shared between
UART RX UART RX EXT1, 2 and 3 UART's, but uses
different pins
----------------- ---------------------- ---------------------- ------------------------------------
14 N/C 14 PB08 SERCOM4 PAD[0] 14 PB12 SERCOM4 PAD[0] The SERCOM4 module is shared between
UART TX UART TX EXT1, 2 and 3 UART's, but uses
different pins
----------------- ---------------------- ---------------------- ------------------------------------
15 DISPLAY_SS 15 PA05 SERCOM0 PAD[1] 15 PA17 SERCOM1 PAD[1]
SPI SS SPI SS
----------------- ---------------------- ---------------------- ------------------------------------
16 SPI_MOSI 16 PA06 SERCOM0 PAD[2] 16 PA18 SERCOM1 PAD[2]
SPI MOSI SPI MOSI
----------------- ---------------------- ---------------------- ------------------------------------
17 N/C 17 PA04 SERCOM0 PAD[0] 17 PA16 SERCOM1 PAD[0]
SPI MISO SPI MISO
----------------- ---------------------- ---------------------- ------------------------------------
18 SPI_SCK 18 PA07 SERCOM0 PAD[3] 18 PA19 SERCOM1 PAD[3]
SPI SCK SPI SCK
----------------- ---------------------- ---------------------- ------------------------------------
19 GND 19 GND GND
----------------- ---------------------- ---------------------- ------------------------------------
20 VCC 20 VCC VCC
----------------- ---------------------- ---------------------- ------------------------------------
Configuration Options:
----------------------
CONFIG_SAMD20_XPLAINED_OLED1MODULE=y : Informs the system that the
I/O1 module is installed
CONFIG_SAMD20_XPLAINED_OLED1MODULE_EXT1=y : The module is installed in EXT1
CONFIG_SAMD20_XPLAINED_OLED1MODULE_EXT2=y : The mdoule is installed in EXT2
See the set-up in the discussion of the nsh configuration below for other
required configuration options.
PROTO1
------
A prototyping board with logic on board (other than power-related logic).
There is no built-in support for the PROTO1 module.
Development Environment
^^^^^^^^^^^^^^^^^^^^^^^
Either Linux or Cygwin on Windows can be used for the development environment.
The source has been built only using the GNU toolchain (see below). Other
toolchains will likely cause problems. Testing was performed using the Cygwin
environment.
GNU Toolchain Options
^^^^^^^^^^^^^^^^^^^^^
The NuttX make system has been modified to support the following different
toolchain options.
1. The CodeSourcery GNU toolchain,
2. The devkitARM GNU toolchain, ok
4. The NuttX buildroot Toolchain (see below).
All testing has been conducted using the NuttX buildroot toolchain. To use
the CodeSourcery, devkitARM or Raisonance GNU toolchain, you simply need to
add one of the following configuration options to your .config (or defconfig)
file:
CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery under Windows
CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL=y : CodeSourcery under Linux
CONFIG_ARMV6M_TOOLCHAIN_ATOLLIC=y : Atollic toolchain for Windos
CONFIG_ARMV6M_TOOLCHAIN_DEVKITARM=y : devkitARM under Windows
CONFIG_ARMV6M_TOOLCHAIN_BUILDROOT=y : NuttX buildroot under Linux or Cygwin (default)
CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y : Generic GCC ARM EABI toolchain for Linux
CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIW=y : Generic GCC ARM EABI toolchain for Windows
If you are not using CONFIG_ARMV6M_TOOLCHAIN_BUILDROOT, then you may also
have to modify the PATH in the setenv.h file if your make cannot find the tools.
NOTE about Windows native toolchains
------------------------------------
The CodeSourcery (for Windows), Atollic, and devkitARM toolchains are
Windows native toolchains. The CodeSourcery (for Linux), NuttX buildroot,
and, perhaps, the generic GCC toolchains are Cygwin and/or Linux native
toolchains. There are several limitations to using a Windows based
toolchain in a Cygwin environment. The three biggest are:
1. The Windows toolchain cannot follow Cygwin paths. Path conversions are
performed automatically in the Cygwin makefiles using the 'cygpath' utility
but you might easily find some new path problems. If so, check out 'cygpath -w'
2. Windows toolchains cannot follow Cygwin symbolic links. Many symbolic links
are used in Nuttx (e.g., include/arch). The make system works around these
problems for the Windows tools by copying directories instead of linking them.
But this can also cause some confusion for you: For example, you may edit
a file in a "linked" directory and find that your changes had no effect.
That is because you are building the copy of the file in the "fake" symbolic
directory. If you use a Windows toolchain, you should get in the habit of
making like this:
make clean_context all
An alias in your .bashrc file might make that less painful.
3. Dependencies are not made when using Windows versions of the GCC. This is
because the dependencies are generated using Windows pathes which do not
work with the Cygwin make.
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
NOTE 1: The CodeSourcery toolchain (2009q1) does not work with default optimization
level of -Os (See Make.defs). It will work with -O0, -O1, or -O2, but not with
-Os.
NOTE 2: The devkitARM toolchain includes a version of MSYS make. Make sure that
the paths to Cygwin's /bin and /usr/bin directories appear BEFORE the devkitARM
path or will get the wrong version of make.
IDEs
^^^^
NuttX is built using command-line make. It can be used with an IDE, but some
effort will be required to create the project (There is a simple RIDE project
in the RIDE subdirectory).
Makefile Build
--------------
Under Eclipse, it is pretty easy to set up an "empty makefile project" and
simply use the NuttX makefile to build the system. That is almost for free
under Linux. Under Windows, you will need to set up the "Cygwin GCC" empty
makefile project in order to work with Windows (Google for "Eclipse Cygwin" -
there is a lot of help on the internet).
Native Build
------------
Here are a few tips before you start that effort:
1) Select the toolchain that you will be using in your .config file
2) Start the NuttX build at least one time from the Cygwin command line
before trying to create your project. This is necessary to create
certain auto-generated files and directories that will be needed.
3) Set up include pathes: You will need include/, arch/arm/src/sam34,
arch/arm/src/common, arch/arm/src/armv7-m, and sched/.
4) All assembly files need to have the definition option -D __ASSEMBLY__
on the command line.
Startup files will probably cause you some headaches. The NuttX startup file
is arch/arm/src/sam34/sam_vectors.S. You may need to build NuttX
one time from the Cygwin command line in order to obtain the pre-built
startup object needed by RIDE.
NuttX EABI "buildroot" Toolchain
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A GNU GCC-based toolchain is assumed. The files */setenv.sh should
be modified to point to the correct path to the Cortex-M0 GCC toolchain (if
different from the default in your PATH variable).
If you have no Cortex-M0 toolchain, one can be downloaded from the NuttX
SourceForge download site (https://sourceforge.net/projects/nuttx/files/buildroot/).
This GNU toolchain builds and executes in the Linux or Cygwin environment.
1. You must have already configured Nuttx in <some-dir>/nuttx.
cd tools
./configure.sh samd20-xplained/<sub-dir>
2. Download the latest buildroot package into <some-dir>
3. unpack the buildroot tarball. The resulting directory may
have versioning information on it like buildroot-x.y.z. If so,
rename <some-dir>/buildroot-x.y.z to <some-dir>/buildroot.
4. cd <some-dir>/buildroot
5. cp configs/cortexm0-eabi-defconfig-4.6.3 .config
6. make oldconfig
7. make
8. Edit setenv.h, if necessary, so that the PATH variable includes
the path to the newly built binaries.
See the file configs/README.txt in the buildroot source tree. That has more
details PLUS some special instructions that you will need to follow if you are
building a Cortex-M0 toolchain for Cygwin under Windows.
LEDs
^^^^
There is one yellow LED available on the SAM D20 Xplained Pro board that
can be turned on and off. The LED can be activated by driving the connected
PA14 I/O line to GND.
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
^^^^^^^^^^^^^^^
SERCOM4
------
SERCOM4 is available on connectors EXT1 and EXT3
PIN EXT1 EXT3 GPIO Function
---- ---- ------ -----------
13 PB09 PB13 SERCOM4 / UART RX
14 PB08 PB12 SERCOM4 / UART TX
19 19 GND
20 20 VCC
If you have a TTL to RS-232 converter then this is the most convenient
serial console to use. It is the default in all of these configurations.
An option is to use the virtual COM port.
Virtual COM Port
----------------
The SAMD20 Xplained Pro contains an Embedded Debugger (EDBG) that can be
used to program and debug the ATSAMD20J18A using Serial Wire Debug (SWD).
The Embedded debugger also include a Virtual Com port interface over
SERCOM3. Virtual COM port connections:
PA24 SERCOM3 / UART TXD
PA25 SERCOM3 / UART RXD
SAMD20 Xplained Pro-specific Configuration Options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
CONFIG_ARCH - Identifies the arch/ subdirectory. This should
be set to:
CONFIG_ARCH=arm
CONFIG_ARCH_family - For use in C code:
CONFIG_ARCH_ARM=y
CONFIG_ARCH_architecture - For use in C code:
CONFIG_ARCH_CORTEXM0=y
CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
CONFIG_ARCH_CHIP="samd"
CONFIG_ARCH_CHIP_name - For use in C code to identify the exact
chip:
CONFIG_ARCH_CHIP_SAMD
CONFIG_ARCH_CHIP_SAMD20
CONFIG_ARCH_CHIP_ATSAMD20J18
CONFIG_ARCH_BOARD - Identifies the configs subdirectory and
hence, the board that supports the particular chip or SoC.
CONFIG_ARCH_BOARD=samd20-xplained (for the SAMD20 Xplained Pro development board)
CONFIG_ARCH_BOARD_name - For use in C code
CONFIG_ARCH_BOARD_SAMD20_XPLAINED=y
CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
of delay loops
CONFIG_ENDIAN_BIG - define if big endian (default is little
endian)
CONFIG_RAM_SIZE - Describes the installed DRAM (SRAM in this case):
CONFIG_RAM_SIZE=0x00010000 (64KB)
CONFIG_RAM_START - The start address of installed DRAM
CONFIG_RAM_START=0x20000000
CONFIG_ARCH_IRQPRIO - The SAMD20 supports interrupt prioritization
CONFIG_ARCH_IRQPRIO=y
CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to boards that
have LEDs
CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt
stack. If defined, this symbol is the size of the interrupt
stack in bytes. If not defined, the user task stacks will be
used during interrupt handling.
CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
cause a 100 second delay during boot-up. This 100 second delay
serves no purpose other than it allows you to calibratre
CONFIG_ARCH_LOOPSPERMSEC. You simply use a stop watch to measure
the 100 second delay then adjust CONFIG_ARCH_LOOPSPERMSEC until
the delay actually is 100 seconds.
Individual subsystems can be enabled:
CONFIG_SAMD_WDT - Watchdog Timer"
CONFIG_SAMD_RTC - Real Time Counter"
CONFIG_SAMD_NVMCTRL - Non-Volatile Memory Controller"
CONFIG_SAMD_EVSYS - Event System"
CONFIG_SAMD_SERCOM0 - Serial Communication Interface 0"
CONFIG_SAMD_SERCOM1 - Serial Communication Interface 1"
CONFIG_SAMD_SERCOM2 - Serial Communication Interface 2"
CONFIG_SAMD_SERCOM3 - Serial Communication Interface 3"
CONFIG_SAMD_SERCOM4 - Serial Communication Interface 4"
CONFIG_SAMD_SERCOM5 - Serial Communication Interface 5"
CONFIG_SAMD_TC0 - Timer/Counter 0"
CONFIG_SAMD_TC1 - Timer/Counter 1"
CONFIG_SAMD_TC2 - Timer/Counter 2"
CONFIG_SAMD_TC3 - Timer/Counter 3"
CONFIG_SAMD_TC4 - Timer/Counter 4"
CONFIG_SAMD_TC5 - Timer/Counter 5"
CONFIG_SAMD_TC6 - Timer/Counter 6"
CONFIG_SAMD_TC7 - Timer/Counter 6"
CONFIG_SAMD_ADC - Analog-to-Digital Converter"
CONFIG_SAMD_AC - Analog Comparator"
CONFIG_SAMD_DAC - Digital-to-Analog Converter"
CONFIG_SAMD_PTC - Peripheral Touch Controller"
Some subsystems can be configured to operate in different ways. The drivers
need to know how to configure the subsystem.
CONFIG_SAM_SERCOM0_I2C, CONFIG_SAM_SERCOM0_SPI, or CONFIG_SAM_SERCOM0_UART
CONFIG_SAM_SERCOM1_I2C, CONFIG_SAM_SERCOM1_SPI, or CONFIG_SAM_SERCOM1_UART
CONFIG_SAM_SERCOM2_I2C, CONFIG_SAM_SERCOM2_SPI, or CONFIG_SAM_SERCOM2_UART
CONFIG_SAM_SERCOM3_I2C, CONFIG_SAM_SERCOM3_SPI, or CONFIG_SAM_SERCOM3_UART
CONFIG_SAM_SERCOM4_I2C, CONFIG_SAM_SERCOM4_SPI, or CONFIG_SAM_SERCOM4_UART
CONFIG_SAM_SERCOM5_I2C, CONFIG_SAM_SERCOM5_SPI, or CONFIG_SAM_SERCOM5_UART
SAT91SAMD20 specific device driver settings
CONFIG_UARTn_SERIAL_CONSOLE - selects the USARTn (n=0,1,2,..5) for the
console and ttys0 (default is the UART4).
CONFIG_UARTn_RXBUFSIZE - Characters are buffered as received.
This specific the size of the receive buffer
CONFIG_UARTn_TXBUFSIZE - Characters are buffered before
being sent. This specific the size of the transmit buffer
CONFIG_UARTn_BAUD - The configure BAUD of the UART. Must be
CONFIG_UARTn_BITS - The number of bits. Must be either 7 or 8.
CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
CONFIG_UARTn_2STOP - Two stop bits
Configurations
^^^^^^^^^^^^^^
Each SAMD20 Xplained Pro configuration is maintained in a sub-directory and
can be selected as follow:
cd tools
./configure.sh samd20-xplained/<subdir>
cd -
. ./setenv.sh
Before sourcing the setenv.sh file above, you should examine it and perform
edits as necessary so that BUILDROOT_BIN is 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
and misc/tools/
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
and misc/tools/
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
2. Unless stated otherwise, all configurations generate console
output of on SERCOM4 which is available on EXT1 or EXT3 (see the
section "Serial Consoles" above). The virtual COM port could
be used, instead, by reconfiguring to use SERCOM3 instead of
SERCOM4:
System Type -> SAMD Peripheral Support
CONFIG_SAM_SERCOM3=y
CONFIG_SAM_SERCOM4=n
Device Drivers -> Serial Driver Support -> Serial Console
CONFIG_SERCOM3_SERIAL_CONSOLE=y
Device Drivers -> Serial Driver Support -> SERCOM4 Configuration
CONFIG_UART3_2STOP=0
CONFIG_UART3_BAUD=115200
CONFIG_UART3_BITS=8
CONFIG_UART3_PARITY=0
CONFIG_UART3_RXBUFSIZE=256
CONFIG_UART3_TXBUFSIZE=256
3. Unless otherwise stated, the configurations are setup for
Cygwin under Windows:
Build Setup:
CONFIG_HOST_WINDOWS=y : Windows Host
CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on windoes
4. These configurations use the CodeSourcery toolchain. But
that is easily reconfigured:
System Type -> Toolchain:
CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYW=y
Any re-configuration should be done before making NuttX or else the
subsequent 'make' will fail. If you have already attempted building
NuttX then you will have to 1) 'make distclean' to remove the old
configuration, 2) 'cd tools; ./configure.sh sam3u-ek/ksnh' to start
with a fresh configuration, and 3) perform the configuration changes
above.
Also, make sure that your PATH variable has the new path to your
Atmel tools. Try 'which arm-none-eabi-gcc' to make sure that you
are selecting the right tool. setenv.sh is available for you to
use to set or PATH variable. The path in the that file may not,
however, be correct for your installation.
See also the "NOTE about Windows native toolchains" in the section call
"GNU Toolchain Options" above.
Configuration sub-directories
-----------------------------
nsh:
This configuration directory will built the NuttShell. See NOTES above
and below:
NOTES:
1. NOTE: If you get a compilation error like:
libxx_new.cxx:74:40: error: 'operator new' takes type 'size_t'
('unsigned int') as first parameter [-fper
Sometimes NuttX and your toolchain will disagree on the underlying
type of size_t; sometimes it is an 'unsigned int' and sometimes it is
an 'unsigned long int'. If this error occurs, then you may need to
toggle the value of CONFIG_CXX_NEWLONG.
2. If the I/O1 module is connected to the SAMD20 Xplained Pro, then
support for the SD card slot can be enabled by making the following
changes to the configuration:
File Systems:
CONFIG_FS_FAT=y : Enable the FAT file system
CONFIG_FAT_LCNAMES=y : Enable upper/lower case 8.3 file names (Optional, see below)
CONFIG_FAT_LFN=y : Enable long file named (Optional, see below)
CONFIG_FAT_MAXFNAME=32 : Maximum supported file name length
There are issues related to patents that Microsoft holds on FAT long
file name technologies. See the top level COPYING file for further
details.
System Type -> Peripherals:
To be provided : Enable the SAMD20 SPI peripheral
Device Drivers
CONFIG_SPI=y : Enable SPI support
CONFIG_SPI_EXCHANGE=y : The exchange() method is supported
CONFIG_SPI_OWNBUS=y : Smaller code if this is the only SPI device
CONFIG_MMCSD=y : Enable MMC/SD support
CONFIG_MMCSD_NSLOTS=1 : Only one MMC/SD card slot
CONFIG_MMCSD_MULTIBLOCK_DISABLE=n : Should not need to disable multi-block transfers
CONFIG_MMCSD_HAVECARDDETECT=y : I/O1 module as a card detect GPIO
CONFIG_MMCSD_SPI=y : Use the SPI interface to the MMC/SD card
CONFIG_MMCSD_SPICLOCK=20000000 : This is a guess for the optimal MMC/SD frequency
CONFIG_MMCSD_SPIMODE=0 : Mode 0 is required
Board Selection -> Common Board Options
CONFIG_NSH_MMCSDSLOTNO=0 : Only one MMC/SD slot, slot 0
CONFIG_NSH_MMCSDSPIPORTNO=0 : Use CS=0 if the I/O1 is in EXT1, OR
CONFIG_NSH_MMCSDSPIPORTNO=2 : Use CS=2 if the I/O1 is in EXT2
Board Selection -> SAMD20 Xplained Pro Modules
CONFIG_SAMD20_XPLAINED_IOMODULE=y : I/O1 module is connected
CONFIG_SAMD20_XPLAINED_IOMODULE_EXT1=y : In EXT1, or EXT2
CONFIG_SAMD20_XPLAINED_IOMODULE_EXT2=y
Application Configuration -> NSH Library
CONFIG_NSH_ARCHINIT=y : Board has architecture-specific initialization
NOTE: If you enable the I/O1 this configuration with SERCOM4 as the
console and with the I/O1 module in EXT1, you *must* remove UART
jumper. Otherwise, you have lookpack on SERCOM4 and NSH will *not*
behave very well (since its outgoing prompts also appear as incoming
commands).
STATUS: As of 2013-6-18, this configuration appears completely
functional. Testing, however, has been very light. Example:
NuttShell (NSH) NuttX-6.34
nsh> mount -t vfat /dev/mmcsd0 /mnt/stuff
nsh> ls /mnt/stuff
/mnt/stuff:
nsh> echo "This is a test" >/mnt/stuff/atest.txt
nsh> ls /mnt/stuff
/mnt/stuff:
atest.txt
nsh> cat /mnt/stuff/atest.txt
This is a test
nsh>
3. If the OLED1 module is connected to the SAMD20 Xplained Pro, then
support for the OLED display can be enabled by making the following
changes to the configuration:
System Type -> Peripherals:
To be provided : Enable the SAMD20 SPI peripheral
Device Drivers -> SPI
CONFIG_SPI=y : Enable SPI support
CONFIG_SPI_EXCHANGE=y : The exchange() method is supported
CONFIG_SPI_CMDDATA=y : CMD/DATA support is required
CONFIG_SPI_OWNBUS=y : Smaller code if this is the only SPI device
Device Drivers -> LCDs
CONFIG_LCD=y : Enable LCD support
CONFIG_LCD_MAXCONTRAST=255 : Maximum contrast value
CONFIG_LCD_LANDSCAPE=y : Landscape orientation (see below*)
CONFIG_LCD_UG2832HSWEG04=y : Enable support for the OLED
CONFIG_LCD_SSD1306_SPIMODE=0 : SPI Mode 0
CONFIG_LCD_SSD1306_SPIMODE=3500000 : Pick an SPI frequency
Board Selection -> SAMD20 Xplained Pro Modules
CONFIG_SAMD20_XPLAINED_OLED1MODULE=y : OLED1 module is connected
CONFIG_SAMD20_XPLAINED_OLED1MODULE_EXT1=y : In EXT1, or EXT2
CONFIG_SAMD20_XPLAINED_OLED1MODULE_EXT2=y
The NX graphics subsystem also needs to be configured:
CONFIG_NX=y : Enable graphics support
CONFIG_NX_LCDDRIVER=y : Using an LCD driver
CONFIG_NX_NPLANES=1 : With a single color plane
CONFIG_NX_WRITEONLY=n : You can read from the LCD (see below**)
CONFIG_NX_DISABLE_2BPP=y : Disable all resolutions except 1BPP
CONFIG_NX_DISABLE_4BPP=y
CONFIG_NX_DISABLE_8BPP=y
CONFIG_NX_DISABLE_16BPP=y
CONFIG_NX_DISABLE_24BPP=y
CONFIG_NX_DISABLE_32BPP=y
CONFIG_NX_PACKEDMSFIRST=y : LSB packed first (shouldn't matter)
CONFIG_NXTK_BORDERWIDTH=2 : Use a small border
CONFIG_NXTK_DEFAULT_BORDERCOLORS=y : Default border colors
CONFIG_NXFONTS_CHARBITS=7 : 7-bit fonts
CONFIG_NXFONT_SANS17X23B=y : Pick a font (any that will fit)
* This orientation will put the buttons "above" the LCD. The
reverse landscape configuration (CONFIG_LCD_RLANDSCAPE) will
"flip" the display so that the buttons are "below" the LCD.
** The hardware is write only, but the driver maintains a frame buffer
to support read and read-write-modiry operations on the LCD.
Reading from the frame buffer is, however, untested.
Then, in order to use the OLED, you will need to build some kind of
graphics application or use one of the NuttX graphics examples.
Here, for example, is the setup for the graphic "Hello, World!"
example:
CONFIG_EXAMPLES_NXHELLO=y : Enables the example
CONFIG_EXAMPLES_NXHELLO_DEFAULT_COLORS=y : Use default colors (see below *)
CONFIG_EXAMPLES_NXHELLO_DEFAULT_FONT=y : Use the default font
CONFIG_EXAMPLES_NXHELLO_BPP=1 : One bit per pixel
CONFIG_EXAMPLES_NXHELLO_EXTERNINIT=y : Special initialization is required.
* The OLED is monochrome so the only "colors" are blacka nd white.
The default "colors" will give you while text on a black background.
You can override the faults it you want black text on a while background.
NOTE: One issue that I have seen with the NXHello example when
running as an NSH command is that it only works the first time.
So, after you run the 'nxhello' command one time, you will have to
reset the board before you run it again.
This is clearly some issue with initializing, un-initializing, and
then re-initializing. If you want to fix this, patches are quite
welcome.

View File

@ -0,0 +1,300 @@
/************************************************************************************
* configs/samd20-xplained/include/board.h
*
* Copyright (C) 2014 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 __CONFIGS_SAMD20_XPLAINED_INCLUDE_BOARD_H
#define __CONFIGS_SAMD20_XPLAINED_INCLUDE_BOARD_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
# ifdef CONFIG_GPIO_IRQ
# include <arch/irq.h>
# endif
#endif
/************************************************************************************
* Definitions
************************************************************************************/
/* Clocking *************************************************************************/
/* Select the DFLL as the source of the system clock.
*
* Options (define one):
* BOARD_SYSCLK_SOURCE_RCSYS - System RC oscillator
* BOARD_SYSCLK_SOURCE_OSC0 - Oscillator 0
* BOARD_SYSCLK_SOURCE_PLL0 - Phase Locked Loop 0
* BOARD_SYSCLK_SOURCE_DFLL0 - Digital Frequency Locked Loop
* BOARD_SYSCLK_SOURCE_RC80M - 80 MHz RC oscillator
* BOARD_SYSCLK_SOURCE_FCFAST12M - 12 MHz RC oscillator
* BOARD_SYSCLK_SOURCE_FCFAST8M - 8 MHz RC oscillator
* BOARD_SYSCLK_SOURCE_FCFAST4M - 4 MHz RC oscillator
* BOARD_SYSCLK_SOURCE_RC1M - 1 MHz RC oscillator
*/
#define BOARD_SYSCLK_SOURCE_DFLL0 1
/* Nominal frequencies in on-chip RC oscillators. These are *not* configurable
* but appear here for use in frequency calculations. NOTE: These may frequencies
* may vary with temperature changes.
*/
#define BOARD_RCSYS_FREQUENCY 115000 /* Nominal frequency of RCSYS (Hz) */
#define BOARD_RC32K_FREQUENCY 32768 /* Nominal frequency of RC32K (Hz) */
#define BOARD_RC80M_FREQUENCY 80000000 /* Nominal frequency of RC80M (Hz) */
#define BOARD_RCFAST4M_FREQUENCY 4000000 /* Nominal frequency of RCFAST4M (Hz) */
#define BOARD_RCFAST8M_FREQUENCY 8000000 /* Nominal frequency of RCFAST8M (Hz) */
#define BOARD_RCFAST12M_FREQUENCY 12000000 /* Nominal frequency of RCFAST12M (Hz) */
#define BOARD_RC1M_FREQUENCY 1000000 /* Nominal frequency of RC1M (Hz) */
/* The SAMD20 Xplained Pro has two on-board crystals:
* XC100 12MHz OSC0
* XC101 32.768KHz OSC32
*/
/* OSC0 Configuration */
#define BOARD_OSC0_FREQUENCY 12000000 /* 12MHz XTAL */
/* OSC32 Configuration */
#define BOARD_OSC32_FREQUENCY 32768 /* 32.768KHz XTAL */
#define BOARD_OSC32_STARTUP_US 6100
#define BOARD_OSC32_SELCURR BSCIF_OSCCTRL32_SELCURR_300
#define BOARD_OSC32_ISXTAL 1 /* OSC32 is a crystal */
/* Digital Frequency Locked Loop configuration
* Fdfll = (Fclk * DFLLmul) / DFLLdiv
* = 32768 * (48000000/32768) / 1 = 48MHz
*
* The actual frequency is 47.97MHz due to truncation of the multiplier.
* The 48MHz target value is treated as "not-to-exceed" value). Use OSC0
* if you need more accuracy (12MHz with a multiplier of 4).
*
* DFLL0 source options (select one):
* BOARD_DFLL0_SOURCE_RCSYS - System RC oscillator
* BOARD_DFLL0_SOURCE_OSC32K - 32.768KHz oscillator
* BOARD_DFLL0_SOURCE_OSC0 - Oscillator 0
* BOARD_DFLL0_SOURCE_RC80M - 80 MHz RC oscillator
* BOARD_DFLL0_SOURCE_RC32K - 32 kHz RC oscillator
*
* NOTE: Nothing must be defined if the DFPLL is not used
*/
#define BOARD_DFLL0_SOURCE_OSC32K 1
#define BOARD_DFLL0_TARGET 48000000
#define BOARD_DFLL0_MUL (BOARD_DFLL0_TARGET / BOARD_OSC32_FREQUENCY)
#define BOARD_DFLL0_DIV 1
#define BOARD_DFLL0_FREQUENCY (BOARD_OSC32_FREQUENCY * BOARD_DFLL0_MUL / BOARD_DFLL0_DIV)
/* Phase Locked Loop configuration
* Fdfll = (Fclk * PLLmul) / PLLdiv
*
* PLL0 source options (select one):
* BOARD_PLL0_SOURCE_OSC0 - Oscillator 0
* BOARD_PLL0_SOURCE_GCLK9 - General clock 9
*
* BOARD_GLCK9_SOURCE_RCSYS - System RC oscillator
* BOARD_GLCK9_SOURCE_OSC32K - Output from OSC32K
* BOARD_GLCK9_SOURCE_DFLL0 - Output from DFLL0
* BOARD_GLCK9_SOURCE_OSC0 - Output from Oscillator0
* BOARD_GLCK9_SOURCE_RC80M - Output from 80MHz RCOSC
* BOARD_GLCK9_SOURCE_RCFAST - Output from 4,8,12MHz RCFAST
* BOARD_GLCK9_SOURCE_RC1M - Output from 1MHz RC1M
* BOARD_GLCK9_SOURCE_CPUCLK - The CPU clock
* BOARD_GLCK9_SOURCE_HSBCLK - High Speed Bus clock
* BOARD_GLCK9_SOURCE_PBACLK - Peripheral Bus A clock
* BOARD_GLCK9_SOURCE_PBBCLK - Peripheral Bus B clock
* BOARD_GLCK9_SOURCE_PBCCLK - Peripheral Bus C clock
* BOARD_GLCK9_SOURCE_PBDCLK - Peripheral Bus D clock
* BOARD_GLCK9_SOURCE_RC32K - Output from 32kHz RCOSC
*
* NOTE: Nothing must be defined if the PLL0 is not used
*/
/* System clock dividers: Fbus = Fmck >> BUSshift */
#define BOARD_CPU_SHIFT 0 /* Fcpu = Fmck = 48MHz */
#define BOARD_PBA_SHIFT 0 /* Fpba = Fmck = 48MHz */
#define BOARD_PBB_SHIFT 0 /* Fpbb = Fmck = 48MHz */
#define BOARD_PBC_SHIFT 0 /* Fpbc = Fmck = 48MHz */
#define BOARD_PBD_SHIFT 0 /* Fpbd = Fmck = 48MHz */
/* Resulting frequencies */
#define BOARD_MCK_FREQUENCY (BOARD_DFLL0_FREQUENCY)
#define BOARD_CPU_FREQUENCY (BOARD_MCK_FREQUENCY >> BOARD_CPU_SHIFT)
#define BOARD_PBA_FREQUENCY (BOARD_MCK_FREQUENCY >> BOARD_PBA_SHIFT)
#define BOARD_PBB_FREQUENCY (BOARD_MCK_FREQUENCY >> BOARD_PBB_SHIFT)
#define BOARD_PBC_FREQUENCY (BOARD_MCK_FREQUENCY >> BOARD_PBC_SHIFT)
#define BOARD_PBD_FREQUENCY (BOARD_MCK_FREQUENCY >> BOARD_PBD_SHIFT)
/* USBC.
*
* "The USBC has two bus clocks connected: One High Speed Bus clock
* (CLK_USBC_AHB) and one Peripheral Bus clock (CLK_USBC_APB). These clocks
* are generated by the Power Manager. Both clocks are enabled at reset
* and can be disabled by the Power Manager. It is recommended to disable
* the USBC before disabling the clocks, to avoid freezing the USBC in
* an undefined state.
*
* "To follow the usb data rate at 12Mbit/s in full-speed mode, the
* CLK_USBC_AHB clock should be at minimum 12MHz.
*
* "The 48MHz USB clock is generated by a dedicated generic clock from
* the SCIF module. Before using the USB, the user must ensure that the
* USB generic clock (GCLK_USBC) is enabled at 48MHz in the SCIF module."
*
* USB Generic Clock 7 (GCLK_USBC) source selection (one only)
*
* BOARD_USBC_SRC_OSC0
* BOARD_USBC_SRC_PLL0
* BOARD_USBC_SRC_DFLL
* BOARD_USBC_SRC_GCLKIN0
*/
#define BOARD_USBC_SRC_DFLL 1 /* Source DFLL0 at 48MHz */
#define BOARD_USBC_GCLK_DIV 1 /* Fusb = Fdfll / 1 = 48MHz */
/* LED definitions ******************************************************************/
/* There are three LEDs on board the SAMD20 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 STATUS near the SAMD20 USB
* connector.
*
* This LED is controlled by PC07 and the LED can be activated by driving the
* PA14 to GND.
*/
/* LED index values for use with sam_setled() */
#define BOARD_STATUS_LED 0
#define BOARD_NLEDS 1
/* LED bits for use with sam_setleds() */
#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 SAMD20 Xplained Pro contains two mechanical buttons. One button is the
* RESET button connected to the SAMD20 reset line and the other is a generic user
* configurable button. When a button is pressed it will drive the I/O line to GND.
*
* PA15 SW0
*/
/* The SAMD20 Xplained Pro supports one button: */
#define BUTTON_SW0 0
#define NUM_BUTTONS 1
#define BUTTON_SW0_BIT (1 << BUTTON_SW0)
/************************************************************************************
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* 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);
/************************************************************************************
* Name: sam_ledinit, sam_setled, and sam_setleds
*
* Description:
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board LEDs. If
* CONFIG_ARCH_LEDS is not defined, then the following interfaces are available to
* control the LEDs from user applications.
*
************************************************************************************/
#ifndef CONFIG_ARCH_LEDS
void sam_ledinit(void);
void sam_setled(int led, bool ledon);
void sam_setleds(uint8_t ledset);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_SAMD20_XPLAINED_INCLUDE_BOARD_H */

View File

@ -0,0 +1,122 @@
############################################################################
# configs/samd20-xplained/nsh/Make.defs
#
# Copyright (C) 2014 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)/configs/$(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)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
endif
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
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 -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHWARNINGSXX = -Wall -Wshadow
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
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 -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/mknulldeps.sh
else
# Linux/Cygwin-native host tools
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
endif

View File

@ -0,0 +1,722 @@
#
# Automatically generated file; DO NOT EDIT.
# Nuttx/ Configuration
#
CONFIG_NUTTX_NEWCONFIG=y
#
# Build Setup
#
# CONFIG_EXPERIMENTAL is not set
CONFIG_HOST_LINUX=y
# CONFIG_HOST_OSX is not set
# CONFIG_HOST_WINDOWS is not set
# CONFIG_HOST_OTHER is not set
#
# Build Configuration
#
# CONFIG_APPS_DIR="../apps"
# CONFIG_BUILD_2PASS is not set
#
# Binary Output Formats
#
# CONFIG_RRLOAD_BINARY is not set
# CONFIG_INTELHEX_BINARY is not set
# CONFIG_MOTOROLA_SREC is not set
CONFIG_RAW_BINARY=y
#
# Customize Header Files
#
# CONFIG_ARCH_STDBOOL_H is not set
# CONFIG_ARCH_MATH_H is not set
# CONFIG_ARCH_FLOAT_H is not set
# CONFIG_ARCH_STDARG_H is not set
#
# Debug Options
#
# CONFIG_DEBUG is not set
# CONFIG_DEBUG_SYMBOLS is not set
#
# System Type
#
# CONFIG_ARCH_8051 is not set
CONFIG_ARCH_ARM=y
# CONFIG_ARCH_AVR is not set
# CONFIG_ARCH_HC is not set
# CONFIG_ARCH_MIPS is not set
# CONFIG_ARCH_RGMP is not set
# CONFIG_ARCH_SH is not set
# CONFIG_ARCH_SIM is not set
# CONFIG_ARCH_X86 is not set
# CONFIG_ARCH_Z16 is not set
# CONFIG_ARCH_Z80 is not set
CONFIG_ARCH="arm"
#
# ARM Options
#
# CONFIG_ARCH_CHIP_C5471 is not set
# CONFIG_ARCH_CHIP_CALYPSO is not set
# CONFIG_ARCH_CHIP_DM320 is not set
# CONFIG_ARCH_CHIP_IMX is not set
# CONFIG_ARCH_CHIP_KINETIS is not set
# CONFIG_ARCH_CHIP_KL is not set
# CONFIG_ARCH_CHIP_LM is not set
# CONFIG_ARCH_CHIP_LPC17XX is not set
# CONFIG_ARCH_CHIP_LPC214X is not set
# CONFIG_ARCH_CHIP_LPC2378 is not set
# CONFIG_ARCH_CHIP_LPC31XX is not set
# CONFIG_ARCH_CHIP_LPC43XX is not set
# CONFIG_ARCH_CHIP_NUC1XX is not set
CONFIG_ARCH_CHIP_SAMD=y
# CONFIG_ARCH_CHIP_STM32 is not set
# CONFIG_ARCH_CHIP_STR71X is not set
CONFIG_ARCH_CORTEXM0=y
CONFIG_ARCH_FAMILY="armv6-m"
CONFIG_ARCH_CHIP="samd"
# CONFIG_ARMV6M_USEBASEPRI is not set
# CONFIG_ARCH_HAVE_FPU is not set
CONFIG_ARCH_HAVE_MPU=y
# CONFIG_ARMV6M_MPU is not set
#
# ARMV6M Configuration Options
#
# CONFIG_ARMV6M_TOOLCHAIN_BUILDROOT is not set
# CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set
CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYW=y
# CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL is not set
# CONFIG_ARMV6M_OABI_TOOLCHAIN=y
# CONFIG_GPIO_IRQ is not set
#
# SAMD Configuration Options
#
# CONFIG_ARCH_CHIP_ATSAM3U4E is not set
# CONFIG_ARCH_CHIP_ATSAM3X8E is not set
# CONFIG_ARCH_CHIP_ATSAM3X8C is not set
# CONFIG_ARCH_CHIP_ATSAM3X4E is not set
# CONFIG_ARCH_CHIP_ATSAM3X4C is not set
# CONFIG_ARCH_CHIP_ATSAM3A8C is not set
# CONFIG_ARCH_CHIP_ATSAM3A4C is not set
# CONFIG_ARCH_CHIP_ATSAMD20C2C is not set
# CONFIG_ARCH_CHIP_ATSAMD20C2B is not set
# CONFIG_ARCH_CHIP_ATSAMD20C2A is not set
CONFIG_ARCH_CHIP_ATSAMD20J18=y
# CONFIG_ARCH_CHIP_ATSAMD20C4B is not set
# CONFIG_ARCH_CHIP_ATSAMD20C4A is not set
# CONFIG_ARCH_CHIP_ATSAMD20S2C is not set
# CONFIG_ARCH_CHIP_ATSAMD20S2B is not set
# CONFIG_ARCH_CHIP_ATSAMD20S2A is not set
# CONFIG_ARCH_CHIP_ATSAMD20S4C is not set
# CONFIG_ARCH_CHIP_ATSAMD20S4B is not set
# CONFIG_ARCH_CHIP_ATSAMD20S4A is not set
# CONFIG_ARCH_CHIP_ATSAM4SD32C is not set
# CONFIG_ARCH_CHIP_ATSAM4SD32B is not set
# CONFIG_ARCH_CHIP_ATSAM4SD16C is not set
# CONFIG_ARCH_CHIP_ATSAM4SD16B is not set
# CONFIG_ARCH_CHIP_ATSAM4SA16C is not set
# CONFIG_ARCH_CHIP_ATSAM4SA16B is not set
# CONFIG_ARCH_CHIP_ATSAM4S16C is not set
# CONFIG_ARCH_CHIP_ATSAM4S16B is not set
# CONFIG_ARCH_CHIP_ATSAM4S8C is not set
# CONFIG_ARCH_CHIP_ATSAM4S8B is not set
# CONFIG_ARCH_CHIP_SAM3U is not set
# CONFIG_ARCH_CHIP_SAM3X is not set
# CONFIG_ARCH_CHIP_SAM3A is not set
CONFIG_ARCH_CHIP_SAMD=y
CONFIG_ARCH_CHIP_SAMD20=y
CONFIG_ARCH_CHIP_SAMD20J=y
# CONFIG_ARCH_CHIP_SAM4S is not set
#
# SAMD Peripheral Support
#
CONFIG_SAM_PICOCACHE=y
# CONFIG_SAMD_OCD is not set
# CONFIG_SAMD_APBA is not set
# CONFIG_SAMD_AESA is not set
# CONFIG_SAMD_IISC is not set
# CONFIG_SAMD_SPI0 is not set
# CONFIG_SAMD_TC0 is not set
# CONFIG_SAMD_TC1 is not set
# CONFIG_SAMD_TWIM0 is not set
# CONFIG_SAMD_TWIS0 is not set
# CONFIG_SAMD_TWIM1 is not set
# CONFIG_SAMD_TWIS1 is not set
# CONFIG_SAMD_TWIM2 is not set
# CONFIG_SAMD_TWIM3 is not set
# CONFIG_SAMD_PICOUART is not set
CONFIG_SAMD_USART0=y
# CONFIG_SAMD_USART1 is not set
# CONFIG_SAMD_USART2 is not set
# CONFIG_SAMD_USART3 is not set
# CONFIG_SAMD_ADC12B is not set
# CONFIG_SAMD_DACC is not set
# CONFIG_SAMD_ACC is not set
# CONFIG_SAMD_GLOC is not set
# CONFIG_SAMD_ABDACB is not set
# CONFIG_SAMD_TRNG is not set
# CONFIG_SAMD_PARC is not set
# CONFIG_SAMD_CATB is not set
# CONFIG_SAMD_HRAMC1 is not set
# CONFIG_SAMD_HMATRIX is not set
# CONFIG_SAMD_PDCA is not set
# CONFIG_SAMD_CRCCU is not set
# CONFIG_SAMD_USBC is not set
# CONFIG_SAMD_PEVC is not set
# CONFIG_SAMD_CHIPID is not set
# CONFIG_SAMD_FREQM is not set
# CONFIG_SAMD_AST is not set
# CONFIG_SAMD_WDT is not set
# CONFIG_SAMD_EIC is not set
#
# SAMD Clock Configuration
#
# CONFIG_SAMD_RESET_PERIPHCLKS is not set
# CONFIG_SAMD_OSC0 is not set
# CONFIG_SAMD_OSC32K is not set
# CONFIG_SAMD_RC80M is not set
# CONFIG_SAMD_RCFAST is not set
# CONFIG_SAMD_RC1M is not set
# CONFIG_SAMD_RC32K is not set
#
# SAMD USART Configuration
#
CONFIG_USART0_ISUART=y
#
# SAMD GPIO Interrupt Configuration
#
#
# External Memory Configuration
#
#
# Architecture Options
#
# CONFIG_ARCH_NOINTC is not set
# CONFIG_ARCH_VECNOTIRQ is not set
# CONFIG_ARCH_DMA is not set
CONFIG_ARCH_IRQPRIO=y
# CONFIG_CUSTOM_STACK is not set
# CONFIG_ADDRENV is not set
CONFIG_ARCH_HAVE_VFORK=y
CONFIG_ARCH_STACKDUMP=y
# CONFIG_ENDIAN_BIG is not set
CONFIG_ARCH_HAVE_RAMFUNCS=y
CONFIG_ARCH_RAMFUNCS=y
CONFIG_ARCH_HAVE_RAMVECTORS=y
# CONFIG_ARCH_RAMVECTORS is not set
#
# Board Settings
#
CONFIG_BOARD_LOOPSPERMSEC=3410
# CONFIG_ARCH_CALIBRATION is not set
CONFIG_RAM_START=0x20000000
CONFIG_RAM_SIZE=32768
CONFIG_ARCH_HAVE_INTERRUPTSTACK=y
CONFIG_ARCH_INTERRUPTSTACK=0
#
# Boot options
#
# CONFIG_BOOT_RUNFROMEXTSRAM is not set
CONFIG_BOOT_RUNFROMFLASH=y
# CONFIG_BOOT_RUNFROMISRAM is not set
# CONFIG_BOOT_RUNFROMSDRAM is not set
# CONFIG_BOOT_COPYTORAM is not set
#
# Board Selection
#
CONFIG_ARCH_BOARD_SAMD20_XPLAINED=y
# CONFIG_ARCH_BOARD_CUSTOM is not set
CONFIG_ARCH_BOARD="samd20-xplained"
#
# Common Board Options
#
CONFIG_ARCH_HAVE_LEDS=y
CONFIG_ARCH_LEDS=y
CONFIG_ARCH_HAVE_BUTTONS=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_HAVE_IRQBUTTONS=y
# CONFIG_ARCH_IRQBUTTONS is not set
CONFIG_NSH_MMCSDMINOR=0
#
# Board-Specific Options
#
#
# SAMD20 Xplained Pro Modules
#
# CONFIG_SAMD20_XPLAINED_IOMODULE is not set
# CONFIG_SAMD20_XPLAINED_OLED1MODULE is not set
#
# RTOS Features
#
# CONFIG_BOARD_INITIALIZE is not set
CONFIG_MSEC_PER_TICK=10
CONFIG_RR_INTERVAL=200
# CONFIG_SCHED_INSTRUMENTATION is not set
CONFIG_TASK_NAME_SIZE=0
# CONFIG_SCHED_HAVE_PARENT is not set
# CONFIG_JULIAN_TIME is not set
CONFIG_START_YEAR=2014
CONFIG_START_MONTH=2
CONFIG_START_DAY=12
CONFIG_DEV_CONSOLE=y
# CONFIG_MUTEX_TYPES is not set
# CONFIG_PRIORITY_INHERITANCE is not set
# CONFIG_FDCLONE_DISABLE is not set
# CONFIG_FDCLONE_STDIO is not set
CONFIG_SDCLONE_DISABLE=y
CONFIG_SCHED_WAITPID=y
# CONFIG_SCHED_STARTHOOK is not set
# CONFIG_SCHED_ATEXIT is not set
# CONFIG_SCHED_ONEXIT is not set
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_DISABLE_OS_API=y
# CONFIG_DISABLE_CLOCK is not set
# CONFIG_DISABLE_POSIX_TIMERS is not set
# CONFIG_DISABLE_PTHREAD is not set
# CONFIG_DISABLE_SIGNALS is not set
# CONFIG_DISABLE_MQUEUE is not set
CONFIG_DISABLE_ENVIRON=y
#
# Signal Numbers
#
CONFIG_SIG_SIGUSR1=1
CONFIG_SIG_SIGUSR2=2
CONFIG_SIG_SIGALARM=3
CONFIG_SIG_SIGCONDTIMEDOUT=16
#
# Sizes of configurable things (0 disables)
#
CONFIG_MAX_TASKS=16
CONFIG_MAX_TASK_ARGS=4
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NAME_MAX=32
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_MQ_MAXMSGSIZE=32
CONFIG_MAX_WDOGPARMS=2
CONFIG_PREALLOC_WDOGS=4
CONFIG_PREALLOC_TIMERS=4
#
# Stack and heap information
#
CONFIG_IDLETHREAD_STACKSIZE=1024
CONFIG_USERMAIN_STACKSIZE=1536
CONFIG_PTHREAD_STACK_MIN=256
CONFIG_PTHREAD_STACK_DEFAULT=1536
#
# Device Drivers
#
CONFIG_DISABLE_POLL=y
CONFIG_DEV_NULL=y
# CONFIG_DEV_ZERO is not set
# CONFIG_LOOP is not set
# CONFIG_RAMDISK is not set
# CONFIG_CAN is not set
# CONFIG_PWM is not set
# CONFIG_I2C is not set
# CONFIG_SPI is not set
# CONFIG_RTC is not set
# CONFIG_WATCHDOG is not set
# CONFIG_ANALOG is not set
# CONFIG_AUDIO_DEVICES is not set
# CONFIG_BCH is not set
# CONFIG_INPUT is not set
# CONFIG_LCD is not set
# CONFIG_MMCSD is not set
# CONFIG_MTD is not set
# CONFIG_PIPES is not set
# CONFIG_PM is not set
# CONFIG_POWER is not set
# CONFIG_SENSORS is not set
CONFIG_SERIAL=y
# CONFIG_DEV_LOWCONSOLE is not set
# CONFIG_16550_UART is not set
CONFIG_ARCH_HAVE_USART0=y
CONFIG_MCU_SERIAL=y
CONFIG_STANDARD_SERIAL=y
CONFIG_USART0_SERIAL_CONSOLE=y
# CONFIG_NO_SERIAL_CONSOLE is not set
#
# USART0 Configuration
#
CONFIG_USART0_RXBUFSIZE=256
CONFIG_USART0_TXBUFSIZE=256
CONFIG_USART0_BAUD=115200
CONFIG_USART0_BITS=8
CONFIG_USART0_PARITY=0
CONFIG_USART0_2STOP=0
# CONFIG_USART0_IFLOWCONTROL is not set
# CONFIG_USART0_OFLOWCONTROL is not set
# CONFIG_SERIAL_IFLOWCONTROL is not set
# CONFIG_SERIAL_OFLOWCONTROL is not set
# CONFIG_USBDEV is not set
# CONFIG_USBHOST is not set
# CONFIG_WIRELESS is not set
#
# System Logging Device Options
#
#
# System Logging
#
# CONFIG_RAMLOG is not set
#
# Networking Support
#
# CONFIG_NET is not set
#
# File Systems
#
#
# File system configuration
#
# CONFIG_DISABLE_MOUNTPOINT is not set
# CONFIG_FS_RAMMAP is not set
# CONFIG_FS_FAT is not set
# CONFIG_FS_NXFFS is not set
# CONFIG_FS_ROMFS is not set
# CONFIG_FS_SMARTFS is not set
# CONFIG_FS_BINFS is not set
#
# System Logging
#
# CONFIG_SYSLOG_ENABLE is not set
# CONFIG_SYSLOG is not set
#
# Graphics Support
#
# CONFIG_NX is not set
#
# Memory Management
#
# CONFIG_MM_MULTIHEAP is not set
# CONFIG_MM_SMALL is not set
CONFIG_MM_REGIONS=3
# CONFIG_GRAN is not set
#
# Audio Support
#
# CONFIG_AUDIO is not set
#
# Binary Formats
#
# CONFIG_BINFMT_DISABLE is not set
# CONFIG_NXFLAT is not set
# CONFIG_ELF is not set
CONFIG_BUILTIN=y
# CONFIG_PIC is not set
# CONFIG_SYMTAB_ORDEREDBYNAME is not set
#
# Library Routines
#
#
# Standard C Library Options
#
CONFIG_STDIO_BUFFER_SIZE=64
CONFIG_STDIO_LINEBUFFER=y
CONFIG_NUNGET_CHARS=2
# CONFIG_LIBM is not set
# CONFIG_NOPRINTF_FIELDWIDTH is not set
# CONFIG_LIBC_FLOATINGPOINT is not set
CONFIG_LIB_RAND_ORDER=1
# CONFIG_EOL_IS_CR is not set
# CONFIG_EOL_IS_LF is not set
# CONFIG_EOL_IS_BOTH_CRLF is not set
CONFIG_EOL_IS_EITHER_CRLF=y
# CONFIG_LIBC_EXECFUNCS is not set
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
# CONFIG_LIBC_STRERROR is not set
# CONFIG_LIBC_PERROR_STDOUT is not set
CONFIG_ARCH_LOWPUTC=y
CONFIG_LIB_SENDFILE_BUFSIZE=512
# CONFIG_ARCH_ROMGETC is not set
# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set
#
# Non-standard Library Support
#
# CONFIG_SCHED_WORKQUEUE is not set
# CONFIG_LIB_KBDCODEC is not set
# CONFIG_LIB_SLCDCODEC is not set
#
# Basic CXX Support
#
# CONFIG_C99_BOOL8 is not set
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_CXX_NEWLONG=y
#
# uClibc++ Standard C++ Library
#
# CONFIG_UCLIBCXX is not set
#
# Application Configuration
#
#
# Built-In Applications
#
CONFIG_BUILTIN_PROXY_STACKSIZE=1024
#
# Examples
#
# CONFIG_EXAMPLES_BUTTONS is not set
# CONFIG_EXAMPLES_CAN is not set
# CONFIG_SYSTEM_COMPOSITE is not set
# CONFIG_EXAMPLES_CXXTEST is not set
# CONFIG_EXAMPLES_DHCPD is not set
# CONFIG_EXAMPLES_ELF is not set
# CONFIG_EXAMPLES_FTPC is not set
# CONFIG_EXAMPLES_FTPD is not set
# CONFIG_EXAMPLES_HELLO is not set
# CONFIG_EXAMPLES_HELLOXX is not set
# CONFIG_EXAMPLES_JSON is not set
# CONFIG_EXAMPLES_HIDKBD is not set
# CONFIG_EXAMPLES_KEYPADTEST is not set
# CONFIG_EXAMPLES_IGMP is not set
# CONFIG_EXAMPLES_LCDRW is not set
# CONFIG_EXAMPLES_MM is not set
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set
# CONFIG_EXAMPLES_NXCONSOLE is not set
# CONFIG_EXAMPLES_NXFFS is not set
# CONFIG_EXAMPLES_NXFLAT is not set
# CONFIG_EXAMPLES_NXHELLO is not set
# CONFIG_EXAMPLES_NXIMAGE is not set
# CONFIG_EXAMPLES_NXLINES is not set
# CONFIG_EXAMPLES_NXTEXT is not set
# CONFIG_EXAMPLES_OSTEST is not set
# CONFIG_EXAMPLES_PASHELLO is not set
# CONFIG_EXAMPLES_PIPE is not set
# CONFIG_EXAMPLES_POSIXSPAWN is not set
# CONFIG_EXAMPLES_QENCODER is not set
# CONFIG_EXAMPLES_RGMP is not set
# CONFIG_EXAMPLES_ROMFS is not set
# CONFIG_EXAMPLES_SENDMAIL is not set
# CONFIG_EXAMPLES_SERLOOP is not set
# CONFIG_EXAMPLES_SLCD is not set
# CONFIG_EXAMPLES_SMART_TEST is not set
# CONFIG_EXAMPLES_SMART is not set
# CONFIG_EXAMPLES_TCPECHO is not set
# CONFIG_EXAMPLES_TELNETD is not set
# CONFIG_EXAMPLES_THTTPD is not set
# CONFIG_EXAMPLES_TIFF is not set
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
# CONFIG_EXAMPLES_UDP is not set
# CONFIG_EXAMPLES_UIP is not set
# CONFIG_EXAMPLES_USBSERIAL is not set
# CONFIG_SYSTEM_USBMSC is not set
# CONFIG_EXAMPLES_USBTERM is not set
# CONFIG_EXAMPLES_WATCHDOG is not set
#
# Graphics Support
#
# CONFIG_TIFF is not set
#
# Interpreters
#
# CONFIG_INTERPRETERS_FICL is not set
# CONFIG_INTERPRETERS_PCODE is not set
#
# Network Utilities
#
#
# Networking Utilities
#
# CONFIG_NETUTILS_CODECS is not set
# CONFIG_NETUTILS_DHCPC is not set
# CONFIG_NETUTILS_DHCPD is not set
# CONFIG_NETUTILS_FTPC is not set
# CONFIG_NETUTILS_FTPD is not set
# CONFIG_NETUTILS_JSON is not set
# CONFIG_NETUTILS_RESOLV is not set
# CONFIG_NETUTILS_SMTP is not set
# CONFIG_NETUTILS_TELNETD is not set
# CONFIG_NETUTILS_TFTPC is not set
# CONFIG_NETUTILS_THTTPD is not set
# CONFIG_NETUTILS_UIPLIB is not set
# CONFIG_NETUTILS_WEBCLIENT is not set
#
# FreeModBus
#
# CONFIG_MODBUS is not set
#
# NSH Library
#
CONFIG_NSH_LIBRARY=y
CONFIG_NSH_BUILTIN_APPS=y
#
# Disable Individual commands
#
# CONFIG_NSH_DISABLE_CAT is not set
# CONFIG_NSH_DISABLE_CD is not set
# CONFIG_NSH_DISABLE_CP is not set
# CONFIG_NSH_DISABLE_DD is not set
# CONFIG_NSH_DISABLE_ECHO is not set
# CONFIG_NSH_DISABLE_EXEC is not set
# CONFIG_NSH_DISABLE_EXIT is not set
# CONFIG_NSH_DISABLE_FREE is not set
# CONFIG_NSH_DISABLE_GET is not set
# CONFIG_NSH_DISABLE_HELP is not set
# CONFIG_NSH_DISABLE_HEXDUMP is not set
# CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_KILL is not set
# CONFIG_NSH_DISABLE_LOSETUP is not set
# CONFIG_NSH_DISABLE_LS is not set
# CONFIG_NSH_DISABLE_MB is not set
# CONFIG_NSH_DISABLE_MKDIR is not set
# CONFIG_NSH_DISABLE_MKFATFS is not set
# CONFIG_NSH_DISABLE_MKFIFO is not set
# CONFIG_NSH_DISABLE_MKRD is not set
# CONFIG_NSH_DISABLE_MH is not set
# CONFIG_NSH_DISABLE_MOUNT is not set
# CONFIG_NSH_DISABLE_MW is not set
# CONFIG_NSH_DISABLE_NSFMOUNT is not set
# CONFIG_NSH_DISABLE_PS is not set
# CONFIG_NSH_DISABLE_PING is not set
# CONFIG_NSH_DISABLE_PUT is not set
# CONFIG_NSH_DISABLE_PWD is not set
# CONFIG_NSH_DISABLE_RM is not set
# CONFIG_NSH_DISABLE_RMDIR is not set
# CONFIG_NSH_DISABLE_SET is not set
# CONFIG_NSH_DISABLE_SH is not set
# CONFIG_NSH_DISABLE_SLEEP is not set
# CONFIG_NSH_DISABLE_TEST is not set
# CONFIG_NSH_DISABLE_UMOUNT is not set
# CONFIG_NSH_DISABLE_UNSET is not set
# CONFIG_NSH_DISABLE_USLEEP is not set
# CONFIG_NSH_DISABLE_WGET is not set
# CONFIG_NSH_DISABLE_XD is not set
#
# Configure Command Options
#
# CONFIG_NSH_CMDOPT_DF_H is not set
CONFIG_NSH_CODECS_BUFSIZE=128
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_MAXARGUMENTS=6
CONFIG_NSH_NESTDEPTH=3
# CONFIG_NSH_DISABLESCRIPT is not set
# CONFIG_NSH_DISABLEBG is not set
CONFIG_NSH_CONSOLE=y
#
# USB Trace Support
#
# CONFIG_NSH_CONDEV is not set
# CONFIG_NSH_ARCHINIT is not set
#
# NxWidgets/NxWM
#
#
# System NSH Add-Ons
#
#
# Custom Free Memory Command
#
# CONFIG_SYSTEM_FREE is not set
#
# I2C tool
#
#
# FLASH Program Installation
#
# CONFIG_SYSTEM_INSTALL is not set
#
# FLASH Erase-all Command
#
#
# RAM test
#
# CONFIG_SYSTEM_RAMTEST is not set
#
# readline()
#
CONFIG_SYSTEM_READLINE=y
CONFIG_READLINE_ECHO=y
#
# Power Off
#
# CONFIG_SYSTEM_POWEROFF is not set
#
# RAMTRON
#
# CONFIG_SYSTEM_RAMTRON is not set
#
# SD Card
#
# CONFIG_SYSTEM_SDCARD is not set
#
# Sysinfo
#
# CONFIG_SYSTEM_SYSINFO is not set
#
# USB Monitor
#

View File

@ -0,0 +1,75 @@
#!/bin/bash
# configs/samd20-xplained/nsh/setenv.sh
#
# Copyright (C) 2014 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.
#
if [ "$_" = "$0" ] ; then
echo "You must source this script, not run it!" 1>&2
exit 1
fi
WD=`pwd`
if [ ! -x "setenv.sh" ]; then
echo "This script must be executed from the top-level NuttX build directory"
exit 1
fi
if [ -z "${PATH_ORIG}" ]; then
export PATH_ORIG="${PATH}"
fi
# This is the Cygwin path to the location where I installed the Atmel GCC
# toolchain under Windows. You will also have to edit this if you install
# this toolchain in any other location
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/Atmel/Atmel Toolchain/ARM GCC/Native/4.7.3.99/arm-gnu-toolchain/bin"
# This is the Cygwin path to the location where I installed the CodeSourcery
# toolchain under windows. You will also have to edit this if you install
# the CodeSourcery toolchain in any other location
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin"
export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
# These are the Cygwin paths to the locations where I installed the Atollic
# toolchain under windows. You will also have to edit this if you install
# the Atollic toolchain in any other location. /usr/bin is added before
# the Atollic bin path because there is are binaries named gcc.exe and g++.exe
# at those locations as well.
#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for ARM Pro 2.3.0/ARMTools/bin"
# This is the Cygwin path to the location where I build the buildroot
# toolchain.
# export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin"
# Add the path to the toolchain to the PATH varialble
export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
echo "PATH : ${PATH}"

View File

@ -0,0 +1,121 @@
/****************************************************************************
* configs/samd30-xplained/scripts/flash.ld
*
* Copyright (C) 2014 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 ATSAMD20J18A has 256KB of FLASH beginning at address 0x0000:0000 and
* 64KB of SRAM beginning at address 0x2000:0000
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00000000, LENGTH = 256K
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
}
OUTPUT_ARCH(arm)
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
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} >flash
__exidx_end = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
_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)
_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) }
}

View File

@ -0,0 +1,2 @@
/.depend
/Make.dep

View File

@ -0,0 +1,122 @@
############################################################################
# configs/samd20-xplained/src/Makefile
#
# Copyright (C) 2014 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
CFLAGS += -I$(TOPDIR)/sched
ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = sam_boot.c
ifeq ($(CONFIG_HAVE_CXX),y)
CSRCS += sam_cxxinitialize.c
endif
ifeq ($(CONFIG_SAMD_SPI0),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_NSH_ARCHINIT),y)
CSRCS += sam_nsh.c
endif
ifeq ($(CONFIG_SAMD_SPI0),y)
ifeq ($(CONFIG_SAM4L_XPLAINED_IOMODULE),y)
CSRCS += sam_mmcsd.c
endif
endif
ifeq ($(CONFIG_SAMD_SPI0),y)
ifeq ($(CONFIG_SAM4L_XPLAINED_OLED1MODULE),y)
ifeq ($(CONFIG_LCD_UG2832HSWEG04),y)
CSRCS += sam_ug2832hsweg04.c
endif
endif
endif
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src
ifeq ($(WINTOOL),y)
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}"
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/common}"
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/armv7-m}"
else
CFLAGS += -I$(ARCH_SRCDIR)/chip
CFLAGS += -I$(ARCH_SRCDIR)/common
CFLAGS += -I$(ARCH_SRCDIR)/armv7-m
endif
all: libboard$(LIBEXT)
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
libboard$(LIBEXT): $(OBJS)
$(call ARCHIVE, $@, $(OBJS))
.depend: Makefile $(SRCS)
$(Q) $(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
$(Q) touch $@
depend: .depend
clean:
$(call DELFILE, libboard$(LIBEXT))
$(call CLEAN)
distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include Make.dep

View File

@ -0,0 +1,177 @@
/****************************************************************************
* configs/samd20-xplained/src/sam_autoleds.c
*
* Copyright (C) 2014 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 are three LEDs on board the SAMD20 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 STATUS near the SAMD20 USB
* connector.
*
* This LED is controlled by PA14 and the LED can be activated by driving PA14
* 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.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#include "sam_gpio.h"
#include "samd20-xplained.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
* with CONFIG_DEBUG_VERBOSE too)
*/
#ifdef CONFIG_DEBUG_LEDS
# define leddbg lldbg
# define ledvdbg llvdbg
#else
# define leddbg(x...)
# define ledvdbg(x...)
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_led_initialize
****************************************************************************/
void board_led_initialize(void)
{
(void)sam_configgpio(GPIO_STATUS_LED);
}
/****************************************************************************
* Name: board_led_on
****************************************************************************/
void board_led_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_gpiowrite(GPIO_STATUS_LED, ledstate);
}
/****************************************************************************
* Name: board_led_off
****************************************************************************/
void board_led_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_gpiowrite(GPIO_STATUS_LED, true);
break;
}
}
#endif /* CONFIG_ARCH_LEDS */

View File

@ -0,0 +1,86 @@
/************************************************************************************
* configs/samd20-xplained/src/sam_boot.c
*
* Copyright (C) 2014 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 "samd20-xplained.h"
/************************************************************************************
* 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 SPI chip selects if 1) SPI is not disabled, and 2) the weak function
* sam_spiinitialize() has been brought into the link.
*/
#ifdef CONFIG_SAMD_SPI0
if (sam_spiinitialize)
{
sam_spiinitialize();
}
#endif
/* Configure on-board LEDs if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
board_led_initialize();
#endif
}

View File

@ -0,0 +1,159 @@
/****************************************************************************
* configs/samd20-xplained/src/sam_buttons.c
*
* Copyright (C) 2014 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 <stdint.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <arch/irq.h>
#include <arch/board/board.h>
#include "sam_gpio.h"
#include "samd20-xplained.h"
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
#if defined(CONFIG_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
static xcpt_t g_irqsw0;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_button_initialize
*
* Description:
* board_button_initialize() must be called to initialize button resources.
* After that, board_buttons() may be called to collect the current state of
* all buttons or board_button_irq() may be called to register button
* interrupt handlers.
*
****************************************************************************/
void board_button_initialize(void)
{
(void)sam_configgpio(GPIO_SW0);
}
/************************************************************************************
* Name: board_buttons
*
* Description:
* After board_button_initialize() has been called, board_buttons() may be called to collect
* the state of all buttons. board_buttons() returns an 8-bit bit set with each bit
* associated with a button. See the BUTTON* definitions above for the meaning of
* each bit in the returned value.
*
************************************************************************************/
uint8_t board_buttons(void)
{
return sam_gpioread(GPIO_SW0) ? 0 : BUTTON_SW0_BIT;
}
/****************************************************************************
* Name: board_button_irq
*
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address isreturned (so that it may restored, if so desired).
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
* overall GPIO IRQ feature and CONFIG_AVR32_GPIOIRQSETA and/or
* CONFIG_AVR32_GPIOIRQSETB must be enabled to select GPIOs to support
* interrupts on. For button support, bits 2 and 3 must be set in
* CONFIG_AVR32_GPIOIRQSETB (PB2 and PB3).
*
****************************************************************************/
#if defined(CONFIG_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
xcpt_t board_button_irq(int id, xcpt_t irqhandler)
{
xcpt_t oldhandler = NULL;
if (id == BUTTON_SW0)
{
irqstate_t flags;
/* Disable interrupts until we are done. This guarantees that the
* following operations are atomic.
*/
flags = irqsave();
/* Get the old button interrupt handler and save the new one */
oldhandler = *g_irqsw0;
*g_irqsw0 = irqhandler;
/* Configure the interrupt */
sam_gpioirq(IRQ_SW0);
(void)irq_attach(IRQ_SW0, irqhandler);
sam_gpioirqenable(IRQ_SW0);
irqrestore(flags);
}
/* Return the old button handler (so that it can be restored) */
return oldhandler;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -0,0 +1,153 @@
/************************************************************************************
* configs/samd20-xplained/src/sam_cxxinitialize.c
*
* Copyright (C) 2014 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/arch.h>
#include <arch/samd/chip.h>
#include "chip.h"
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
/************************************************************************************
* Definitions
************************************************************************************/
/* Debug ****************************************************************************/
/* Non-standard debug that may be enabled just for testing the static constructors */
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_CXX
#endif
#ifdef CONFIG_DEBUG_CXX
# define cxxdbg dbg
# define cxxlldbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define cxxvdbg vdbg
# define cxxllvdbg llvdbg
# else
# define cxxvdbg(x...)
# define cxxllvdbg(x...)
# endif
#else
# define cxxdbg(x...)
# define cxxlldbg(x...)
# define cxxvdbg(x...)
# define cxxllvdbg(x...)
#endif
/************************************************************************************
* Private Types
************************************************************************************/
/* This type defines one entry in initialization array */
typedef void (*initializer_t)(void);
/************************************************************************************
* External references
************************************************************************************/
/* _sinit and _einit are symbols exported by the linker script that mark the
* beginning and the end of the C++ initialization section.
*/
extern initializer_t _sinit;
extern initializer_t _einit;
/* _stext and _etext are symbols exported by the linker script that mark the
* beginning and the end of text.
*/
extern uint32_t _stext;
extern uint32_t _etext;
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/****************************************************************************
* Name: up_cxxinitialize
*
* Description:
* If C++ and C++ static constructors are supported, then this function
* must be provided by board-specific logic in order to perform
* initialization of the static C++ class instances.
*
* This function should then be called in the application-specific
* user_start logic in order to perform the C++ initialization. NOTE
* that no component of the core NuttX RTOS logic is involved; This
* function defintion only provides the 'contract' between application
* specific C++ code and platform-specific toolchain support
*
***************************************************************************/
void up_cxxinitialize(void)
{
initializer_t *initp;
cxxdbg("_sinit: %p _einit: %p _stext: %p _etext: %p\n",
&_sinit, &_einit, &_stext, &_etext);
/* Visit each entry in the initialzation table */
for (initp = &_sinit; initp != &_einit; initp++)
{
initializer_t initializer = *initp;
cxxdbg("initp: %p initializer: %p\n", initp, initializer);
/* Make sure that the address is non-NULL and lies in the text region
* defined by the linker script. Some toolchains may put NULL values
* or counts in the initialization table
*/
if ((void*)initializer > (void*)&_stext && (void*)initializer < (void*)&_etext)
{
cxxdbg("Calling %p\n", initializer);
initializer();
}
}
}
#endif /* CONFIG_HAVE_CXX && CONFIG_HAVE_CXXINITIALIZE */

View File

@ -0,0 +1,125 @@
/****************************************************************************
* config/samd20-xplained/src/sam_mmcsd.c
*
* Copyright (C) 2014 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 <debug.h>
#include <errno.h>
#include <nuttx/spi/spi.h>
#include <nuttx/mmcsd.h>
#include "samd20-xplained.h"
#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifdef CONFIG_DISABLE_MOUNTPOINT
# error Mountpoints are disabled (CONFIG_DISABLE_MOUNTPOINT=y)
#endif
#ifndef CONFIG_SAMD_SPI0 /* REVISIT */
# error SPI support is required (CONFIG_SAMD_SPI0)
#endif
#ifndef CONFIG_MMCSD
# error MMC/SD support is required (CONFIG_MMCSD)
#endif
#define SAMD_MMCSDSLOTNO 0 /* There is only one slot */
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_sdinitialize
*
* Description:
* Initialize the SPI-based SD card. Requires
* - CONFIG_SAM4L_XPLAINED_IOMODULE=y,
* - CONFIG_DISABLE_MOUNTPOINT=n,
* - CONFIG_MMCSD=y, and
* - CONFIG_SAMD_SPI0=y
*
*****************************************************************************/
int sam_sdinitialize(int minor)
{
FAR struct spi_dev_s *spi;
int ret;
/* Get the SPI driver instance for the SD chip select */
fvdbg("Initializing SPI chip select %d\n", SD_CSNO);
spi = up_spiinitialize(SD_CSNO);
if (!spi)
{
fdbg("Failed to initialize SPI chip select %d\n", SD_CSNO);
return -ENODEV;
}
fvdbg("Successfully initialized SPI chip select %d\n", SD_CSNO);
/* Bind the SPI device for the chip select to the slot */
fvdbg("Binding SPI chip select %d to MMC/SD slot %d\n",
SD_CSNO, SAMD_MMCSDSLOTNO);
ret = mmcsd_spislotinitialize(minor, SAMD_MMCSDSLOTNO, spi);
if (ret < 0)
{
fdbg("Failed to bind SPI chip select %d to MMC/SD slot %d: %d\n",
SD_CSNO, SAMD_MMCSDSLOTNO, ret);
return ret;
}
fvdbg("Successfuly bound SPI chip select %d to MMC/SD slot %d\n",
SD_CSNO, SAMD_MMCSDSLOTNO);
return OK;
}
#endif /* CONFIG_SAM4L_XPLAINED_IOMODULE */

View File

@ -0,0 +1,117 @@
/****************************************************************************
* config/samd20-xplained/src/sam_nsh.c
*
* Copyright (C) 2014 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 <debug.h>
#include "samd20-xplained.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
/* Support for the SD card slot on the I/O1 module */
/* Verify NSH PORT and SLOT settings */
# define SAMD_MMCSDSLOTNO 0 /* There is only one slot */
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != SAMD_MMCSDSLOTNO
# error Only one MMC/SD slot: Slot 0 (CONFIG_NSH_MMCSDSLOTNO)
# endif
# if defined(CONFIG_NSH_MMCSDSPIPORTNO) && CONFIG_NSH_MMCSDSPIPORTNO != SD_CSNO
# error CONFIG_NSH_MMCSDSPIPORTNO must have the same value as SD_CSNO
# endif
/* Default MMC/SD minor number */
# ifndef CONFIG_NSH_MMCSDMINOR
# define CONFIG_NSH_MMCSDMINOR 0
# endif
#endif
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lowsyslog(__VA_ARGS__)
# else
# define message(...) printf(__VA_ARGS__)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lowsyslog
# else
# define message printf
# endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int nsh_archinitialize(void)
{
#if defined(CONFIG_SAMD_SPI0) && defined(CONFIG_SAM4L_XPLAINED_IOMODULE)
/* Initialize the SPI-based MMC/SD slot */
{
int ret = sam_sdinitialize(CONFIG_NSH_MMCSDMINOR);
if (ret < 0)
{
message("nsh_archinitialize: Failed to initialize MMC/SD slot: %d\n",
ret);
return ret;
}
}
#endif
return OK;
}

View File

@ -0,0 +1,283 @@
/************************************************************************************
* configs/samd20-xplained/src/sam_spi.c
*
* Copyright (C) 2014 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_gpio.h"
#include "sam_spi.h"
#include "samd20-xplained.h"
#ifdef CONFIG_SAMD_SPI0 /* REVISIT */
/************************************************************************************
* Definitions
************************************************************************************/
/* Configuration ********************************************************************/
#if defined(CONFIG_SAM4L_XPLAINED_IOMODULE) && \
defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE) && defined(CONFIG_SPI_OWNBUS)
# error CONFIG_SPI_OWNBUS must not defined if using both I/O1 and OLED1 modules
#endif
/* Enables debug output from this file (needs CONFIG_DEBUG too) */
#undef SPI_DEBUG /* Define to enable debug */
#undef SPI_VERBOSE /* Define to enable verbose debug */
#ifdef SPI_DEBUG
# define spidbg lldbg
# ifdef SPI_VERBOSE
# define spivdbg lldbg
# else
# define spivdbg(x...)
# endif
#else
# undef SPI_VERBOSE
# define spidbg(x...)
# define spivdbg(x...)
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: sam_spiinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the SAM3U10E-EVAL board.
*
************************************************************************************/
void weak_function sam_spiinitialize(void)
{
/* The I/O module containing the SD connector may or may not be installed. And, if
* it is installed, it may be in connector EXT1 or EXT2.
*/
#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
/* TODO: enable interrupt on card detect */
sam_configgpio(GPIO_SD_CD); /* Card detect input */
sam_configgpio(GPIO_SD_CS); /* Chip select output */
#endif
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
sam_configgpio(GPIO_OLED_DATA); /* Command/data */
sam_configgpio(GPIO_OLED_CS); /* Card detect input */
#endif
}
/****************************************************************************
* Name: sam_spiselect, sam_spistatus, and sam_spicmddata
*
* Description:
* These external functions must be provided by board-specific logic. They
* include:
*
* o sam_spiselect is a functions tomanage the board-specific chip selects
* o sam_spistatus and sam_spicmddata: 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
* up_spiinitialize()) are provided by common SAM3/4 logic.
*
* To use this common SPI logic on your board:
*
* 1. Provide logic in sam_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide sam_spiselect() and sam_spistatus() 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_spicmddata() 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 up_spiinitialize() in your low level application
* initialization logic
* 4. The handle returned by up_spiinitialize() 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_spiselect
*
* 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:
* devid - Identifies the (logical) device
* selected - TRUE:Select the device, FALSE:De-select the device
*
* Returned Values:
* None
*
****************************************************************************/
void sam_spiselect(enum spi_dev_e devid, bool selected)
{
#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
/* Select/de-select the SD card */
if (devid == SPIDEV_MMCSD)
{
/* Active low */
sam_gpiowrite(GPIO_SD_CS, !selected);
}
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
else
#endif
#endif
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
/* Select/de-select the OLED */
if (devid == SPIDEV_DISPLAY)
{
/* Active low */
sam_gpiowrite(GPIO_OLED_CS, !selected);
}
#endif
}
/****************************************************************************
* Name: sam_spistatus
*
* Description:
* Return status information associated with the SPI device.
*
* Input Parameters:
* devid - Identifies the (logical) device
*
* Returned Values:
* Bit-encoded SPI status (see include/nuttx/spi/spi.h.
*
****************************************************************************/
uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
uint8_t ret = 0;
#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
/* Check if an SD card is present in the microSD slot */
if (devid == SPIDEV_MMCSD)
{
/* Active low */
if (!sam_gpioread(GPIO_SD_CD))
{
ret |= SPI_STATUS_PRESENT;
}
}
#endif
return ret;
}
#endif /* CONFIG_SAMD_SPI0 */
/****************************************************************************
* Name: sam_spicmddata
*
* 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 Values:
* Zero on success; a negated errno on failure.
*
****************************************************************************/
#ifdef CONFIG_SPI_CMDDATA
int sam_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
if (devid == SPIDEV_DISPLAY)
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*
* High: the inputs are treated as display data.
* Low: the inputs are transferred to the command registers.
*/
(void)sam_gpiowrite(GPIO_OLED_DATA, !cmd);
}
#endif
return OK;
}
#endif

View File

@ -0,0 +1,211 @@
/****************************************************************************
* config/samd20-xplained/src/sam_ug2832hsweg04.c
*
* Copyright (C) 2014 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.
*
****************************************************************************/
/* OLED1 Connector:
*
* OLED1 CONNECTOR
* ----------------- ---------------------- ----------------------
* OLED1 EXT1 EXT2
* ----------------- ---------------------- ----------------------
* 1 ID 1 1
* ----------------- ---------------------- ----------------------
* 2 GND 2 GND 2 GND
* ----------------- ---------------------- ----------------------
* 3 BUTTON2 3 PB00 AIN[8] 3 PA10 AIN[18]
* ----------------- ---------------------- ----------------------
* 4 BUTTON3 4 PB01 AIN[9] 4 PA11 AIN[19]
* ----------------- ---------------------- ----------------------
* 5 DATA_CMD_SEL 5 PB06 GPIO 5 PA20 GPIO
* ----------------- ---------------------- ----------------------
* 6 LED3 6 PB07 GPIO 6 PA21 GPIO
* ----------------- ---------------------- ----------------------
* 7 LED1 7 PB02 TC6/WO[0] 7 PA22 TC4/WO[0]
* ----------------- ---------------------- ----------------------
* 8 LED2 8 PB03 TC6/WO[1] 8 PA23 TC4/WO[1]
* ----------------- ---------------------- ----------------------
* 9 BUTTON1 9 PB04 EXTINT[4] 9 PB14 EXTINT[14]
* ----------------- ---------------------- ----------------------
* 10 DISPLAY_RESET 10 PB05 GPIO 10 PB15 GPIO
* ----------------- ---------------------- ----------------------
* 11 N/C 11 PA08 SERCOM2 PAD[0] 11 PA08 SERCOM2 PAD[0]
* I²C SDA I²C SDA
* ----------------- ---------------------- ----------------------
* 12 N/C 12 PA09 SERCOM2 PAD[1] 12 PA09 SERCOM2 PAD[1]
* I²C SCL I²C SCL
* ----------------- ---------------------- ----------------------
* 13 N/C 13 PB09 SERCOM4 PAD[1] 13 PB13 SERCOM4 PAD[1]
* UART RX UART RX
* ----------------- ---------------------- ----------------------
* 14 N/C 14 PB08 SERCOM4 PAD[0] 14 PB12 SERCOM4 PAD[0]
* UART TX UART TX
* ----------------- ---------------------- ----------------------
* 15 DISPLAY_SS 15 PA05 SERCOM0 PAD[1] 15 PA17 SERCOM1 PAD[1]
* SPI SS SPI SS
* ----------------- ---------------------- ----------------------
* 16 SPI_MOSI 16 PA06 SERCOM0 PAD[2] 16 PA18 SERCOM1 PAD[2]
* SPI MOSI SPI MOSI
* ----------------- ---------------------- ----------------------
* 17 N/C 17 PA04 SERCOM0 PAD[0] 17 PA16 SERCOM1 PAD[0]
* SPI MISO SPI MISO
* ----------------- ---------------------- ----------------------
* 18 SPI_SCK 18 PA07 SERCOM0 PAD[3] 18 PA19 SERCOM1 PAD[3]
* SPI SCK SPI SCK
* ----------------- ---------------------- ----------------------
* 19 GND 19 GND GND
* ----------------- ---------------------- ----------------------
* 20 VCC 20 VCC VCC
* ----------------- ---------------------- ----------------------
*
* OLED1 signals
*
* DATA_CMD_SEL - Data/command select. Used to choose whether the
* communication is data to the display memory or a command to the LCD
* controller. High = data, low = command
* DISPLAY_RESET - Reset signal to the OLED display, active low. Used during
* initialization of the display.
* DISPLAY_SS - SPI slave select signal, must be held low during SPI
* communication.
* SPI_MOSI - SPI master out, slave in signal. Used to write data to the
* display
* SPI_SCK SPI - clock signal, generated by the master.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/spi/spi.h>
#include <nuttx/lcd/lcd.h>
#include <nuttx/lcd/ssd1306.h>
#include "sam_gpio.h"
#include "samd20-xplained.h"
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* The pin configurations here require that SPI1 is selected */
#ifndef CONFIG_LCD_SSD1306
# error "The OLED driver requires CONFIG_LCD_SSD1306 in the configuration"
#endif
#ifndef CONFIG_LCD_UG2832HSWEG04
# error "The OLED driver requires CONFIG_LCD_UG2832HSWEG04 in the configuration"
#endif
#ifndef CONFIG_SAMD_SPI0
# error "The OLED driver requires CONFIG_SAMD_SPI0 in the configuration"
#endif
#ifndef CONFIG_SPI_CMDDATA
# error "The OLED driver requires CONFIG_SPI_CMDDATA in the configuration"
#endif
/* Debug ********************************************************************/
#ifdef CONFIG_DEBUG_LCD
# define lcddbg(format, arg...) dbg(format, ##arg)
# define lcdvdbg(format, arg...) vdbg(format, ##arg)
#else
# define lcddbg(x...)
# define lcdvdbg(x...)
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_nxdrvinit
*
* Description:
* Called by NX initialization logic to configure the OLED.
*
****************************************************************************/
FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno)
{
FAR struct spi_dev_s *spi;
FAR struct lcd_dev_s *dev;
/* Configure the OLED GPIOs. This initial configuration is RESET low,
* putting the OLED into reset state.
*/
(void)sam_configgpio(GPIO_OLED_RST);
/* Wait a bit then release the OLED from the reset state */
up_mdelay(20);
sam_gpiowrite(GPIO_OLED_RST, true);
/* Get the SPI1 port interface */
spi = up_spiinitialize(OLED_CSNO);
if (!spi)
{
lcddbg("Failed to initialize SPI port 1\n");
}
else
{
/* Bind the SPI port to the OLED */
dev = ssd1306_initialize(spi, devno);
if (!dev)
{
lcddbg("Failed to bind SPI port 1 to OLED %d: %d\n", devno);
}
else
{
lcdvdbg("Bound SPI port 1 to OLED %d\n", devno);
/* And turn the OLED on */
(void)dev->setpower(dev, CONFIG_LCD_MAXPOWER);
return dev;
}
}
return NULL;
}
#endif /* CONFIG_SAM4L_XPLAINED_OLED1MODULE */

View File

@ -0,0 +1,142 @@
/****************************************************************************
* configs/samd20-xplained/src/sam_userleds.c
*
* Copyright (C) 2014 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 are three LEDs on board the SAMD20 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 labeled STATUS near the SAMD20 USB
* connector.
*
* This LED is controlled by PA14 and the LED can be activated by driving PA14
* to GND.
*
* 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_gpio.h"
#include "samd20-xplained.h"
#ifndef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
* with CONFIG_DEBUG_VERBOSE too)
*/
#ifdef CONFIG_DEBUG_LEDS
# define leddbg lldbg
# define ledvdbg llvdbg
#else
# define leddbg(x...)
# define ledvdbg(x...)
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_ledinit
*
* Description:
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
* LEDs. If CONFIG_ARCH_LEDS is not defined, then the sam_ledinit() is
* available to initialize the LED from user application logic.
*
****************************************************************************/
void sam_ledinit(void)
{
(void)sam_configgpio(GPIO_STATUS_LED);
}
/****************************************************************************
* Name: sam_setled
*
* Description:
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
* LEDs. If CONFIG_ARCH_LEDS is not defined, then the sam_setled() is
* available to control the LED from user application logic.
*
*****************************************************************************/
void sam_setled(int led, bool ledon)
{
if (led == BOARD_STATUS_LED)
{
sam_gpiowrite(GPIO_STATUS_LED, !ledon);
}
}
/****************************************************************************
* Name: sam_setled
*
* Description:
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
* LEDs. If CONFIG_ARCH_LEDS is not defined, then the sam_setleds() 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 sam_setleds(uint8_t ledset)
{
sam_setled(BOARD_STATUS_LED, (ledset & BOARD_STATUS_LED_BIT) != 0);
}
#endif /* !CONFIG_ARCH_LEDS */

View File

@ -0,0 +1,277 @@
/************************************************************************************
* configs/samd20-xplained/src/samd20-xplained.h
*
* Copyright (C) 2014 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 __CONFIGS_SAMD20_XPLAINED_SRC_SAMD20_XPLAINED_H
#define __CONFIGS_SAMD20_XPLAINED_SRC_SAMD20_XPLAINED_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
#include <arch/irq.h>
#include <nuttx/irq.h>
#include "chip/sam_pinmap.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* LEDs: There are three LEDs on board the SAMD20 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 SAMD20 USB
* connector.
*
* This LED is controlled by PA14 and the LED can be activated by driving PA14
* 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 GPIO_STATUS_LED (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_SET | \
GPIO_PORTA | GPIO_PIN14)
/* Mechanical buttons:
*
* The SAMD20 Xplained Pro contains two mechanical buttons. One button is the
* RESET button connected to the SAMD20 reset line and the other is a generic user
* configurable button. When a button is pressed it will drive the I/O line to GND.
*
* PA15 SW0
*/
#define GPIO_SW0 (GPIO_INTERRUPT | GPIO_PULL_UP | GPIO_GLITCH_FILTER | \
GPIO_PORTA | GPIO_PIN15)
#define IRQ_SW0 SAM_IRQ_PA15
/* I/O1
*
* Support for the microSD card slot on the I/O1 module. The I/O1 requires
* SPI support and two GPIOs. These the GPIOs will vary if the I/O1
* is installed on the EXT1 or EXT2 connector:
*
* --- ------------------ ---------------------- -------------------------------
* PIN EXT1 EXT2 Description
* --- ------------------ ---------------------- -------------------------------
* 15 PA05 SERCOM0 PAD[1] 15 PA17 SERCOM1 PAD[1] Active low chip select OUTPUT,
* SPI SS SPI SS pulled high on board.
* --- ------------------ ---------------------- -------------------------------
* 10 PB05 GPIO 10 PB15 GPIO Active low card detect INPUT,
* must use internal pull-up.
* --- ------------------ ---------------------- -------------------------------
*/
#ifdef CONFIG_SAMD20_XPLAINED_IOMODULE
# ifndef CONFIG_SAMD_SPI0
# error CONFIG_SAMD_SPI0 is required to use the I/O1 module
# endif
# if defined(CONFIG_SAMD20_XPLAINED_IOMODULE_EXT1)
# if defined(CONFIG_SAMD20_XPLAINED_OLED1MODULE) && \
defined(CONFIG_SAMD20_XPLAINED_OLED1MODULE_EXT1)
# error I/O1 and OLED1 modules cannot both reside in EXT1
# endif
# define GPIO_SD_CD (GPIO_INTERRUPT | GPIO_INT_CHANGE | GPIO_PULL_UP | \
GPIO_GLITCH_FILTER | GPIO_PORTF | GPIO_PIN5)
# define IRQ_SD_CD SAM_IRQ_PB5
# define GPIO_SD_CS (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_SET | \
GPIO_PORTA | GPIO_PIN5)
# define SD_CSNO 0
# elif defined(CONFIG_SAMD20_XPLAINED_IOMODULE_EXT2)
# if defined(CONFIG_SAMD20_XPLAINED_OLED1MODULE) && \
defined(CONFIG_SAMD20_XPLAINED_OLED1MODULE_EXT2)
# error I/O1 and OLED1 modules cannot both reside in EXT2
# endif
# define GPIO_CD (GPIO_INTERRUPT | GPIO_INT_CHANGE | GPIO_PULL_UP | \
GPIO_GLITCH_FILTER | GPIO_PORTB | GPIO_PIN15)
# define IRQ_CD SAM_IRQ_PB15
# define GPIO_SD_CS (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_SET | \
GPIO_PORTA | GPIO_PIN17)
# define SD_CSNO 2
# else
# error Which connector is the I/O1 module installed in?
# endif
#endif
/* OLED1
*
* Support for the microSD card slot on the I/O1 module. The I/O1 requires
* SPI support and three output GPIOs. These the GPIOs will vary if the OLED1
* is installed on the EXT1 or EXT2 connector:
*
*
* PIN EXT1 EXT2 Description
* --- ------------------- -------------------- -------------------------------------
* 5 PB06 GPIO PA20 GPIO DATA_CMD_SEL
* 10 PB05 GPIO PB15 GPIO DISPLAY_RESET. Active low.
* 15 PA05 SERCOM0 PAD[1] PA17 SERCOM1 PAD[1] DISPLAY_SS. Active low.
* SPI SS SPI SS
*/
#ifdef CONFIG_SAMD20_XPLAINED_OLED1MODULE
# ifndef CONFIG_SAMD_SPI0 /* REVISIT */
# error CONFIG_SAMD_SPI0 is required to use the OLED1 module
# endif
# ifndef CONFIG_SPI_CMDDATA
# error CONFIG_SPI_CMDDATA is required to use the OLED1 module
# endif
# ifndef CONFIG_LCD_SSD1306
# error CONFIG_LCD_SSD1306 is required to use the OLED1 module
# endif
# ifndef CONFIG_LCD_UG2832HSWEG04
# error CONFIG_LCD_UG2832HSWEG04 is required to use the OLED1 module
# endif
# if defined(CONFIG_SAMD20_XPLAINED_OLED1MODULE_EXT1)
# if defined(CONFIG_SAMD20_XPLAINED_IOMODULE) && \
defined(CONFIG_SAMD20_XPLAINED_IOMODULE_EXT1)
# error OLED1 and I/O1 modules cannot both reside in EXT1
# endif
# define GPIO_OLED_DATA (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_CLEAR | \
GPIO_PORTB | GPIO_PIN6)
# define GPIO_OLED_RST (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_CLEAR | \
GPIO_PORTB | GPIO_PIN5)
# define GPIO_OLED_CS (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_SET | \
GPIO_PORTA | GPIO_PIN5)
# define OLED_CSNO 0
# elif defined(CONFIG_SAMD20_XPLAINED_OLED1MODULE_EXT2)
# if defined(CONFIG_SAMD20_XPLAINED_IOMODULE) && \
defined(CONFIG_SAMD20_XPLAINED_IOMODULE_EXT2)
# error OLED1 and I/O1 modules cannot both reside in EXT2
# endif
# define GPIO_OLED_DATA (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_CLEAR | \
GPIO_PORTA | GPIO_PIN20)
# define GPIO_OLED_RST (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_CLEAR | \
GPIO_PORTB | GPIO_PIN15)
# define GPIO_OLED_CS (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_SET | \
GPIO_PORTA | GPIO_PIN17)
# define OLED_CSNO 2
# else
# error Which connector is the OLED1 module installed in?
# endif
#endif
#if defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01)
# define GPIO_SD_CS (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_SET | \
GPIO_PORTB | GPIO_PIN11) /* REVISIT */
#endif
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Public data
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: sam_spiinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the SAM3U-EK board.
*
************************************************************************************/
void weak_function sam_spiinitialize(void);
/************************************************************************************
* Name: sam_sdinitialize
*
* Description:
* Initialize the SPI-based SD card. Requires CONFIG_SAMD20_XPLAINED_IOMODULE=y,
* CONFIG_DISABLE_MOUNTPOINT=n, CONFIG_MMCSD=y, and CONFIG_SAMD_SPI0=y
*
************************************************************************************/
#if defined(CONFIG_SAMD_SPI0) && defined(CONFIG_SAMD20_XPLAINED_IOMODULE)
int sam_sdinitialize(int minor);
#endif
/************************************************************************************
* Name: board_led_initialize
************************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void board_led_initialize(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_SAMD20_XPLAINED_SRC_SAMD20_XPLAINED_H */