From 1acfa1771ba4ffc1ca660f9a6733ea28f2a68d1c Mon Sep 17 00:00:00 2001
From: Gregory Nutt
Date: Tue, 9 Jun 2015 15:54:04 -0600
Subject: [PATCH] Rename teensy-3.1 directory to teensy-3.x. Add board.h
header file
---
Documentation/NuttX.html | 2 +-
README.txt | 2 +-
configs/Kconfig | 27 +++
configs/README.txt | 15 ++
configs/{teensy-3.1 => teensy-3.x}/README.txt | 17 +-
configs/teensy-3.x/include/board.h | 206 ++++++++++++++++++
6 files changed, 261 insertions(+), 8 deletions(-)
rename configs/{teensy-3.1 => teensy-3.x}/README.txt (94%)
create mode 100644 configs/teensy-3.x/include/board.h
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index 7f534b02dc..507ee76868 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -3281,7 +3281,7 @@ nsh>
STATUS:
There are no K20 boards yet supported.
Work is underway on the the PJRC Teensy-3.1 board and that port is expected in NuttX-7.11.
- Refer to the Teensy-3.1 board README file for further information.
+ Refer to the Teensy-3.1 board README file for further information.
diff --git a/README.txt b/README.txt
index 2ba063410e..e09b853831 100644
--- a/README.txt
+++ b/README.txt
@@ -1330,7 +1330,7 @@ nuttx
| | `- README.txt
| |- teensy-2.0/
| | `- README.txt
- | |- teensy-3.1/
+ | |- teensy-3.x/
| | `- README.txt
| |- teensy-lc/
| | `- README.txt
diff --git a/configs/Kconfig b/configs/Kconfig
index cc938e4799..156e1d3225 100644
--- a/configs/Kconfig
+++ b/configs/Kconfig
@@ -908,6 +908,29 @@ config ARCH_BOARD_TEENSY_20
developed by http://pjrc.com/teensy/. The Teensy++ 2.0 is based
on an Atmel AT90USB1286 MCU.
+config ARCH_BOARD_TEENSY_3X
+ bool "PJRC Teensy++ 3.1 board"
+ depends on ARCH_CHIP_MK20DX256VLH7
+ select ARCH_HAVE_LEDS
+ ---help---
+ This is the port of NuttX to the PJRC Teensy++ 2.0 board. This board is
+ developed by http://pjrc.com/teensy/. The Teensy++ 2.0 is based
+ on an Atmel AT90USB1286 MCU.
+
+ This is the port of NuttX to the Teensy-3.1 from PJRC
+ (https://www.pjrc.com/). The Teensy-3.1 features the Freescale
+ MK30DX256VLH7 chip (now NXP). The MK30DX256VLH7 is a 64-pin Cortex-M4
+ running at 72MHz. It has 256KiB of program FLASH memory and 64KiB of
+ SRAM. For more information about the Teensy 3.1, see
+
+ https://www.pjrc.com/teensy/teensy31.html
+ https://www.pjrc.com/store/teensy31.html
+
+ This board configuration can also be used with the older Teensy-3.0. The
+ Teensy-3.0 has the same schematic (although some pins are not used on the
+ Teensy-3.0). the primary difference is that the Teensy 3.0 has a
+ MK30DX128VLH5 with slightly less capability.
+
config ARCH_BOARD_TEENSY_LC
bool "Teensy LC"
depends on ARCH_CHIP_MKL25Z64
@@ -1238,6 +1261,7 @@ config ARCH_BOARD
default "mikroe-stm32f4" if ARCH_BOARD_MIKROE_STM32F4
default "sure-pic32mx" if ARCH_BOARD_SUREPIC32MX
default "teensy-2.0" if ARCH_BOARD_TEENSY_20
+ default "teensy-3.x" if ARCH_BOARD_TEENSY_3X
default "teensy-lc" if ARCH_BOARD_TEENSY_LC
default "tm4c123g-launchpad" if ARCH_BOARD_TM4C123G_LAUNCHPAD
default "tm4c1294-launchpad" if ARCH_BOARD_TM4C1294_LAUNCHPAD
@@ -1569,6 +1593,9 @@ endif
if ARCH_BOARD_TEENSY_20
source "configs/teensy-2.0/Kconfig"
endif
+if ARCH_BOARD_TEENSY_3X
+source "configs/teensy-3.x/Kconfig"
+endif
if ARCH_BOARD_TEENSY_LC
source "configs/teensy-lc/Kconfig"
endif
diff --git a/configs/README.txt b/configs/README.txt
index 2843cbd07e..00c808f778 100644
--- a/configs/README.txt
+++ b/configs/README.txt
@@ -607,6 +607,21 @@ configs/teensy-2.0
developed by http://pjrc.com/teensy/. The Teensy++ 2.0 is based
on an Atmel AT90USB1286 MCU.
+configs/teensy-3.x
+ This is the port of NuttX to the Teensy-3.1 from PJRC
+ (https://www.pjrc.com/). The Teensy-3.1 features the Freescale
+ MK30DX256VLH7 chip (now NXP). The MK30DX256VLH7 is a 64-pin Cortex-M4
+ running at 72MHz. It has 256KiB of program FLASH memory and 64KiB of
+ SRAM. For more information about the Teensy 3.1, see
+
+ https://www.pjrc.com/teensy/teensy31.html
+ https://www.pjrc.com/store/teensy31.html
+
+ This board configuration can also be used with the older Teensy-3.0. The
+ Teensy-3.0 has the same schematic (although some pins are not used on the
+ Teensy-3.0). the primary difference is that the Teensy 3.0 has a
+ MK30DX128VLH5 with slightly less capability.
+
configs/teensy-lc
This is the port of nuttx for the Teensy LC board. The Teensy LC
is a DIP style breakout board for the MKL25Z64 and comes with a USB
diff --git a/configs/teensy-3.1/README.txt b/configs/teensy-3.x/README.txt
similarity index 94%
rename from configs/teensy-3.1/README.txt
rename to configs/teensy-3.x/README.txt
index a548e1b980..8079ec91e8 100644
--- a/configs/teensy-3.1/README.txt
+++ b/configs/teensy-3.x/README.txt
@@ -6,10 +6,15 @@ README
MK30DX256VLH7 chip (now NXP). The MK30DX256VLH7 is a 64-pin Cortex-M4
running at 72MHz. It has 256KiB of program FLASH memory and 64KiB of
SRAM. For more information about the Teensy 3.1, see
-
+
https://www.pjrc.com/teensy/teensy31.html
https://www.pjrc.com/store/teensy31.html
+ This board configuration can also be used with the older Teensy-3.0. The
+ Teensy-3.0 has the same schematic (although some pins are not used on the
+ Teensy-3.0). the primary difference is that the Teensy 3.0 has a
+ MK30DX128VLH5 with slightly less capability.
+
Contents
========
@@ -133,11 +138,11 @@ Teensy-3.1 Configuration settings
CONFIG_ARCH_BOARD - Identifies the configs subdirectory and
hence, the board that supports the particular chip or SoC.
- CONFIG_ARCH_BOARD="teensy-3.1"
+ CONFIG_ARCH_BOARD="teensy-3.x"
CONFIG_ARCH_BOARD_name - For use in C code
- CONFIG_ARCH_BOARD_TEENSY_31=y
+ CONFIG_ARCH_BOARD_TEENSY_3X=y
CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
of delay loops
@@ -179,11 +184,11 @@ Configurations
Common Configuration Information
--------------------------------
- Each Teensy-3.1 configurations are maintained in sub-directories and
+ Each Teensy-3.x configurations are maintained in sub-directories and
can be selected as follow:
cd tools
- ./configure.sh teensy-3.1/
+ ./configure.sh teensy-3.x/
cd -
make oldconfig
. ./setenv.sh
@@ -195,7 +200,7 @@ Configurations
If this is a Windows native build, then configure.bat should be used
instead of configure.sh:
- configure.bat teensy-3.1\
+ configure.bat teensy-3.x\
And then build NuttX by simply typing the following. At the conclusion of
the make, the nuttx binary will reside in an ELF file called, simply,
diff --git a/configs/teensy-3.x/include/board.h b/configs/teensy-3.x/include/board.h
new file mode 100644
index 0000000000..e4b6d7c3d0
--- /dev/null
+++ b/configs/teensy-3.x/include/board.h
@@ -0,0 +1,206 @@
+/************************************************************************************
+ * configs/teensy-3.x/include/board.h
+ * include/arch/board/board.h
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * 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_TEENSY_3X_INCLUDE_BOARD_H
+#define __CONFIGS_TEENSY_3X_INCLUDE_BOARD_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+#ifndef __ASSEMBLY__
+# include
+#endif
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* Clocking *************************************************************************/
+/* The teensy-3.1 has a 16MHz crystal on board */
+
+#undef BOARD_EXTCLOCK /* Crystal */
+#define BOARD_EXTAL_FREQ 16000000 /* 16MHz crystal frequency (REFCLK) */
+#define BOARD_XTAL32_FREQ 32768 /* 32KHz RTC Oscillator (not populated) */
+
+/* PLL Configuration. NOTE: Only even frequency crystals are supported that will
+ * produce a 2MHz reference clock to the PLL. The rated speed is 72MHz, but can
+ * be overclocked at 96MHz
+ *
+ * 72MHz
+ *
+ * PLL Input frequency: PLLIN = REFCLK/PRDIV = 16MHz/2 = 8MHz
+ * PLL Output frequency: PLLOUT = PLLIN*VDIV = 8Mhz*9 = 72MHz
+ * MCG Frequency: PLLOUT = 96MHz
+ *
+ * 96MHz
+ * PLL Input frequency: PLLIN = REFCLK/PRDIV = 16MHz/1 = 16MHz
+ * PLL Output frequency: PLLOUT = PLLIN*VDIV = 16Mhz*6 = 96MHz
+ * MCG Frequency: PLLOUT = 96MHz
+ */
+
+#define BOARD_PRDIV 2 /* PLL External Reference Divider */
+#define BOARD_VDIV 24 /* PLL VCO Divider (frequency multiplier) */
+
+#define BOARD_PLLIN_FREQ (BOARD_EXTAL_FREQ / BOARD_PRDIV)
+#define BOARD_PLLOUT_FREQ (BOARD_PLLIN_FREQ * BOARD_VDIV)
+#define BOARD_MCG_FREQ BOARD_PLLOUT_FREQ
+
+/* SIM CLKDIV1 dividers */
+
+#define BOARD_OUTDIV1 1 /* Core = MCG, 96MHz */
+#define BOARD_OUTDIV2 2 /* Bus = MCG/2, 48MHz */
+#define BOARD_OUTDIV3 2 /* FlexBus = MCG/2, 48MHz */
+#define BOARD_OUTDIV4 4 /* Flash clock = MCG/4, 24MHz */
+
+#define BOARD_CORECLK_FREQ (BOARD_MCG_FREQ / BOARD_OUTDIV1)
+#define BOARD_BUS_FREQ (BOARD_MCG_FREQ / BOARD_OUTDIV2)
+#define BOARD_FLEXBUS_FREQ (BOARD_MCG_FREQ / BOARD_OUTDIV3)
+#define BOARD_FLASHCLK_FREQ (BOARD_MCG_FREQ / BOARD_OUTDIV4)
+
+/* SDHC clocking ********************************************************************/
+
+/* SDCLK configurations corresponding to various modes of operation. Formula is:
+ *
+ * SDCLK frequency = (base clock) / (prescaler * divisor)
+ *
+ * The SDHC module is always configure configured so that the core clock is the base
+ * clock.
+ */
+
+/* Identification mode: 400KHz = 96MHz / ( 16 * 15) */
+
+#define BOARD_SDHC_IDMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
+#define BOARD_SDHC_IDMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
+
+/* MMC normal mode: 16MHz = 96MHz / (2 * 3) */
+
+#define BOARD_SDHC_MMCMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
+#define BOARD_SDHC_MMCMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
+
+/* SD normal mode (1-bit): 16MHz = 96MHz / (2 * 3) */
+
+#define BOARD_SDHC_SD1MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
+#define BOARD_SDHC_SD1MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
+
+/* SD normal mode (4-bit): 24MHz = 96MHz / (2 * 2) (with DMA)
+ * SD normal mode (4-bit): 16MHz = 96MHz / (2 * 3) (no DMA)
+ */
+
+#ifdef CONFIG_SDIO_DMA
+# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
+# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(2)
+#else
+//# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
+//# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
+# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
+# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
+#endif
+
+/* LED definitions ******************************************************************/
+/* A single LED is available driven by PTC5. The LED is grounded so bringing PTC5
+ * high will illuminate the LED.
+ */
+
+/* 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 ***************************************************************/
+/* The teensy-3.1 board has no standard GPIO contact buttons */
+
+/* Alternative pin resolution *******************************************************/
+/* To be provided */
+
+/************************************************************************************
+ * Public Data
+ ************************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/************************************************************************************
+ * Public Function Prototypes
+ ************************************************************************************/
+/************************************************************************************
+ * Name: kinetis_boardinitialize
+ *
+ * Description:
+ * All STM32 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 kinetis_boardinitialize(void);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __CONFIGS_TEENSY_3X_INCLUDE_BOARD_H */