mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
Add a general bit-bang SPI lower-half driver and implement the bit-bang driver for the Arduino ITEAD TFT shield
This commit is contained in:
@@ -55,7 +55,7 @@ endif
|
||||
ifeq ($(CONFIG_ARDUINO_ITHEAD_TFT),y)
|
||||
|
||||
ifeq ($(CONFIG_SPI_BITBANG),y)
|
||||
ifeq ($(CONFIG_MMC_SPI),y)
|
||||
ifeq ($(CONFIG_MMCSD_SPI),y)
|
||||
CSRCS += sam_mmcsd.c
|
||||
endif
|
||||
|
||||
@@ -69,6 +69,10 @@ CSRCS += sam_lcd.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_ARCHINIT),y)
|
||||
CSRCS += sam_nsh.c
|
||||
endif
|
||||
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
* SPI bit-bang driver as well as support for SPI-based MMC/SD cards.
|
||||
*/
|
||||
|
||||
# if defined(CONFIG_SPI_BITBANG) && defined(CONFIG_MMC_SPI)
|
||||
# if defined(CONFIG_SPI_BITBANG) && defined(CONFIG_MMCSD_SPI)
|
||||
|
||||
/* The SD slot shares the pin with LED "L" so LED support must be disabled
|
||||
* to use the MMC/SD card on the ITEAD shield.
|
||||
@@ -183,13 +183,13 @@
|
||||
# error LEDs may not be used with the ITEAD SD card
|
||||
# endif
|
||||
|
||||
# define GPIO_SD_SCK (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_SD_SCK (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOB | GPIO_PIN27)
|
||||
# define GPIO_SD_MISO (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_SD_MISO (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOD | GPIO_PIN8)
|
||||
# define GPIO_SD_MOSI (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_SD_MOSI (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOD | GPIO_PIN7)
|
||||
# define GPIO_SD_CS (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_SD_CS (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIO? | GPIO_PIN?)
|
||||
# endif
|
||||
|
||||
@@ -198,13 +198,13 @@
|
||||
*/
|
||||
|
||||
# if defined(CONFIG_SPI_BITBANG) && defined(CONFIG_INPUT)
|
||||
# define GPIO_TSC_SCK (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_TSC_SCK (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOA | GPIO_PIN24)
|
||||
# define GPIO_TSC_MISO (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_TSC_MISO (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOC | GPIO_PIN21)
|
||||
# define GPIO_TSC_MOSI (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_TSC_MOSI (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOA | GPIO_PIN16)
|
||||
# define GPIO_TSC_CS (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_TSC_CS (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIO? | GPIO_PIN?)
|
||||
# define GPIO_TSC_IRQ (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_INT_BOTHEDGES | \
|
||||
GPIO_PORT_PIOC | GPIO_PIN22)
|
||||
@@ -227,29 +227,29 @@
|
||||
* either inputs or outputs as needed.
|
||||
*/
|
||||
|
||||
# define GPIO_LCD_D0IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_D0IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOA | GPIO_PIN8)
|
||||
# define GPIO_LCD_D1IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_D1IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOA | GPIO_PIN9)
|
||||
# define GPIO_LCD_D2IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_D2IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOB | GPIO_PIN25)
|
||||
# define GPIO_LCD_D3IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_D3IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOC | GPIO_PIN28)
|
||||
# define GPIO_LCD_D4IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_D4IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOC | GPIO_PIN26)
|
||||
# define GPIO_LCD_D5IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_D5IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOC | GPIO_PIN25)
|
||||
# define GPIO_LCD_D6IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_D6IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOC | GPIO_PIN24)
|
||||
# define GPIO_LCD_D7IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_D7IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOC | GPIO_PIN23)
|
||||
# define GPIO_LCD_D7IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_D7IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOC | GPIO_PIN23)
|
||||
# define GPIO_LCD_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOA | GPIO_PIN22)
|
||||
# define GPIO_LCD_WR (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_WR (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOA | GPIO_PIN6)
|
||||
# define GPIO_LCD_RS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLR | \
|
||||
# define GPIO_LCD_RS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOA | GPIO_PIN4)
|
||||
# endif
|
||||
#endif
|
||||
@@ -288,6 +288,20 @@ void sam_sram_initialize(void);
|
||||
void up_ledinit(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_sdinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SPI-based SD card.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \
|
||||
defined(CONFIG_MMCSD_SPI)
|
||||
int sam_sdinitialize(int minor);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_ARDUINO_DUE_SRC_ARDUNO_DUE_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
/****************************************************************************
|
||||
* configs/sam3u-ek/src/up_mmcsd.c
|
||||
*
|
||||
* Copyright (C) 2010, 2013 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 <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/mmcsd.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/spi/spi_bitbang.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "sam_gpio.h"
|
||||
#include "chip/sam3u_pio.h"
|
||||
|
||||
#include "arduino-due.h"
|
||||
|
||||
/* In order to use the SD card on the ITEAD shield, you must enable the SPI bit-bang
|
||||
* driver as well as support for SPI-based MMC/SD cards.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \
|
||||
defined(CONFIG_MMCSD_SPI)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifdef CONFIG_DISABLE_MOUNTPOINT
|
||||
# error Mountpoints are disabled (CONFIG_DISABLE_MOUNTPOINT=y)
|
||||
#endif
|
||||
|
||||
/* Definitions for include/nuttx/spi/spi_bitbang.c. */
|
||||
|
||||
#define SPI_SETSCK putreg32(1 << 27, SAM_PIOB_SODR)
|
||||
#define SPI_CLRSCK putreg32(1 << 27, SAM_PIOB_CODR)
|
||||
#define SPI_SETMOSI putreg32(1 << 7, SAM_PIOD_SODR)
|
||||
#define SPI_CLRMOSI putreg32(1 << 7, SAM_PIOD_CODR)
|
||||
#define SPI_GETMISO ((getreg32(SAM_PIOD_PDSR) >> 8) & 1)
|
||||
|
||||
/* SPI_PERBIT_NSEC is the minimum time to transfer one bit. This determines
|
||||
* the maximum frequency and is also used to calculate delays to achieve
|
||||
* other SPI frequencies.
|
||||
*
|
||||
* This value came from selecting 400KHz and increasing SPI_PERBIT_NSEC
|
||||
* until a frequency close to 400KHz was achieved. This is what was
|
||||
* reported by the software: frequency=400000 holdtime=1 actual=298507.
|
||||
* I measured a frequency of approximately 305KHz.
|
||||
*
|
||||
* NOTE that there are really only two frequencies possible: hold time=1
|
||||
* (305KHz) and hold time = 0 (probably around 781KHz)
|
||||
*/
|
||||
|
||||
#define SPI_PERBIT_NSEC 1350 /* Calibrated at 400KHz */
|
||||
|
||||
/* Misc definitions */
|
||||
|
||||
#define SAM34_MMCSDSLOTNO 0 /* There is only one slot */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void spi_select(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
|
||||
bool selected);
|
||||
static uint8_t spi_status(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid);
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
static int spi_cmddata(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
|
||||
bool cmd);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
/****************************************************************************
|
||||
* Include the bit-band skeleton logic
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/spi/spi_bitbang.c>
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_mmcsd_spiinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SPI bitband driver
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-NULL reference to the SPI driver on success
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void spi_select(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
|
||||
bool selected)
|
||||
{
|
||||
# warning Still need CS GPIO pin
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_mmcsd_spiinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SPI bitband driver
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-NULL reference to the SPI driver on success
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t spi_status(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid)
|
||||
{
|
||||
if (devid = SPIDEV_MMCSD)
|
||||
{
|
||||
return SPI_STATUS_PRESENT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spi_cmddata
|
||||
*
|
||||
* Description:
|
||||
* If there were was a CMD/DATA line, this function would manage it
|
||||
*
|
||||
* Input Parameters:
|
||||
* priv - An instance of the bit-bang driver structure
|
||||
* devid - The device to use
|
||||
* cmd - True=MCD false=DATA
|
||||
*
|
||||
* Returned Value:
|
||||
* OK
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
static int spi_cmddata(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
|
||||
bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_mmcsd_spiinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SPI bitband driver
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-NULL reference to the SPI driver on success
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct spi_dev_s *sam_mmcsd_spiinitialize(void)
|
||||
{
|
||||
/* Initialize GPIOs */
|
||||
|
||||
sam_configgpio(GPIO_SD_SCK);
|
||||
sam_configgpio(GPIO_SD_MISO);
|
||||
sam_configgpio(GPIO_SD_MOSI);
|
||||
// sam_configgpio(GPIO_SD_CS);
|
||||
# warning Still need CS GPIO pin
|
||||
|
||||
/* Create the SPI driver instance */
|
||||
|
||||
return spi_create_bitbang(&g_spiops);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_sdinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SPI-based SD card.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int sam_sdinitialize(int minor)
|
||||
{
|
||||
FAR struct spi_dev_s *spi;
|
||||
int ret;
|
||||
|
||||
/* Get the SPI driver instance for the SD chip select */
|
||||
|
||||
fvdbg("Initializing bit bang SPI for the MMC/SD slot\n");
|
||||
|
||||
spi = sam_mmcsd_spiinitialize();
|
||||
if (!spi)
|
||||
{
|
||||
fdbg("Failed to bit bang SPI for the MMC/SD slot\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
fvdbg("Successfully initialized bit bang SPI for the MMC/SD slot\n");
|
||||
|
||||
/* Bind the SPI device for the chip select to the slot */
|
||||
|
||||
fvdbg("Binding bit bang SPI device to MMC/SD slot %d\n",
|
||||
SAM34_MMCSDSLOTNO);
|
||||
|
||||
ret = mmcsd_spislotinitialize(minor, SAM34_MMCSDSLOTNO, spi);
|
||||
if (ret < 0)
|
||||
{
|
||||
fdbg("Failed to bind bit bang SPI device to MMC/SD slot %d: %d\n",
|
||||
SAM34_MMCSDSLOTNO, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
fvdbg("Successfuly bound bit bang SPI device to MMC/SD slot %d\n",
|
||||
SAM34_MMCSDSLOTNO);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARDUINO_ITHEAD_TFT && CONFIG_SPI_BITBANG && CONFIG_MMC_SPI */
|
||||
@@ -0,0 +1,115 @@
|
||||
/****************************************************************************
|
||||
* config/arduino-due/src/sam_nsh.c
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "arduino-due.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \
|
||||
defined(CONFIG_MMCSD_SPI)
|
||||
/* Support for the SD card slot on the ITEAD TFT shield */
|
||||
/* Verify NSH PORT and SLOT settings */
|
||||
|
||||
# define SAM34_MMCSDSLOTNO 0 /* There is only one slot */
|
||||
|
||||
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != SAM34_MMCSDSLOTNO
|
||||
# error Only one MMC/SD slot: Slot 0 (CONFIG_NSH_MMCSDSLOTNO)
|
||||
# endif
|
||||
|
||||
/* Default MMC/SD minor number */
|
||||
|
||||
# ifndef CONFIG_NSH_MMCSDMINOR
|
||||
# define CONFIG_NSH_MMCSDMINOR 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Debug ********************************************************************/
|
||||
|
||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message(...) lowsyslog(__VA_ARGS__)
|
||||
# else
|
||||
# define message(...) printf(__VA_ARGS__)
|
||||
# endif
|
||||
#else
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message lowsyslog
|
||||
# else
|
||||
# define message printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_archinitialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_archinitialize(void)
|
||||
{
|
||||
#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \
|
||||
defined(CONFIG_MMCSD_SPI)
|
||||
/* Initialize the SPI-based MMC/SD slot */
|
||||
|
||||
{
|
||||
int ret = sam_sdinitialize(CONFIG_NSH_MMCSDMINOR);
|
||||
if (ret < 0)
|
||||
{
|
||||
message("nsh_archinitialize: Failed to initialize MMC/SD slot: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
Reference in New Issue
Block a user