diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-06-25 21:21:08 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-06-25 21:21:08 +0000 |
commit | 7ec3df6877acc2a99bff86c03122ce15a035977d (patch) | |
tree | 6ff78431ddd745e2b416e1eff97d70756739165b /nuttx/configs/mirtoo | |
parent | c8f02e00cd16f5031baad36615ec3dd76c575e02 (diff) | |
download | px4-firmware-7ec3df6877acc2a99bff86c03122ce15a035977d.tar.gz px4-firmware-7ec3df6877acc2a99bff86c03122ce15a035977d.tar.bz2 px4-firmware-7ec3df6877acc2a99bff86c03122ce15a035977d.zip |
Add a driver for SST 25 FLASH
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4868 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/configs/mirtoo')
-rw-r--r-- | nuttx/configs/mirtoo/nsh/defconfig | 10 | ||||
-rw-r--r-- | nuttx/configs/mirtoo/src/Makefile | 8 | ||||
-rw-r--r-- | nuttx/configs/mirtoo/src/up_nsh.c | 126 | ||||
-rw-r--r-- | nuttx/configs/mirtoo/src/up_spi2.c | 10 |
4 files changed, 146 insertions, 8 deletions
diff --git a/nuttx/configs/mirtoo/nsh/defconfig b/nuttx/configs/mirtoo/nsh/defconfig index c581a7f29..7bec6ed54 100644 --- a/nuttx/configs/mirtoo/nsh/defconfig +++ b/nuttx/configs/mirtoo/nsh/defconfig @@ -164,6 +164,14 @@ CONFIG_PIC32MX_IOPORTB=y CONFIG_PIC32MX_IOPORTC=y # +# Mirtoo Board Settings +# +CONFIG_MTD_SST25=n +#CONFIG_SST25_SPIMODE +#CONFIG_SST25_SPIFREQUENCY +CONFIG_SST25_SECTOR512=n + +# # PIC32MX Configuration Settings # # DEVCFG0: @@ -346,6 +354,8 @@ CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_SYMBOLS=n CONFIG_DEBUG_SCHED=n +CONFIG_DEBUG_FS=n +CONFIG_DEBUG_SPI=n CONFIG_HAVE_CXX=n CONFIG_HAVE_CXXINITIALIZE=n diff --git a/nuttx/configs/mirtoo/src/Makefile b/nuttx/configs/mirtoo/src/Makefile index fbde5728f..cbfbb8173 100644 --- a/nuttx/configs/mirtoo/src/Makefile +++ b/nuttx/configs/mirtoo/src/Makefile @@ -44,6 +44,10 @@ ifeq ($(CONFIG_PIC32MX_SPI2),y) CSRCS += up_spi2.c endif +ifeq ($(CONFIG_NSH_ARCHINIT),y) +CSRCS += up_nsh.c +endif + AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) @@ -53,8 +57,8 @@ OBJS = $(AOBJS) $(COBJS) ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src ifeq ($(WINTOOL),y) CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \ - -I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \ - -I "${shell cygpath -w $(ARCH_SRCDIR)/mips32}" + -I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/mips32}" else CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/mips32 endif diff --git a/nuttx/configs/mirtoo/src/up_nsh.c b/nuttx/configs/mirtoo/src/up_nsh.c new file mode 100644 index 000000000..d2c8064c3 --- /dev/null +++ b/nuttx/configs/mirtoo/src/up_nsh.c @@ -0,0 +1,126 @@ +/**************************************************************************** + * config/mirtoo/src/up_nsh.c + * arch/arm/src/board/up_nsh.c + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdbool.h> +#include <stdio.h> +#include <errno.h> +#include <debug.h> + +#ifdef CONFIG_PIC32MX_SPI2 +# include <nuttx/spi.h> +# include <nuttx/mtd.h> +#endif + +#include "pic32mx-internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ +/* Can't support the SST25 device if it SPI2 or SST25 support is not enabled */ + +#define HAVE_SST25 1 +#if !defined(CONFIG_PIC32MX_SPI2) || !defined(CONFIG_MTD_SST25) +# undef HAVE_SST25 +#endif + +/* Can't support SST25 features if mountpoints are disabled */ + +#if defined(CONFIG_DISABLE_MOUNTPOINT) +# undef HAVE_SST25 +#endif + +/* Use minor device number 0 is not is provided */ + +#ifndef CONFIG_NSH_SST25MINOR +# define CONFIG_NSH_SST25MINOR 0 +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nsh_archinitialize + * + * Description: + * Perform architecture specific initialization + * + ****************************************************************************/ + +int nsh_archinitialize(void) +{ +#ifdef HAVE_SST25 + FAR struct spi_dev_s *spi; + FAR struct mtd_dev_s *mtd; + int ret; + + /* Get the SPI port */ + + spi = up_spiinitialize(2); + if (!spi) + { + fdbg("ERROR: Failed to initialize SPI port 2\n"); + return -ENODEV; + } + + /* Now bind the SPI interface to the SST 25 SPI FLASH driver */ + + mtd = sst25_initialize(spi); + if (!mtd) + { + fdbg("ERROR: Failed to bind SPI port 2 to the SST 25 FLASH driver\n"); + return -ENODEV; + } + + /* And finally, use the FTL layer to wrap the MTD driver as a block driver */ + + ret = ftl_initialize(CONFIG_NSH_SST25MINOR, mtd); + if (ret < 0) + { + fdbg("ERROR: Initialize the FTL layer\n"); + return -ENODEV; + } +#endif + return OK; +} diff --git a/nuttx/configs/mirtoo/src/up_spi2.c b/nuttx/configs/mirtoo/src/up_spi2.c index 785eadb80..3b43497d7 100644 --- a/nuttx/configs/mirtoo/src/up_spi2.c +++ b/nuttx/configs/mirtoo/src/up_spi2.c @@ -51,7 +51,7 @@ #include "chip.h" #include "pic32mx-internal.h" #include "pic32mx-pps.h" -#include "mirtoo_internal.h" +#include "mirtoo-internal.h" #ifdef CONFIG_PIC32MX_SPI2 @@ -119,8 +119,6 @@ void weak_function pic32mx_spi2initialize(void) { - uint32_t regval; - /* Make sure that TRIS pins are set correctly. Configure the SPI pins as digital * inputs and outputs first. */ @@ -171,7 +169,7 @@ void weak_function pic32mx_spi2initialize(void) struct spi_dev_s; enum spi_dev_e; -void pic31mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) +void pic32mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) { spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); @@ -185,13 +183,13 @@ void pic31mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool s } } -uint8_t pic31mx_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) +uint8_t pic32mx_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) { return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic31mx_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd) +int pic32mx_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd) { return 0; } |