diff --git a/Documentation/README.html b/Documentation/README.html index 6595cea3fd..fe5aa0286e 100644 --- a/Documentation/README.html +++ b/Documentation/README.html @@ -8,7 +8,7 @@

NuttX README Files

-

Last Updated: April 15, 2018

+

Last Updated: April 18, 2018

@@ -322,6 +322,8 @@ nuttx/ | | `- README.txt | |- tm4c1294-launchpad/ | | `- README.txt + | |- tms570ls31x-usb-kit/ + | | `- README.txt | |- twr-k60n512/ | | `- README.txt | |- twr-k64f120m/ diff --git a/README.txt b/README.txt index 1a1d762c77..d760f17dcc 100644 --- a/README.txt +++ b/README.txt @@ -1892,6 +1892,8 @@ nuttx/ | | `- README.txt | |- twr-k60n512/ | | `- README.txt + | |- tms570ls31x-usb-kit/ + | | `- README.txt | |- twr-k64f120m/ | | `- README.txt | |- u-blox-co27/ diff --git a/configs/Kconfig b/configs/Kconfig index 4bc5432754..4ad0b46697 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -1401,6 +1401,16 @@ config ARCH_BOARD_TM4C1294_LAUNCHPAD ---help--- Tiva EK-TM4C1294XL LaunchPad. +config ARCH_BOARD_TMS570LS31X_USB_KIT + bool "TI TMS570LS31X_USB_KIT" + depends on ARCH_CHIP_TMS570LS3137ZWT + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS + ---help--- + TI Hercules TMS570LS31xx Evaluation Kit (TMDS570ls31xx USB Kit) + featuring the Hercules TMS570LS3137ZWT chip. + config ARCH_BOARD_TWR_K60N512 bool "FreeScale TWR-K60N512 development board" depends on ARCH_CHIP_MK60N512VMD100 @@ -1735,6 +1745,7 @@ config ARCH_BOARD default "teensy-lc" if ARCH_BOARD_TEENSY_LC default "tm4c123g-launchpad" if ARCH_BOARD_TM4C123G_LAUNCHPAD default "tm4c1294-launchpad" if ARCH_BOARD_TM4C1294_LAUNCHPAD + default "tms570ls31x-usb-kit" if ARCH_BOARD_TMS570LS31X_USB_KIT default "twr-k60n512" if ARCH_BOARD_TWR_K60N512 default "twr-k64f120m" if ARCH_BOARD_TWR_K64F120M default "u-blox-c027" if ARCH_BOARD_U_BLOX_C027 @@ -2182,6 +2193,9 @@ endif if ARCH_BOARD_TM4C1294_LAUNCHPAD source "configs/tm4c1294-launchpad/Kconfig" endif +if ARCH_BOARD_TMS570LS31X_USB_KIT +source "configs/tms570ls31x-usb-kit/Kconfig" +endif if ARCH_BOARD_TWR_K60N512 source "configs/twr-k60n512/Kconfig" endif diff --git a/configs/README.txt b/configs/README.txt index 34ee5a821e..4a0a9ac54b 100644 --- a/configs/README.txt +++ b/configs/README.txt @@ -781,6 +781,10 @@ configs/tm4c1294-launchpad platform for ARM® Cortex™-M4F-based microcontrollers from Texas Instruments. +configs/tms570ls31x-usb-kit + TI Hercules TMS570LS31xx Evaluation Kit (TMDS570ls31xx USB Kit) + featuring the Hercules TMS570LS3137ZWT chip. + configs/twr-k60n512 Kinetis K60 Cortex-M4 MCU. This port uses the FreeScale TWR-K60N512 development board. diff --git a/configs/launchxl-tms57004/src/tms570_buttons.c b/configs/launchxl-tms57004/src/tms570_buttons.c index d84de8f63a..f8f2405bd3 100644 --- a/configs/launchxl-tms57004/src/tms570_buttons.c +++ b/configs/launchxl-tms57004/src/tms570_buttons.c @@ -186,7 +186,7 @@ int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) #ifdef HAVE_IRQBUTTONS if (id == BUTTON_GIOA7) { - return board_button_irqx(GIO_BUTTON, IRQ_BUTTON, irqhandler,i + return board_button_irqx(GIO_BUTTON, IRQ_BUTTON, irqhandler, &g_irq_button, arg); } #endif diff --git a/configs/tms570ls31x-usb-kit/Kconfig b/configs/tms570ls31x-usb-kit/Kconfig new file mode 100644 index 0000000000..1bfcff66cd --- /dev/null +++ b/configs/tms570ls31x-usb-kit/Kconfig @@ -0,0 +1,8 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_TMS570LS31x_USB_KIT + +endif # ARCH_BOARD_TMS570LS31x_USB_KIT diff --git a/configs/tms570ls31x-usb-kit/README.txt b/configs/tms570ls31x-usb-kit/README.txt new file mode 100644 index 0000000000..b9eac6e43d --- /dev/null +++ b/configs/tms570ls31x-usb-kit/README.txt @@ -0,0 +1,114 @@ +README +====== + + This README provides some information about the port of NuttX to the TI + Hercules TMS570LS31x USB Kit featuring the Hercules TMS570LS3137ZWT chip. + +Contents +======== + + - Status + - Toolchain + - LEDs and Buttons + - Serial Console + - Debugging + - Configurations + +Status +====== + + 2017-10-18: + The basic port to the TMS570 is complete. The NSH with basic commands is + up and running. There is support for SCI communication and RTI. + +Toolchain +========= + + Build Platform + -------------- + All of these configurations are set up to build with Ubuntu. + + Endian-ness Issues + ------------------ + I used a version of the NuttX buildroot toolchain that can be built like + this: + + cd buildroot/ + cp configs/cortexr4f-eabi-defconfig-4.8.5 .config + make oldconfig + make + + Before building the compiler I installed the following packages which + are needed for the compiler build. + + # install or update all apt-get dependencies + sudo apt-get update + sudo apt-get upgrade + sudo apt-get install gcc # not cross + sudo apt-get install g++ + sudo apt-get install make + sudo apt-get install bison + sudo apt-get install flex + sudo apt-get install gawk + sudo apt-get install libgmp3-dev + sudo apt-get install libmpfr-dev libmpfr-doc libmpfr4 libmpfr4-dbg + sudo apt-get install mpc + sudo apt-get install texinfo # optional + sudo apt-get install libcloog-isl-dev # optional + sudo apt-get install build-essential + sudo apt-get install glibc-devel + sudo apt-get -y install gcc-multilib libc6-i386 + +Serial Console +============== + + This TMS570ls3137 has a single SCI and one combined SCI/LIN interface. + The SCI_RX and TX pins are connected to the FTDI chip which provides a + virtual COM port for the usb kit. + +Debugging +========= + + I used the On Board Debugger. + +Configurations +============== + + Information Common to All Configurations + ---------------------------------------- + Each TMS570LS31X Usb Kit configuration is maintained in a sub-directory and + can be selected as follow: + + cd tools + ./configure.sh tms570ls31x-usb-kit/ + cd - + + Before building, make sure the PATH environment variable includes the + correct path to the directory than holds your toolchain binaries. + + And then build NuttX by simply typing the following. At the conclusion of + the make, the nuttx binary will reside in an ELF file called, simply, nuttx. + + make oldconfig + make + + The that is provided above as an argument to the tools/configure.sh + must be is one of the following. + + NOTES: + + 1. These configurations use the mconf-based configuration tool. To + change any of these configurations using that tool, you should: + + a. Build and install the kconfig-mconf tool. See nuttx/README.txt + see additional README.txt files in the NuttX tools repository. + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + +Configuration sub-directories +----------------------------- + + nsh: + + Configures the NuttShell (nsh) located at examples/nsh. diff --git a/configs/tms570ls31x-usb-kit/include/board.h b/configs/tms570ls31x-usb-kit/include/board.h new file mode 100644 index 0000000000..ec58c66354 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/include/board.h @@ -0,0 +1,290 @@ +/************************************************************************************ + * configs/tms570ls31x-usb-kit/include/board.h + * + * Copyright (C) 2017 Ivan Ucherdzhiev. All rights reserved. + * Author: Ivan Ucherdzhiev + * + * 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_TMX570LS31X_USB_KIT_INCLUDE_BOARD_H +#define __CONFIGS_TMX570LS31X_USB_KIT_INCLUDE_BOARD_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#ifndef __ASSEMBLY__ +# include +# include +#endif + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +/* Clocking *************************************************************************/ +/* The tms570ls31x-usb-kit has a 16 MHz external crystal. */ + +#define BOARD_FCLKIN_FREQUENCY 16000000 /* 16 MHz crystal frequency */ + +/* The maximum frequency for the TMS570LS3137 is 180 MHz. + * + * REFCLKDIV controls input clock divider: + * + * NR = REFCLKDIV+1 + * Fintclk = Fclkin / NR + * + * PLLMUL controls multipler on divided input clock (Fintclk): + * + * Non-modulated: + * NF = (PLLMUL + 256) / 256 + * Modulated: + * NF = (PLLMUL + MULMOD + 256) / 256 + * + * Foutputclk = Fintclk x NF (150MHz - 550MHz) + * + * ODPLL controls internal PLL output divider: + * + * OD = ODPLL+1 + * Fpostodclk = Foutputclock / OD + * + * Final divisor, R, controls PLL output: + * + * R = PLLDIV + 1 + * Fpllclock = Fpostodclk / R + * + * Or: + * + * Fpllclock = = (Fclkin / NR) x NF / OD / R + * + * In this case, we have: + * + * Fclkin = 16,000,000 + * NR = 6 (REFCLKDIV=5) + * NF = 120 (PLLMUL = 119 * 256) + * OD = 1 (ODPLL = 0) + * R = 2 (PLLDIV=1) + * + * Then: + * + * Fintclk = 16 MHz / 6 = 2.667 MHz + * Foutputclock = 2.667 MHz * 135 = 360 MHz + * Fpostodclock = 320 MHz / 2 = 180 MHz + * Fpllclock = 160 MHz / 1 = 180 MHz + */ + +#define BOARD_PLL_NR 6 /* REFCLKDIV = 5 */ +#define BOARD_PLL_NF 135 /* PLLMUL = 119 * 256 */ +#define BOARD_PLL_OD 2 /* ODPLL = 1 */ +#define BOARD_PLL_R 1 /* PLLDIV = 1 */ +#define BOARD_PLL_FREQUENCY 180000000 + +/* Clock Sources / Dividers + * + * GCLK and HCLK are both driven by PLL1. + * VCLK is driven by HCLK (optionally by HCLK/2) + * RTICLK source is VCLK/2 (optionally from VCLK) + */ + +#define BOARD_VCLK_DIVIDER 2 +#define BOARD_VCLK2_DIVIDER 2 +#define BOARD_VCLK3_DIVIDER 2 +#define BOARD_RTICLK_DIVIDER 1 +#define BOARD_VCLK4_DIVIDER 1 + +/* Resulting frequencies: + * + * GCLK and HCLK are both driven by PLL1. + * VCLK is driven by HCLK (optionally by HCLK/2) + * RTICLK source is VCLK/2 (optionally from VCLK) + */ + +#define BOARD_GCLK_FREQUENCY BOARD_PLL_FREQUENCY +#define BOARD_HCLK_FREQUENCY BOARD_PLL_FREQUENCY +#define BOARD_VCLK_FREQUENCY BOARD_PLL_FREQUENCY/ BOARD_VCLK_DIVIDER +#define BOARD_VCLK2_FREQUENCY BOARD_PLL_FREQUENCY / BOARD_VCLK2_DIVIDER +#define BOARD_VCLK3_FREQUENCY BOARD_PLL_FREQUENCY / BOARD_VCLK3_DIVIDER +#define BOARD_VCLKA1_FREQUENCY BOARD_VCLK1_FREQUENCY +#define BOARD_VCLKA2_FREQUENCY BOARD_VCLK1_FREQUENCY +#define BOARD_RTICLK_FREQUENCY (BOARD_PLL_FREQUENCY / (1 << BOARD_RTICLK_DIVIDER )) +#define BOARD_VCLKA4_FREQUENCY BOARD_VCLK1_FREQUENCY / BOARD_VCLK4_DIVIDER + +/* FLASH wait states */ + +#define BOARD_ASWAIT 1 /* No address setup wait states */ +#define BOARD_RWAIT 3 /* One read access wait state */ +#define BOARD_EWAIT 3 /* Four wait states for EEPROM access */ + +/* PIN Multiplexor Initializer ******************************************************/ + +/* You may specify one alternative from each set (the first is the default and, + * hence, could probably be omitted): + * + * 1. {GIOA0, SPI3nCS3} + * 2. {GIOA1, SPI3nCS2} + * 3. {GIOA2, SPI3nCS1} + * 4. {GIOA3, SPI2nCS3} + * 5. {GIOA4, SPI2nCS2} + * 6. {GIOA5, EXTCLKIN} + * 7. {GIOA6, SPI2nCS1, N2HET31} + * 8. {GIOA7, N2HET29} + * 9. {MIBSPI1nCS2, N2HET20, N2HET19} + * 10. {SPI3CLK, EQEPA} + * 11. {SPI3nENA, EQEPB} + * 12. {SPI3nCS0, EQEPI}} + * 13. {MIBSPI1nCS3, N2HET26} + * 14. {ADEVT, N2HET28} + * 15. {MIBSPI1nENA, N2HET23, NHET30} + * 16. {MIBSPI1nCS1, EQEPS, N2HET17} + */ + +#define BOARD_PINMUX_INITIALIZER \ + PINMUX_GIOA0_PIN, \ + PINMUX_GIOA1_PIN, \ + PINMUX_GIOA2_PIN, \ + PINMUX_GIOA3_PIN, \ + PINMUX_GIOA4_PIN, \ + PINMUX_GIOA5_PIN, \ + PINMUX_GIOA6_PIN, \ + PINMUX_GIOA7_PIN, \ + PINMUX_MIBSPI1NCS2_PIN, \ + PINMUX_SPI3CLK_PIN, \ + PINMUX_SPI3NENA_PIN, \ + PINMUX_SPI3NCS0_PIN, \ + PINMUX_MIBSPI1NCS3_PIN, \ + PINMUX_ADEVT_PIN, \ + PINMUX_MIBSPI1NENA_PIN, \ + PINMUX_MIBSPI1NCS1_PIN + +/* LED definitions ******************************************************************/ +/* LEDs + * + * The launchpad has several LEDs: + * + * - LEd D1 (white) that connects to the USB +5V supply, + * - LED D10 (red) that connects to the TMS570's NERROR pin, + * - D5 (blue), D6 (blue), and D8 (blue) connect to the XDS100 FT2322, + * - D7 (blue) connects to the XSD100 CPLD, and + * - Two white, user LEDs labeled D12 that connects to the NHET08 + * pin and D11 that connects to GIOA2. + * + * NHET08 is one of 32 N2HET pins than can be available to the user if not used by + * N2HET. This implementation, however, uses only the single LED driven by GIOA2. + * That LED is tied to ground and illuminated with a high level output value. + */ + +/* LED index values for use with board_userled() */ + +#define BOARD_LED_D11 0 +#define BOARD_NLEDS 1 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED_D11_BIT (1 << BOARD_LED_D11) + +/* SPI1 Chip Select pin */ + +#define SPI1_SDCARD_CS PIN_HIGH | PIN_PULLUP | PIN_PUPD_DIS | PIN_OPEN_DRAIN_DIS | \ + PIN_DIR_OUTPUT | GIO_FUNC | SPI_PORT1 | SPI_GIO_CS1 + +/* Spi4 Chip Select pin */ + +#define SPI4_SDCARD_CS PIN_HIGH | PIN_PULLUP | PIN_PUPD_DIS | PIN_OPEN_DRAIN_DIS | \ + PIN_DIR_OUTPUT | GIO_FUNC | SPI_PORT4 | SPI_GIO_CS0 + +/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/sam_autoleds.c. The LEDs are used to encode + * OS-related events as follows: + * + * ---------------------- ---------------------------- ------ + * SYMBOL Meaning LED + * ---------------------- ---------------------------- ------ */ + +#define LED_STARTED 1 /* NuttX has been started OFF */ +#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF */ +#define LED_IRQSENABLED 0 /* Interrupts enabled OFF */ +#define LED_STACKCREATED 1 /* Idle stack created ON */ +#define LED_INIRQ 2 /* In an interrupt N/C */ +#define LED_SIGNAL 2 /* In a signal handler N/C */ +#define LED_ASSERTION 2 /* An assertion failed N/C */ +#define LED_PANIC 3 /* The system has crashed FLASH */ +#undef LED_IDLE /* MCU is is sleep mode Not used */ + +/* 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. + */ + +/* Button definitions ***************************************************************/ +/* Buttons + * + * The launchpad has three mechanical buttons. Two of these are reset buttons: One + * button is labeled PORRST performs a power-on reset and one labeled RST performs + * an MCU reset. Only one button is available for general software usage. That + * button is labeled GIOA7 and is, obviously, sensed on GIOA7. + * + * GIOA7 is tied to ground, but will be pulled high if the GIOA7 button is + * depressed. + */ + +#define BUTTON_GIOA7 0 +#define NUM_BUTTONS 1 + +#define BUTTON_GIOA7_BIT (1 << BUTTON_GIOA7) + +/************************************************************************************ + * Public Data + ************************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/************************************************************************************ + * Public Function Prototypes + ************************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __CONFIGS_LAUNCHXL_TMS57004_INCLUDE_BOARD_H */ diff --git a/configs/tms570ls31x-usb-kit/include/nsh_romfsimg.h b/configs/tms570ls31x-usb-kit/include/nsh_romfsimg.h new file mode 100644 index 0000000000..15e4e7a8d5 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/include/nsh_romfsimg.h @@ -0,0 +1,42 @@ +/**************************************************************************** + * + * Copyright (C) 2013 PX4 Development Team. All rights reserved. + * + * 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 PX4 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. + * + ****************************************************************************/ + +/** + * nsh_romfsetc.h + * + * This file is a stub for 'make export' purposes; the actual ROMFS + * must be supplied by the library client. + */ + +extern unsigned char romfs_img[]; +extern unsigned int romfs_img_len; diff --git a/configs/tms570ls31x-usb-kit/nsh/defconfig b/configs/tms570ls31x-usb-kit/nsh/defconfig new file mode 100644 index 0000000000..bbfefc30dd --- /dev/null +++ b/configs/tms570ls31x-usb-kit/nsh/defconfig @@ -0,0 +1,50 @@ +# CONFIG_ARCH_RAMFUNCS is not set +CONFIG_ARCH_BOARD_TMS570LS31X_USB_KIT=y +CONFIG_ARCH_BOARD="tms570ls31x-usb-kit" +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP_TMS570=y +CONFIG_ARCH_CHIP_TMS570LS3137ZWT=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQBUTTONS=y +CONFIG_ARCH_LOWVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH="arm" +CONFIG_BUILTIN=y +CONFIG_DISABLE_POLL=y +CONFIG_ELF=y +CONFIG_EXAMPLES_NSH=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_I2C=y +CONFIG_INTELHEX_BINARY=y +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=262143 +CONFIG_RAM_START=0x08000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SCI1_2STOP=1 +CONFIG_SCI1_BAUD=9600 +CONFIG_SCI1_SERIAL_CONSOLE=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_SPI=y +CONFIG_START_DAY=10 +CONFIG_START_MONTH=3 +CONFIG_START_YEAR=2014 +CONFIG_SYSTEM_RAMTEST=y +CONFIG_TMS570_GIO_IRQ=y +CONFIG_TMS570_SCI1=y +CONFIG_USER_ENTRYPOINT="nsh_main" diff --git a/configs/tms570ls31x-usb-kit/scripts/Make.defs b/configs/tms570ls31x-usb-kit/scripts/Make.defs new file mode 100644 index 0000000000..343fdb8991 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/scripts/Make.defs @@ -0,0 +1,137 @@ +############################################################################ +# configs/tms570ls31x-usb-kit/scripts/Make.defs +# +# Copyright (C) 2017 Ivan Ucherdzhiev. All rights reserved. +# Author: Ivan Ucherdzhiev +# +# 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}$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)armv7-r$(DELIM)Toolchain.defs + +LDSCRIPT = flash-sram.ld + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)$(DELIM)include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)$(DELIM)include}" -isystem "${shell cygpath -w $(TOPDIR)$(DELIM)include$(DELIM)cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + ARCHINCLUDES = -I. -isystem $(TOPDIR)$(DELIM)include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)$(DELIM)include -isystem $(TOPDIR)$(DELIM)include$(DELIM)cxx + ARCHSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)$(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 + +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 + +ARCHCPUFLAGS = -mcpu=cortex-r4f -march=armv7-r -mbig-endian -mfpu=vfpv3-d16 -mfloat-abi=hard +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +# NXFLAT module definitions + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# ELF module definitions + +CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs +CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs + +LDELFFLAGS = -r -e main +ifeq ($(WINTOOL),y) + LDELFFLAGS += -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld}" +else + LDELFFLAGS += -T $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld +endif + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) +ifneq ($(CROSSDEV),armeb-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = +ifeq ($(CONFIG_HOST_WINDOWS),y) + HOSTEXEEXT = .exe +else + HOSTEXEEXT = +endif + +ifeq ($(WINTOOL),y) + # Windows-native host tools + DIRLINK = $(TOPDIR)$(DELIM)tools$(DELIM)copydir.sh + DIRUNLINK = $(TOPDIR)$(DELIM)tools$(DELIM)unlink.sh + MKDEP = $(TOPDIR)$(DELIM)tools$(DELIM)mkwindeps.sh +else + # Linux/Cygwin-native host tools + MKDEP = $(TOPDIR)$(DELIM)tools$(DELIM)mkdeps$(HOSTEXEEXT) +endif diff --git a/configs/tms570ls31x-usb-kit/scripts/flash-sram.ld b/configs/tms570ls31x-usb-kit/scripts/flash-sram.ld new file mode 100644 index 0000000000..cb835614c1 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/scripts/flash-sram.ld @@ -0,0 +1,125 @@ +/**************************************************************************** + * configs/tms570ls31x-usb-kit/scripts/flash-sram.ld + * + * Copyright (C) 2017 Ivan Ucherdzhiev. All rights reserved. + * Author: Ivan Ucherdzhiev + * + * 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 TMS570LS3137ZWT has 3MB of FLASH beginning at address 0x0000:0000 and + * 256Kb of SRAM beginning at 0x0800:0000 + */ + +/* Specify the memory areas */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x00000000, LENGTH = (0x0017FFE0 + 0x00180000 + 0x00000020 ) + sram (rwx) : ORIGIN = 0x08000000, LENGTH = (0x0003EB00 + 0x00001500) +} + +OUTPUT_ARCH(arm) +OUTPUT_FORMAT(elf32-bigarm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .init_section : + { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : + { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : + { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > sram AT > flash + + .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) } +} diff --git a/configs/tms570ls31x-usb-kit/src/Makefile b/configs/tms570ls31x-usb-kit/src/Makefile new file mode 100644 index 0000000000..69b4a42d57 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/Makefile @@ -0,0 +1,59 @@ +############################################################################ +# configs/launchxl-tms57004/src/Makefile +# +# 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +ASRCS = +CSRCS = tms570_initialize.c tms570_bringup.c tms570_spi.c + +ifeq ($(CONFIG_LIB_BOARDCTL),y) + CSRCS += tms570_appinit.c +endif + +ifeq ($(CONFIG_ARCH_LEDS),y) + CSRCS += tms570_autoleds.c +else + CSRCS += tms570_userleds.c +endif + +ifeq ($(CONFIG_ARCH_BUTTONS),y) + CSRCS += tms570_buttons.c +endif + +ifeq ($(CONFIG_MMCSD),y) + CSRCS += tms570_sdmmc.c +endif + +include $(TOPDIR)/configs/Board.mk diff --git a/configs/tms570ls31x-usb-kit/src/tms570_appinit.c b/configs/tms570ls31x-usb-kit/src/tms570_appinit.c new file mode 100644 index 0000000000..8cc3d08ef8 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/tms570_appinit.c @@ -0,0 +1,85 @@ +/**************************************************************************** + * configs/launchxl_tms57004/src/sim_appinit.c + * + * Copyright (C) 2018 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "tms570ls31x_usb_kit.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform architecture specific initialization + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value cold be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_LIB_BOARDCTL +int board_app_initialize(uintptr_t arg) +{ +#ifndef CONFIG_BOARD_INITIALIZE + /* Perform application level board initialization (if that was not already + * done in board_initialize(). + */ + + tms570_bringup(); +#endif + + return 0; +} +#endif /* CONFIG_LIB_BOARDCTL */ diff --git a/configs/tms570ls31x-usb-kit/src/tms570_autoleds.c b/configs/tms570ls31x-usb-kit/src/tms570_autoleds.c new file mode 100644 index 0000000000..06eb1ed689 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/tms570_autoleds.c @@ -0,0 +1,127 @@ +/**************************************************************************** + * configs/launchxl-tms57004/include/tms570_autoleds.c + * + * Copyright (C) 2018 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. + * + ****************************************************************************/ + +/* LEDs + * + * The launchpad has several LEDs: + * + * - LEd D1 (white) that connects to the USB +5V supply, + * - LED D10 (red) that connects to the TMS570's NERROR pin, + * - D5 (blue), D6 (blue), and D8 (blue) connect to the XDS100 FT2322, + * - D7 (blue) connects to the XSD100 CPLD, and + * - Two white, user LEDs labeled D12 that connects to the NHET08 + * pin and D11 that connects to GIOA2. + * + * NHET08 is one of 32 N2HET pins than can be available to the user if + * not used by N2HET. This implementation, however, uses only the single + * LED driven by GIOA2. That LED is tied to ground and illuminated + * with a high level output value. + * + * This LED is not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/tms570_autoleds.c. The LED is used to encode + * OS-related events as follows: + * + * ------------------- ----------------------- ------ + * SYMBOL Meaning LED + * ------------------- ----------------------- ------ + * LED_STARTED NuttX has been started OFF + * LED_HEAPALLOCATE Heap has been allocated OFF + * LED_IRQSENABLED Interrupts enabled OFF + * LED_STACKCREATED Idle stack created ON + * LED_INIRQ In an interrupt N/C + * LED_SIGNAL In a signal handler N/C + * LED_ASSERTION An assertion failed N/C + * LED_PANIC The system has crashed FLASH + * + * Thus if the LED is statically on, NuttX has successfully booted and is, + * apparently, running normally. If the LED is flashing at approximately + * 2Hz, then a fatal error has been detected and the system has halted. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "tms570_gio.h" +#include "tms570ls31x_usb_kit.h" + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + /* Configure LED GIOs for output */ + + tms570_configgio(GIO_LED_D11); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + if (led == 1 || led == 3) + { + tms570_giowrite(GIO_LED_D11, true); /* High illuminates */ + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + if (led == 3) + { + tms570_giowrite(GIO_LED_D11, false); /* Low extinguishes */ + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/configs/tms570ls31x-usb-kit/src/tms570_bringup.c b/configs/tms570ls31x-usb-kit/src/tms570_bringup.c new file mode 100644 index 0000000000..6a1b5b6ba8 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/tms570_bringup.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * configs/launchxl-tms57004/src/tms570_bringup.c + * + * Copyright (C) 2018 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + + #include + + #include + #include + #include + #include + #include + #include + + #include +#include "tms570ls31x_usb_kit.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + + /* Checking needed by MMC/SDCard */ + + #ifdef CONFIG_NSH_MMCSDMINOR + # define MMCSD_MINOR CONFIG_NSH_MMCSDMINOR + #else + # define MMCSD_MINOR 0 + #endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tms570_bringup + * + * Description: + * Bring up simulated board features + * + ****************************************************************************/ + +int tms570_bringup(void) +{ + int ret = OK; + +#ifdef CONFIG_MMCSD + tms570_spidev_initialize(); + ret = tms570_mmcsd_initialize(MMCSD_MINOR); + if (ret < 0) + { + serr( "Failed to initialize SD slot %d: %d\n", ret); + return ret; + } +#endif + + UNUSED(ret); + return OK; +} diff --git a/configs/tms570ls31x-usb-kit/src/tms570_buttons.c b/configs/tms570ls31x-usb-kit/src/tms570_buttons.c new file mode 100644 index 0000000000..bc9b2acc51 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/tms570_buttons.c @@ -0,0 +1,197 @@ +/**************************************************************************** + * configs/sam4e-ek/src/tms570_buttons.c + * + * Copyright (C) 2018 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include "up_arch.h" +#include "tms570_gio.h" +#include "tms570ls31x_usb_kit.h" + +#ifdef CONFIG_ARCH_BUTTONS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#undef HAVE_IRQBUTTONS +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_TMS570_GIO_IRQ) +# define HAVE_IRQBUTTONS 1 +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef HAVE_IRQBUTTONS +static xcpt_t g_irq_button; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_button_irqx + * + * Description: + * This function implements the core of the board_button_irq() logic. + * + ****************************************************************************/ + +#ifdef HAVE_IRQBUTTONS +static int board_button_irqx(gio_pinset_t pinset, int irq, + xcpt_t irqhandler, xcpt_t *store, void *arg) +{ + irqstate_t flags; + + /* Disable interrupts until we are done. This guarantees that the following + * operations are atomic. + */ + + flags = enter_critical_section(); + + /* Get the old button interrupt handler and save the new one */ + + *store = irqhandler; + + /* Are we attaching or detaching? */ + + if (irqhandler != NULL) + { + /* Configure the interrupt */ + + tms570_gioirq(pinset); + (void)irq_attach(irq, irqhandler, arg); + tms570_gioirqenable(irq); + } + else + { + /* Detach and disable the interrupt */ + + (void)irq_detach(irq); + tms570_gioirqdisable(irq); + } + + leave_critical_section(flags); + + /* Return the old button handler (so that it can be restored) */ + + return OK; +} +#endif + +/**************************************************************************** + * 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) +{ + /* Configure button GIOs */ + + (void)tms570_configgio(GIO_BUTTON); +} + +/**************************************************************************** + * 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 + * 32-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. + * + ****************************************************************************/ + +uint32_t board_buttons(void) +{ + return tms570_gioread(GIO_BUTTON) ? BUTTON_GIOA7_BIT : 0; +} + +/**************************************************************************** + * 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. + * + * Configuration Notes: + * Configuration CONFIG_AVR32_GIOIRQ must be selected to enable the + * overall GIO IRQ feature and CONFIG_AVR32_GIOIRQSETA and/or + * CONFIG_AVR32_GIOIRQSETB must be enabled to select GIOs to support + * interrupts on. For button support, bits 2 and 3 must be set in + * CONFIG_AVR32_GIOIRQSETB (PB2 and PB3). + * + ****************************************************************************/ + +int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +{ +#ifdef HAVE_IRQBUTTONS + if (id == BUTTON_GIOA7) + { + return board_button_irqx(GIO_BUTTON, IRQ_BUTTON, irqhandler, + &g_irq_button, arg); + } +#endif + + return -EINVAL; +} + +#endif /* CONFIG_ARCH_BUTTONS */ diff --git a/configs/tms570ls31x-usb-kit/src/tms570_initialize.c b/configs/tms570ls31x-usb-kit/src/tms570_initialize.c new file mode 100644 index 0000000000..7866ae1166 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/tms570_initialize.c @@ -0,0 +1,128 @@ +/**************************************************************************** + * config/launchxl-tms57004/src/moxart_boot.c + * + * Copyright (C) 2018 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#include "tms570ls31x_usb_kit.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tms570_boardinitialize + * + * Description: + * All TMS570 architectures must provide the following entry point. This + * function is called near the beginning of _start. This function is + * called after clocking has been configured but before caches have been + * enabled and before any devices have been initialized. .data/.bss + * memory may or may not have been initialized (see the "special + * precautions" below). + * + * This function must perform low level initialization including + * + * - Initialization of board-specific memory resources (e.g., SDRAM) + * - Configuration of board specific resources (GPIOs, LEDs, etc). + * - Setup of the console UART. This UART done early so that the serial + * console is available for debugging very early in the boot sequence. + * + * Special precautions must be taken if .data/.bss lie in SRAM. in that + * case, the boot logic cannot initialize .data or .bss. The function + * must then: + * + * - Take precautions to assume that logic does not access any global + * data that might lie in SDRAM. + * - Call the function arm_data_initialize() as soon as SDRAM has been + * properly configured for use. + * + ****************************************************************************/ + +void tms570_board_initialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif + +#if 0 + putreg32(0x01000001, 0xfff7b800 + 0); + + /* - PULL functinality is enabled */ + + putreg32(0x00000000, 0xfff7b800 + 0x64); + + /* - This if statement is a placeholder for ArgoBoard/USBStick check */ + /* - Configure NHET pins as output */ + + putreg32(0xaa178035, 0xfff7b800 + 0x004c); + /* - Turn all LEDs off */ + + putreg32(0x08110034, 0xfff7b800 + 0x0054); + + /* - Set only NHET[25,0] */ + + putreg32(0x0a110035, 0xfff7b800 + 0x0054); +#endif +} + +/**************************************************************************** + * Name: board_initialize + * + * Description: + * If CONFIG_BOARD_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_initialize(). board_initialize() will be + * called immediately after up_initialize() is called and just before the + * initial application is started. This additional initialization phase + * may be used, for example, to initialize board-specific device drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_INITIALIZE +void board_initialize(void) +{ + /* Perform application level board initialization */ + + tms570_bringup(); +} +#endif diff --git a/configs/tms570ls31x-usb-kit/src/tms570_sdmmc.c b/configs/tms570ls31x-usb-kit/src/tms570_sdmmc.c new file mode 100644 index 0000000000..9cae616dcc --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/tms570_sdmmc.c @@ -0,0 +1,128 @@ +/***************************************************************************** + * configs/tms570f103-minimum/src/tms570_mmcsd.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Alan Carvalho de Assis + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tms570ls31x_usb_kit.h" +#include "tms570_spi.h" + +/***************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef CONFIG_TMS570_SPI1 +# error "SD driver requires CONFIG_STM32_SPI1 to be enabled" +#endif + +#ifdef CONFIG_DISABLE_MOUNTPOINT +# error "SD driver requires CONFIG_DISABLE_MOUNTPOINT to be disabled" +#endif + +/***************************************************************************** + * Private Definitions + ****************************************************************************/ + +static const int SD_SPI_PORT = CONFIG_NSH_MMCSDSPIPORTNO; /* SD is connected to SPI1 port */ +static const int SD_SLOT_NO = 0; /* There is only one SD slot */ + +/***************************************************************************** + * Private Functions + ****************************************************************************/ + +/* NOTE: We are using a SDCard adapter/module without Card Detect pin! + * Then we don't need to Card Detect callback here. + */ + +/***************************************************************************** + * Public Functions + ****************************************************************************/ + +/***************************************************************************** + * Name: tms570_spi1register + * + * Description: + * Registers media change callback + ****************************************************************************/ + +int tms570_spi1register(struct spi_dev_s *dev, spi_mediachange_t callback, + void *arg) +{ + spiinfo("INFO: Registering spi1 device\n"); + return OK; +} + +/***************************************************************************** + * Name: tms570_mmcsd_initialize + * + * Description: + * Initialize SPI-based SD card and card detect thread. + ****************************************************************************/ + +int tms570_mmcsd_initialize(int minor) +{ + struct spi_dev_s *spi; + int rv; + + mcinfo("INFO: Initializing mmcsd card\n"); + + spi = tms570_spibus_initialize(SD_SPI_PORT); + if (spi == NULL) + { + mcerr("ERROR: Failed to initialize SPI port %d\n", SD_SPI_PORT); + return -ENODEV; + } + + rv = mmcsd_spislotinitialize(minor, SD_SLOT_NO, spi); + if (rv < 0) + { + mcerr("ERROR: Failed to bind SPI port %d to SD slot %d\n", + SD_SPI_PORT, SD_SLOT_NO); + return rv; + } + + spiinfo("INFO: mmcsd card has been initialized successfully\n"); + return OK; +} diff --git a/configs/tms570ls31x-usb-kit/src/tms570_spi.c b/configs/tms570ls31x-usb-kit/src/tms570_spi.c new file mode 100644 index 0000000000..e884be31c9 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/tms570_spi.c @@ -0,0 +1,160 @@ +/************************************************************************************ + * configs/tms570f103-minimum/src/tms570_spi.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * Laurent Latil + * + * 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 + +#include +#include +#include + +#include +#include + +#include "up_arch.h" +#include "chip.h" +#include "tms570_spi.h" +#include "tms570ls31x_usb_kit.h" + +#if defined(CONFIG_TMS570_SPI1) || defined(CONFIG_TMS570_SPI4) + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: tms570_spidev_initialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the HY-MiniTMS570 board. + * + ************************************************************************************/ + +void tms570_spidev_initialize(void) +{ +#ifdef CONFIG_MMCSD_SPI +#if defined (CONFIG_TMS570_SPI1) + tms570_spi_gio_config(SPI1_SDCARD_CS); /* SD/MMC Card chip select */ +#endif +#if defined (CONFIG_TMS570_SPI4) + tms570_spi_gio_config(SPI4_SDCARD_CS); +#endif +#endif +} + +/**************************************************************************** + * Name: tms570_spi1/2select and tms570_spi1/2status + * + * Description: + * The external functions, tms570_spi1/2/3select and tms570_spi1/2/3status must be + * provided by board-specific logic. They are implementations of the select + * and status methods of the SPI interface defined by struct spi_ops_s (see + * include/nuttx/spi/spi.h). All other methods (including tms570_spibus_initialize()) + * are provided by common TMS570 logic. To use this common SPI logic on your + * board: + * + * 1. Provide logic in tms570_boardinitialize() to configure SPI chip select + * pins. + * 2. Provide tms570_spi1/2/3select() and tms570_spi1/2/3status() functions in your + * board-specific logic. These functions will perform chip selection and + * status operations using GPIOs in the way your board is configured. + * 3. Add a calls to tms570_spibus_initialize() in your low level application + * initialization logic + * 4. The handle returned by tms570_spibus_initialize() may then be used to bind the + * SPI driver to higher level logic (e.g., calling + * mmcsd_spislotinitialize(), for example, will bind the SPI driver to + * the SPI MMC/SD driver). + * + ****************************************************************************/ + +#ifdef CONFIG_TMS570_SPI1 +void tms570_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ +#ifdef CONFIG_MMCSD_SPI + if (devid == SPIDEV_MMCSD(0)) + { + tms570_spi_giowrite(SPI1_SDCARD_CS, !selected); + } +#endif +} + +uint8_t tms570_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t status = 0; + +#ifdef CONFIG_MMCSD_SPI + if (devid == SPIDEV_MMCSD(0)) + { + status |= SPI_STATUS_PRESENT; + } +#endif + + return status; +} +#endif + +#ifdef CONFIG_TMS570_SPI4 +void tms570_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ +#ifdef CONFIG_MMCSD_SPI + if (devid == SPIDEV_MMCSD(0)) + { + tms570_spi_giowrite(SPI4_SDCARD_CS, !selected); + } +#endif +} + +uint8_t tms570_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t status = 0; + +#ifdef CONFIG_MMCSD_SPI + if (devid == SPIDEV_MMCSD(0)) + { + status |= SPI_STATUS_PRESENT; + } +#endif + + return status; +} +#endif + +#endif /* CONFIG_TMS570_SPI1 || CONFIG_TMS570_SPI2 */ diff --git a/configs/tms570ls31x-usb-kit/src/tms570_userleds.c b/configs/tms570ls31x-usb-kit/src/tms570_userleds.c new file mode 100644 index 0000000000..d53b298173 --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/tms570_userleds.c @@ -0,0 +1,104 @@ +/**************************************************************************** + * configs/launchxl-tms57004/src/tms570_userleds.c + * + * Copyright (C) 2018 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. + * + ****************************************************************************/ + +/* LEDs + * + * The launchpad has several LEDs: + * + * - LEd D1 (white) that connects to the USB +5V supply, + * - LED D10 (red) that connects to the TMS570's NERROR pin, + * - D5 (blue), D6 (blue), and D8 (blue) connect to the XDS100 FT2322, + * - D7 (blue) connects to the XSD100 CPLD, and + * - Two white, user LEDs labeled D12 that connects to the NHET08 + * pin and D11 that connects to GIOA2. + * + * NHET08 is one of 32 N2HET pins than can be available to the user if + * not used by N2HET. This implementation, however, uses only the single + * LED driven by GIOA2. That LED is tied to ground and illuminated + * with a high level output value. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include "tms570_gio.h" +#include "tms570ls31x_usb_kit.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +void board_userled_initialize(void) +{ + /* Configure LED PIOs for output */ + + tms570_configgio(GIO_LED_D11); +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if (led == BOARD_LED_D11) + { + tms570_giowrite(GIO_LED_D11, !ledon); /* Low illuminates */ + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint8_t ledset) +{ + /* Low illuminates */ + + tms570_giowrite(GIO_LED_D11, (ledset & BOARD_LED_D11_BIT) == 0)); +} diff --git a/configs/tms570ls31x-usb-kit/src/tms570ls31x_usb_kit.h b/configs/tms570ls31x-usb-kit/src/tms570ls31x_usb_kit.h new file mode 100644 index 0000000000..40d879a94e --- /dev/null +++ b/configs/tms570ls31x-usb-kit/src/tms570ls31x_usb_kit.h @@ -0,0 +1,110 @@ +/**************************************************************************** + * config/tms570ls31x-usb-kit/src/tms570ls31x_usb_kit.h + * + * Copyright (C) 2018 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_LAUNCHXL_TMS57004_SRC_LAUNCHXL_TMS57004_H +#define __CONFIGS_LAUNCHXL_TMS57004_SRC_LAUNCHXL_TMS57004_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LEDs + * + * The launchpad has several LEDs: + * + * - LEd D1 (white) that connects to the USB +5V supply, + * - LED D10 (red) that connects to the TMS570's NERROR pin, + * - D5 (blue), D6 (blue), and D8 (blue) connect to the XDS100 FT2322, + * - D7 (blue) connects to the XSD100 CPLD, and + * - Two white, user LEDs labeled D12 that connects to the NHET08 + * pin and D11 that connects to GIOA2. + * + * NHET08 is one of 32 N2HET pins than can be available to the user if not + * used by N2HET. This implementation, however, uses only the single LED + * driven by GIOA2. That LED is tied to ground and illuminated with a high + * level output value. + */ + +#define GIO_LED_D11 (GIO_OUTPUT | GIO_CFG_DEFAULT | GIO_OUTPUT_CLEAR | \ + GIO_PORT_GIOA | GIO_PIN1) + +/* Buttons + * + * The launchpad has three mechanical buttons. Two of these are reset + * buttons: One button is labeled PORRST performs a power-on reset and one + * labeled RST performs an MCU reset. Only one button is available for + * general software usage. That button is labeled GIOA7 and is, obviously, + * sensed on GIOA7. + * + * GIOA7 is tied to ground, but will be pulled high if the GIOA7 button is + * depressed. + */ + +#define GIO_BUTTON (GIO_INPUT | GIO_CFG_PULLUP | GIO_INT_BOTHEDGES | \ + GIO_PORT_GIOA | GIO_PIN7) +#define IRQ_BUTTON TMS570_IRQ_GIOA7 + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: tms570_bringup + * + * Description: + * Bring up simulated board features + * + ****************************************************************************/ + +int tms570_bringup(void); + +/***************************************************************************** + * Name: tms570_mmcsd_initialize + * + * Description: + * Initialize SPI-based SD card and card detect thread. + ****************************************************************************/ + +#ifdef CONFIG_MMCSD +int tms570_mmcsd_initialize(int minor); +#endif + +#endif /* __CONFIGS_LAUNCHXL_TMS57004_SRC_LAUNCHXL_TMS57004_H */