mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 21:34:07 +08:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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 */
|
||||
@@ -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
|
||||
File diff suppressed because it is too large
Load Diff
Executable
+75
@@ -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}"
|
||||
Executable
+121
@@ -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) }
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
/.depend
|
||||
/Make.dep
|
||||
@@ -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
|
||||
@@ -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 */
|
||||
@@ -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
|
||||
}
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user