diff --git a/configs/lpc4370-link2/README.txt b/configs/lpc4370-link2/README.txt index ea3e63ee89a..70c35ced913 100644 --- a/configs/lpc4370-link2/README.txt +++ b/configs/lpc4370-link2/README.txt @@ -51,7 +51,7 @@ LPC4370-Link2 board Console ------- - The LPC4370-Link2 default console is the USART0. + The LPC4370-Link2 default console is the USART2. Status ====== diff --git a/configs/lpc4370-link2/include/board.h b/configs/lpc4370-link2/include/board.h index b094ad7ec3b..cc01c5ca98f 100644 --- a/configs/lpc4370-link2/include/board.h +++ b/configs/lpc4370-link2/include/board.h @@ -1,5 +1,40 @@ -#ifndef __ARCH_BOARD_BOARD_H -#define __ARCH_BOARD_BOARD_H +/**************************************************************************** + * configs/lpc4357-evb/include/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_LPC4357_EVB_INCLUDE_BOARD_H +#define __CONFIGS_LPC4357_EVB_INCLUDE_BOARD_H /**************************************************************************** * Included Files @@ -106,32 +141,30 @@ #endif - - #define LPC43_CCLK BOARD_FCLKOUT_FREQUENCY #if defined(CONFIG_LPC43_BUS) || defined(CONFIG_LPC43_MCPWM) || defined(CONFIG_LPC43_I2C0) || defined(CONFIG_LPC43_I2S0) || defined(CONFIG_LPC43_I2S1) || defined(CONFIG_LPC43_CAN1) -#define BOARD_ABP1_CLKSRC BASE_APB1_CLKSEL_XTAL -#define BOARD_ABP1_FREQUENCY BOARD_XTAL_FREQUENCY +# define BOARD_ABP1_CLKSRC BASE_APB_CLKSEL_XTAL +# define BOARD_ABP1_FREQUENCY BOARD_XTAL_FREQUENCY #endif #if defined(CONFIG_LPC43_BUS) || defined(CONFIG_LPC43_I2C1) || defined(CONFIG_LPC43_DAC) || defined(CONFIG_LPC43_ADC0) || defined(CONFIG_LPC43_ADC1) || defined(CONFIG_LPC43_CAN0) -#define BOARD_ABP3_CLKSRC BASE_APB3_CLKSEL_XTAL -#define BOARD_ABP3_FREQUENCY BOARD_XTAL_FREQUENCY +# define BOARD_ABP3_CLKSRC BASE_APB_CLKSEL_XTAL +# define BOARD_ABP3_FREQUENCY BOARD_XTAL_FREQUENCY #endif -#define BOARD_IDIVA_DIVIDER (2) +#define BOARD_IDIVA_DIVIDER (2) #define BOARD_IDIVA_CLKSRC IDIVA_CLKSEL_PLL1 -#define BOARD_IDIVA_FREQUENCY (BOARD_FCLKOUT_FREQUENCY/BOARD_IDIVA_DIVIDER) +#define BOARD_IDIVA_FREQUENCY (BOARD_FCLKOUT_FREQUENCY/BOARD_IDIVA_DIVIDER) /* USB0 ********************************************************************/ /* Settings needed in lpc43_cpu.c */ -#define BOARD_USB0_CLKSRC PLL0USB_CLKSEL_XTAL +#define BOARD_USB0_CLKSRC PLL0USB_CLKSEL_XTAL #define BOARD_USB0_MDIV 0x06167ffa /* Table 149 datsheet, valid for 12Mhz Fclkin */ #define BOARD_USB0_NP_DIV 0x00302062 /* Table 149 datsheet, valid for 12Mhz Fclkin */ @@ -167,6 +200,27 @@ # define BOARD_SPIFI_FREQUENCY (102000000) /* 204MHz / 14 = 14.57MHz */ #endif +#if CONFIG_SPIFI_LIBRARY +# define SPIFI_DEVICE_ALL 0 /**< Enables all devices in family */ +# define SPIFI_DEVICE_S25FL016K 0 /**< Enables Spansion S25FL016K device */ +# define SPIFI_DEVICE_S25FL032P 0 /**< Enables Spansion S25FL032P device */ +# define SPIFI_DEVICE_S25FL064P 0 /**< Enables Spansion S25FL064P device */ +# define SPIFI_DEVICE_S25FL129P_64K 0 /**< Enables Spansion S25FL129P (64K block) device */ +# define SPIFI_DEVICE_S25FL129P_256K 0 /**< Enables Spansion S25FL129P (256K block) device */ +# define SPIFI_DEVICE_S25FL164K 0 /**< Enables Spansion S25FL164K device */ +# define SPIFI_DEVICE_S25FL256S_64K 0 /**< Enables Spansion S25FL256S (64K block) device */ +# define SPIFI_DEVICE_S25FL256S_256K 0 /**< Enables Spansion S25FL256S (256K block) device */ +# define SPIFI_DEVICE_S25FL512S 0 /**< Enables Spansion S25FL512S device */ +# define SPIFI_DEVICE_MX25L1635E 0 /**< Enables Macronix MX25L1635E device */ +# define SPIFI_DEVICE_MX25L3235E 0 /**< Enables Macronix MX25L3235E device */ +# define SPIFI_DEVICE_MX25L8035E 0 /**< Enables Macronix MX25L8035E device */ +# define SPIFI_DEVICE_MX25L6435E 0 /**< Enables Macronix MX25L6435E device */ +# define SPIFI_DEVICE_W25Q32FV 0 /**< Enables Winbond W25Q32FV device */ +# define SPIFI_DEVICE_W25Q64FV 0 /**< Enables Winbond W25Q32V device */ +# define SPIFI_DEVICE_W25Q80BV 1 /**< Enables Winbond W25Q80BV device */ +# define SPIFI_DEVICE_REQUENCY_DIVIDER 2 /* PLL1 clock divider */ +#endif + /* UART clocking ***********************************************************/ /* Configure all U[S]ARTs to use the XTAL input frequency */ @@ -193,29 +247,24 @@ * */ +#define BOARD_SSP0_CLKSRC BASE_SSP0_CLKSEL_IDIVA +#define BOARD_SSP0_BASEFREQ BOARD_IDIVA_FREQUENCY -#define BOARD_SSP0_CLKSRC BASE_SSP0_CLKSEL_IDIVA -#define BOARD_SSP0_BASEFREQ BOARD_IDIVA_FREQUENCY - -#define BOARD_SSP1_CLKSRC BASE_SSP1_CLKSEL_IDIVA -#define BOARD_SSP1_BASEFREQ BOARD_IDIVA_FREQUENCY - - +#define BOARD_SSP1_CLKSRC BASE_SSP1_CLKSEL_IDIVA +#define BOARD_SSP1_BASEFREQ BOARD_IDIVA_FREQUENCY /* LED definitions *********************************************************/ - -/* - * LED1 K2 GPIO0[8] +/* LED1 K2 GPIO0[8] * * LED index values for use with board_userled() */ -#define BOARD_LED 0 -#define BOARD_NLEDS 1 +#define BOARD_LED 0 +#define BOARD_NLEDS 1 /* LED bits for use with board_userled_all() */ -#define BOARD_LED_BIT (1 << BOARD_LED) +#define BOARD_LED_BIT (1 << BOARD_LED) /* If CONFIG_ARCH_LEDS is defined, the LEDs will be controlled as follows * for NuttX debug functionality (where NC means "No Change"). If @@ -227,15 +276,15 @@ * void board_userled(int led, bool ledon); * void board_userled_all(uint8_t ledset); */ - /* LED */ -#define LED_STARTED 0 /* OFF */ -#define LED_HEAPALLOCATE 0 /* OFF */ -#define LED_IRQSENABLED 0 /* OFF */ -#define LED_STACKCREATED 1 /* ON */ -#define LED_INIRQ 2 /* NC */ -#define LED_SIGNAL 2 /* NC */ -#define LED_ASSERTION 2 /* NC */ -#define LED_PANIC 3 /* Flashing */ + /* LED */ +#define LED_STARTED 0 /* OFF */ +#define LED_HEAPALLOCATE 0 /* OFF */ +#define LED_IRQSENABLED 0 /* OFF */ +#define LED_STACKCREATED 1 /* ON */ +#define LED_INIRQ 2 /* NC */ +#define LED_SIGNAL 2 /* NC */ +#define LED_ASSERTION 2 /* NC */ +#define LED_PANIC 3 /* Flashing */ /* UART Pins ****************************************************************/ /* @@ -244,31 +293,32 @@ * file arch/arc/src/lpc43xx/lpc43*_pinconf.h for more info). */ -#define PINCONF_U0_TXD PINCONF_U0_TXD_3 -#define PINCONF_U0_RXD PINCONF_U0_RXD_3 -#define PINCONF_U0_DIR PINCONF_U0_DIR_3 +#define PINCONF_U0_TXD PINCONF_U0_TXD_3 +#define PINCONF_U0_RXD PINCONF_U0_RXD_3 +#define PINCONF_U0_DIR PINCONF_U0_DIR_3 -#define PINCONF_U1_TXD PINCONF_U1_TXD_1 -#define PINCONF_U1_RXD PINCONF_U1_RXD_1 +#define PINCONF_U1_TXD PINCONF_U1_TXD_1 +#define PINCONF_U1_RXD PINCONF_U1_RXD_1 -#define PINCONF_U2_TXD PINCONF_U2_TXD_2 -#define PINCONF_U2_RXD PINCONF_U2_RXD_2 -#define PINCONF_U2_DIR PINCONF_U2_DIR_2 +#define PINCONF_U2_TXD PINCONF_U2_TXD_2 +#define PINCONF_U2_RXD PINCONF_U2_RXD_2 +#define PINCONF_U2_DIR PINCONF_U2_DIR_2 -#define PINCONF_U3_TXD PINCONF_U3_TXD_2 -#define PINCONF_U3_RXD PINCONF_U3_RXD_2 -#define PINCONF_U3_DIR PINCONF_U3_DIR_2 +#define PINCONF_U3_TXD PINCONF_U3_TXD_2 +#define PINCONF_U3_RXD PINCONF_U3_RXD_2 +#define PINCONF_U3_DIR PINCONF_U3_DIR_2 -//I2C1 pins, not really accessible on the board -#define PINCONF_I2C1_SCL PINCONF_I2C1_SCL_1 -#define PINCONF_I2C1_SDA PINCONF_I2C1_SDA_1 +/* I2C1 pins, not really accessible on the board */ -//SSP1 pins -#define PINCONF_SSP1_MISO PINCONF_SSP1_MISO_3 -#define PINCONF_SSP1_MOSI PINCONF_SSP1_MOSI_3 -#define PINCONF_SSP1_SCK PINCONF_SSP1_SCK_1 -#define PINCONF_SSP1_SSEL PINCONF_SSP1_SSEL_1 +#define PINCONF_I2C1_SCL PINCONF_I2C1_SCL_1 +#define PINCONF_I2C1_SDA PINCONF_I2C1_SDA_1 +/* SSP1 pins */ + +#define PINCONF_SSP1_MISO PINCONF_SSP1_MISO_3 +#define PINCONF_SSP1_MOSI PINCONF_SSP1_MOSI_3 +#define PINCONF_SSP1_SCK PINCONF_SSP1_SCK_1 +#define PINCONF_SSP1_SSEL PINCONF_SSP1_SSEL_1 /**************************************************************************** * Public Types @@ -297,9 +347,10 @@ extern "C" * Name: lpc43_boardinitialize * * Description: - * All LPC43xx architectures must provide the following entry point. This entry point - * is called early in the intitialization -- after all memory has been configured - * and mapped but before any devices have been initialized. + * All LPC43xx architectures must provide the following entry point. This + * entry point is called early in the intitialization -- after all memory + * has been configured and mapped but before any devices have been + * initialized. * ****************************************************************************/ @@ -311,4 +362,4 @@ void lpc43_boardinitialize(void); #endif #endif /* __ASSEMBLY__ */ -#endif /* __ARCH_BOARD_BOARD_H */ +#endif /* __CONFIGS_LPC4357_EVB_INCLUDE_BOARD_H */ diff --git a/configs/lpc4370-link2/scripts/flash.bat b/configs/lpc4370-link2/scripts/flash.bat index e8055218f25..7a269a21753 100644 --- a/configs/lpc4370-link2/scripts/flash.bat +++ b/configs/lpc4370-link2/scripts/flash.bat @@ -2,6 +2,8 @@ set LPCScrypt=C:\NXP\LPCScrypt\bin call %LPCScrypt%\..\scripts\boot_lpcscrypt.cmd +TIMEOUT /T 5 + %LPCScrypt%\lpcscrypt.exe erase SPIFI %LPCScrypt%\lpcscrypt.exe program ..\..\..\nuttx.bin SPIFI \ No newline at end of file diff --git a/configs/lpc4370-link2/scripts/spificonfig.ld b/configs/lpc4370-link2/scripts/spificonfig.ld index 9cdbb2ba4fa..d0f420c0e8c 100644 --- a/configs/lpc4370-link2/scripts/spificonfig.ld +++ b/configs/lpc4370-link2/scripts/spificonfig.ld @@ -84,10 +84,10 @@ SECTIONS .text : { _stext = ABSOLUTE(.); *(.vectors) - *(.text .text.*) + *(EXCLUDE_FILE (*spifilib*) .text .text.*) *(.fixup) *(.gnu.warning) - *(.rodata .rodata.*) + *(EXCLUDE_FILE (*spifilib*) .rodata .rodata.*) *(.gnu.linkonce.t.*) *(.glue_7) *(.glue_7t) @@ -117,6 +117,8 @@ SECTIONS .data : { _sdata = ABSOLUTE(.); + *spifilib*(.text .text.*) + *spifilib*( .rodata .rodata.*) *(.data .data.*) *(.gnu.linkonce.d.*) CONSTRUCTORS @@ -130,7 +132,8 @@ SECTIONS *(COMMON) _ebss = ABSOLUTE(.); } > datamem - /* Stabs debugging sections. */ + + /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } diff --git a/configs/lpc4370-link2/src/Makefile b/configs/lpc4370-link2/src/Makefile index 1a99c0e15a8..1527be7734b 100644 --- a/configs/lpc4370-link2/src/Makefile +++ b/configs/lpc4370-link2/src/Makefile @@ -56,22 +56,12 @@ ifeq ($(CONFIG_USBMSC),y) CSRCS += lpc43_usbmsc.c endif +ifeq ($(CONFIG_LPC43_ADC0),y) +CSRCS += lpc43_adc.c +endif + ifeq ($(CONFIG_SPIFI_LIBRARY),y) -CFLAGS += -DEUROBIRD -SPIFI_LIB = spifi_lib -CSRCS += $(SPIFI_LIB)/spifi_rom_api.c -#CSRCS += $(SPIFI_LIB)/amic.c -#CSRCS += $(SPIFI_LIB)/atmel.c -#CSRCS += $(SPIFI_LIB)/chi.c -#CSRCS += $(SPIFI_LIB)/eon.c -#CSRCS += $(SPIFI_LIB)/esmt.c -#CSRCS += $(SPIFI_LIB)/esmt.c -#CSRCS += $(SPIFI_LIB)/giga.c -#CSRCS += $(SPIFI_LIB)/macronix.c -#CSRCS += $(SPIFI_LIB)/numonyx.c -CSRCS += $(SPIFI_LIB)/spansion.c -#CSRCS += $(SPIFI_LIB)/sst.c -CSRCS += $(SPIFI_LIB)/winbond.c +CSRCS += lpc43_spifilib_init.c endif include $(TOPDIR)/configs/Board.mk diff --git a/configs/lpc4370-link2/src/lpc4370-link2.h b/configs/lpc4370-link2/src/lpc4370-link2.h index 7333be78da9..9fe33877511 100644 --- a/configs/lpc4370-link2/src/lpc4370-link2.h +++ b/configs/lpc4370-link2/src/lpc4370-link2.h @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/lpc4370-LINK2/src/lpc4370-LINK2.h + * configs/lpc4370-link2/src/lpc4370-link2.h * * Copyright (C) 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -45,6 +45,7 @@ #include "lpc43_pinconfig.h" #include "lpc43_gpio.h" +#include "lpc43_spifi.h" /**************************************************************************** * Pre-processor Definitions @@ -91,6 +92,8 @@ * Public Functions ****************************************************************************/ +void board_spifi_initialize(void); + #endif /* __ASSEMBLY__ */ #endif /* _CONFIGS_LPC4370_LINK2_SRC_LPC3257_LINK2_H */ diff --git a/configs/lpc4370-link2/src/lpc43_adc.c b/configs/lpc4370-link2/src/lpc43_adc.c new file mode 100644 index 00000000000..531b25ad7e6 --- /dev/null +++ b/configs/lpc4370-link2/src/lpc43_adc.c @@ -0,0 +1,110 @@ +/************************************************************************************ + * configs/lpc4370-link2/src/lpc43_adc.c + * + * Copyright (C) 2013 Zilogic Systems. All rights reserved. + * Author: Kannan + * + * Based on configs/stm3220g-eval/src/lpc43_adc.c + * + * Copyright (C) 2012, 2014 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 "chip.h" +#include "up_arch.h" + +#include "lpc43_adc.h" + +#if defined(CONFIG_LPC43_ADC0) || defined(CONFIG_LPC43_ADC1) + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: board_adc_setup + * + * Description: + * All LPC43 architectures must provide the following interface to work with + * examples/adc. + * + ************************************************************************************/ + +int board_adc_setup(void) +{ + static bool initialized = false; + struct adc_dev_s *adc; + int ret; + + /* Check if we have already initialized */ + + if (!initialized) + { + /* Call lpc43_adcinitialize() to get an instance of the ADC interface */ + + adc = lpc43_adcinitialize(); + if (adc == NULL) + { + adbg("ERROR: Failed to get ADC interface\n"); + return -ENODEV; + } + + /* Register the ADC driver at "/dev/adc0" */ + + ret = adc_register("/dev/adc0", adc); + if (ret < 0) + { + adbg("adc_register failed: %d\n", ret); + return ret; + } + + /* Now we are initialized */ + + initialized = true; + } + + return OK; +} + +#endif /* CONFIG_ADC */ diff --git a/configs/lpc4370-link2/src/lpc43_boot.c b/configs/lpc4370-link2/src/lpc43_boot.c index 3466e32d215..e83b0cdad1d 100644 --- a/configs/lpc4370-link2/src/lpc43_boot.c +++ b/configs/lpc4370-link2/src/lpc43_boot.c @@ -78,5 +78,8 @@ void lpc43_boardinitialize(void) #ifdef CONFIG_ARCH_LEDS board_autoled_initialize(); #endif -} +#ifdef CONFIG_SPIFI_LIBRARY + board_spifi_initialize(); +#endif +} diff --git a/configs/lpc4370-link2/src/lpc43_nsh.c b/configs/lpc4370-link2/src/lpc43_nsh.c index 8d00e000f92..22cec0065ea 100644 --- a/configs/lpc4370-link2/src/lpc43_nsh.c +++ b/configs/lpc4370-link2/src/lpc43_nsh.c @@ -47,88 +47,6 @@ #include "chip.h" -#ifdef CONFIG_LPC43_SPIFI -# include -# include "lpc43_spifi.h" - -# ifdef CONFIG_SPFI_NXFFS -# include -# include -# endif -#endif - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -/* Configuration ************************************************************/ - -#ifndef CONFIG_SPIFI_DEVNO -# define CONFIG_SPIFI_DEVNO 0 -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nsh_spifi_initialize - * - * Description: - * Make the SPIFI (or part of it) into a block driver that can hold a - * file system. - * - ****************************************************************************/ - -#ifdef CONFIG_LPC43_SPIFI -static int nsh_spifi_initialize(void) -{ - FAR struct mtd_dev_s *mtd; - int ret; - - /* Initialize the SPIFI interface and create the MTD driver instance */ - - mtd = lpc43_spifi_initialize(); - if (!mtd) - { - fdbg("ERROR: lpc43_spifi_initialize failed\n"); - return -ENODEV; - } - -#ifndef CONFIG_SPFI_NXFFS - /* And finally, use the FTL layer to wrap the MTD driver as a block driver */ - - ret = ftl_initialize(CONFIG_SPIFI_DEVNO, mtd); - if (ret < 0) - { - fdbg("ERROR: Initializing the FTL layer: %d\n", ret); - return ret; - } -#else - /* Initialize to provide NXFFS on the MTD interface */ - - ret = nxffs_initialize(mtd); - if (ret < 0) - { - fdbg("ERROR: NXFFS initialization failed: %d\n", ret); - return ret; - } - - /* Mount the file system at /mnt/spifi */ - - ret = mount(NULL, "/mnt/spifi", "nxffs", 0, NULL); - if (ret < 0) - { - fdbg("ERROR: Failed to mount the NXFFS volume: %d\n", errno); - return ret; - } -#endif - - return OK; -} -#else -# define nsh_spifi_initialize() (OK) -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,8 +61,5 @@ static int nsh_spifi_initialize(void) int board_app_initialize(void) { - /* Initialize the SPIFI block device */ - - return nsh_spifi_initialize(); + return OK; } - diff --git a/configs/lpc4370-link2/src/lpc43_spifilib_init.c b/configs/lpc4370-link2/src/lpc43_spifilib_init.c new file mode 100644 index 00000000000..245cc2676e5 --- /dev/null +++ b/configs/lpc4370-link2/src/lpc43_spifilib_init.c @@ -0,0 +1,130 @@ +/**************************************************************************** + * configs/lpc4370-link2/src/lpc43_spifilib_initc + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "chip.h" +#include "up_arch.h" +#include "up_internal.h" +#include "lpc43_spifi.h" +#include "lpc43_cgu.h" + +#include "lpc4370-link2.h" + +#include "spifi/inc/spifilib_api.h" + +#ifdef CONFIG_SPIFI_LIBRARY + +/**************************************************************************** + * Private Data + ****************************************************************************/ +/* Local memory, 32-bit aligned that will be used for driver context + * (handle). + */ + +static uint32_t lmem[21]; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void board_spifi_initialize(void) +{ + irqstate_t flags = irqsave(); + uint32_t regval; + + flags = irqsave(); + + /* Initial frequency is set by boot ROM in IDIVE */ + + /* Pin configuration */ + + lpc43_pin_config(PINCONF_SPIFI_CS); + lpc43_pin_config(PINCONF_SPIFI_MISO); + lpc43_pin_config(PINCONF_SPIFI_MOSI); + lpc43_pin_config(PINCONF_SPIFI_SCK); + lpc43_pin_config(PINCONF_SPIFI_SIO2); + lpc43_pin_config(PINCONF_SPIFI_SIO3); + + /* Initialize LPCSPIFILIB library, reset the interface */ + + spifiInit(LPC43_SPIFI_CTRL, true); + + /* Register the family for the device */ + + spifiRegisterFamily(spifi_REG_FAMILY_CommonCommandSet); + + /* Initialize and detect a device and get device context */ + + SPIFI_HANDLE_T* pSpifi = spifiInitDevice(&lmem, sizeof(lmem), + LPC43_SPIFI_CTRL, + LPC43_LOCSRAM_SPIFI_BASE); + + /* Enable quad. If not supported it will be ignored */ + + spifiDevSetOpts(pSpifi, SPIFI_OPT_USE_QUAD, true); + + /* Enter memMode */ + + spifiDevSetMemMode(pSpifi, true); + + /* Configure divider as the input to the SPIFI */ + + regval = getreg32(LPC43_BASE_SPIFI_CLK); + regval &= ~BASE_SPIFI_CLK_CLKSEL_MASK; + regval |= BASE_SPIFI_CLKSEL_IDIVE; + putreg32(regval, LPC43_BASE_SPIFI_CLK); + + regval = getreg32(LPC43_IDIVE_CTRL); + regval &= ~(IDIVE_CTRL_CLKSEL_MASK | IDIVE_CTRL_IDIV_MASK); + regval |= BASE_SPIFI_CLKSEL_PLL1 | IDIVE_CTRL_AUTOBLOCK | + IDIVE_CTRL_IDIV(SPIFI_DEVICE_REQUENCY_DIVIDER); + putreg32(regval, LPC43_IDIVE_CTRL); + + irqrestore(flags); +} + +#endif /* CONFIG_SPIFI_LIBRARY */