Resync new repository with old repo r5166

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5153 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-09-17 18:18:44 +00:00
commit 57623d42eb
5691 changed files with 1361853 additions and 0 deletions
@@ -0,0 +1,99 @@
############################################################################
# configs/pic32-starterkit/src/Makefile
#
# Copyright (C) 2011 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.
#
############################################################################
-include $(TOPDIR)/Make.defs
CFLAGS += -I$(TOPDIR)/sched
ASRCS =
CSRCS = up_boot.c up_leds.c up_spi.c
ifeq ($(CONFIG_PIC32MX_USBDEV),y)
CSRCS += up_usbdev.c
ifeq ($(CONFIG_EXAMPLES_USBTERM_DEVINIT),y)
CSRCS += up_usbterm.c
endif
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += up_nsh.c
endif
ifeq ($(CONFIG_USBMSC),y)
CSRCS += up_usbmsc.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
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}"
else
CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/mips32
endif
all: libboard$(LIBEXT)
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
libboard$(LIBEXT): $(OBJS)
@( for obj in $(OBJS) ; do \
$(call ARCHIVE, $@, $${obj}); \
done ; )
.depend: Makefile $(SRCS)
@$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@
depend: .depend
clean:
@rm -f libboard$(LIBEXT) *~ .*.swp
$(call CLEAN)
distclean: clean
@rm -f Make.dep .depend
-include Make.dep
@@ -0,0 +1,122 @@
/****************************************************************************
* configs/pic32-starterkit/src/starterkit_internal.h
*
* Copyright (C) 2011 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.
*
****************************************************************************/
#ifndef __CONFIGS_PIC32_STARTERKIT_SRC_STARTERKIT_INTERNAL_H
#define __CONFIGS_PIC32_STARTERKIT_SRC_STARTERKIT_INTERNAL_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* The PIC32 starter kit has 3 user LEDs
*
* RD0 User LED D4 (high illuminates)
* RD2 User LED D5 (high illuminates)
* RD1 User LED D6 (high illuminates)
*
* There are 5 LEDs available on the MEB:
*
* RD1 LED1
* RD2 LED2
* RD3 LED3
* RC1 LED4
* RC2 LED5
*/
/* The PIC32 starter kit has 3 switches:
*
* RD7 Switch SW2 (low when closed)
* RD6 Switch SW1 (low when closed)
* RD13 Switch SW3 (low when closed)
*/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline Functions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/************************************************************************************
* Name: pic32mx_spiinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the PCB Logic board.
*
************************************************************************************/
#if defined(CONFIG_PIC32MX_SPI2)
EXTERN void weak_function pic32mx_spiinitialize(void);
#endif
/************************************************************************************
* Name: pic32mx_ledinit
*
* Description:
* Configure on-board LEDs if LED support has been selected.
*
************************************************************************************/
#ifdef CONFIG_ARCH_LEDS
EXTERN void pic32mx_ledinit(void);
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_PIC32_STARTERKIT_SRC_STARTERKIT_INTERNAL_H */
@@ -0,0 +1,94 @@
/************************************************************************************
* configs/pic32-starterkit/src/up_boot.c
* arch/mips/src/board/up_boot.c
*
* Copyright (C) 2011 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 <debug.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "up_internal.h"
#include "pic32mx-internal.h"
#include "starterkit_internal.h"
/************************************************************************************
* Definitions
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: pic32mx_boardinitialize
*
* Description:
* All PIC32MX 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.
*
************************************************************************************/
void pic32mx_boardinitialize(void)
{
/* Configure SPI chip selects if 1) at least one SPI is enabled, and 2) the weak
* function pic32mx_spiinitialize() has been brought into the link.
*/
#if defined(CONFIG_PIC32MX_SPI1) || defined(CONFIG_PIC32MX_SPI2) || \
defined(CONFIG_PIC32MX_SPI3) || defined(CONFIG_PIC32MX_SPI4)
if (pic32mx_spiinitialize)
{
pic32mx_spiinitialize();
}
#endif
/* Configure on-board LEDs if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
pic32mx_ledinit();
#endif
}
@@ -0,0 +1,266 @@
/****************************************************************************
* configs/pic32-starterkit/src/up_leds.c
* arch/arm/src/board/up_leds.c
*
* Copyright (C) 2011 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 <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#include "chip.h"
#include "up_arch.h"
#include "up_internal.h"
#include "pic32mx-internal.h"
#include "pic32mx-ioport.h"
#include "starterkit_internal.h"
/****************************************************************************
* Definitions
****************************************************************************/
/* LED Configuration ********************************************************/
/* The PIC32MX Ethernet Starter kit has 3 user LEDs labeled LED1-3 on the
* board graphics (but referred to as LED4-6 in the schematic):
*
* PIN User's Guide Board Stencil Notes
* --- ------------- -------------- -------------------------
* RD0 "User LED D4" "LED1 (RD0") High illuminates (RED)
* RD2 "User LED D5" "LED3 (RD2)" High illuminates (YELLOW)
* RD1 "User LED D6" "LED2 (RD1)" High illuminates (GREEN)
*
* We will use the labels on the board to identify LEDs
*
* ON OFF
* ------------------------- ---- ---- ---- ---- ---- ----
* LED1 LED2 LED3 LED1 LED2 LED3
* ------------------------- ---- ---- ---- ---- ---- ----
* LED_STARTED 0 OFF OFF OFF --- --- ---
* LED_HEAPALLOCATE 1 ON OFF N/C --- --- ---
* LED_IRQSENABLED 2 OFF ON N/C --- --- ---
* LED_STACKCREATED 3 ON ON N/C --- --- ---
* LED_INIRQ 4 N/C N/C ON N/C N/C OFF
* LED_SIGNAL 4 N/C N/C ON N/C N/C OFF
* LED_ASSERTION 4 N/C N/C ON N/C N/C OFF
* LED_PANIC 5 ON N/C N/C OFF N/C N/C
*/
#define GPIO_LED_1 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTD|GPIO_PIN0)
#define GPIO_LED_2 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTD|GPIO_PIN1)
#define GPIO_LED_3 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTD|GPIO_PIN2)
/* LED Management Definitions ***********************************************/
#ifdef CONFIG_ARCH_LEDS
# define LED_OFF 0
# define LED_ON 1
# define LED_NC 2
#endif
/* Debug ********************************************************************/
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_LEDS)
# define leddbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define ledvdbg lldbg
# else
# define ledvdbg(x...)
# endif
#else
# undef CONFIG_DEBUG_LEDS
# undef CONFIG_DEBUG_VERBOSE
# define leddbg(x...)
# define ledvdbg(x...)
#endif
/****************************************************************************
* Private types
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
struct led_setting_s
{
uint8_t led1 : 2;
uint8_t led2 : 2;
uint8_t led3 : 2;
uint8_t unused : 2;
};
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/* If CONFIG_ARCH_LEDS is defined then NuttX will control the LEDs. The
* following structures identified the LED settings for each NuttX LED state.
*/
#ifdef CONFIG_ARCH_LEDS
static const struct led_setting_s g_ledonvalues[LED_NVALUES] =
{
{LED_OFF, LED_OFF, LED_OFF, LED_OFF},
{LED_ON, LED_OFF, LED_NC, LED_OFF},
{LED_OFF, LED_ON, LED_NC, LED_OFF},
{LED_ON, LED_ON, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_ON, LED_OFF},
{LED_ON, LED_NC, LED_NC, LED_OFF},
};
static const struct led_setting_s g_ledoffvalues[LED_NVALUES] =
{
{LED_NC, LED_NC, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_OFF, LED_OFF},
{LED_OFF, LED_NC, LED_NC, LED_OFF},
};
/* If CONFIG_ARCH_LEDS is not defined, the the user can control the LEDs in
* any way. The following array simply maps the PIC32MX_STARTERKIT_LEDn
* index values to the correct LED pin configuration.
*/
#else
static const uint16_t g_ledpincfg[PIC32MX_STARTERKIT_NLEDS] =
{
GPIO_LED_1, GPIO_LED_2, GPIO_LED_3
};
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: up_setleds
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void up_setleds(FAR const struct led_setting_s *setting)
{
if (setting->led1 != LED_NC)
{
pic32mx_gpiowrite(GPIO_LED_1, setting->led1 == LED_ON);
}
if (setting->led2 != LED_NC)
{
pic32mx_gpiowrite(GPIO_LED_2, setting->led2 == LED_ON);
}
if (setting->led3 != LED_NC)
{
pic32mx_gpiowrite(GPIO_LED_3, setting->led3 == LED_ON);
}
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: pic32mx_ledinit
****************************************************************************/
void pic32mx_ledinit(void)
{
/* Configure output pins */
pic32mx_configgpio(GPIO_LED_1);
pic32mx_configgpio(GPIO_LED_2);
pic32mx_configgpio(GPIO_LED_3);
}
/****************************************************************************
* Name: pic32mx_setled
****************************************************************************/
#ifndef CONFIG_ARCH_LEDS
void pic32mx_setled(int led, bool ledon)
{
if ((unsigned)led < PIC32MX_STARTERKIT_NLEDS)
{
pic32mx_gpiowrite(g_ledpincfg[led], ledon);
}
}
#endif
/****************************************************************************
* Name: pic32mx_setleds
****************************************************************************/
#ifndef CONFIG_ARCH_LEDS
void pic32mx_setleds(uint8_t ledset)
{
pic32mx_setled(PIC32MX_STARTERKIT_LED1, (ledset & PIC32MX_STARTERKIT_LED1_BIT) != 0);
pic32mx_setled(PIC32MX_STARTERKIT_LED2, (ledset & PIC32MX_STARTERKIT_LED2_BIT) != 0);
pic32mx_setled(PIC32MX_STARTERKIT_LED3, (ledset & PIC32MX_STARTERKIT_LED3_BIT) != 0);
}
#endif
/****************************************************************************
* Name: up_ledon
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void up_ledon(int led)
{
if ((unsigned)led < LED_NVALUES)
{
up_setleds(&g_ledonvalues[led]);
}
}
#endif
/****************************************************************************
* Name: up_ledoff
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void up_ledoff(int led)
{
if ((unsigned)led < LED_NVALUES)
{
up_setleds(&g_ledoffvalues[led]);
}
}
#endif
+381
View File
@@ -0,0 +1,381 @@
/****************************************************************************
* config/pic32-starterkit/src/up_nsh.c
* arch/arm/src/board/up_nsh.c
*
* Copyright (C) 2011 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 <unistd.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/spi.h>
#include <nuttx/mmcsd.h>
#include <nuttx/usb/usbhost.h>
#include "pic32mx-internal.h"
#include "starterkit_internal.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Assume that we have MMC/SD, USB host (and USB device) */
#define NSH_HAVEMMCSD 1
#define NSH_HAVEUSBHOST 1
/* The PIC32 Ethernet Starter Kit does not have an SD slot on board. If one
* is added, then it must be specified by defining which SPI bus that it
* is connected on.
*/
#ifndef CONFIG_PIC32MX_MMCSDSPIPORTNO
# undef NSH_HAVEMMCSD
#endif
/* Make sure that the configuration will support the SD card */
#ifdef NSH_HAVEMMCSD
/* Make sure that the NSH configuration uses the correct SPI */
# if !defined(CONFIG_NSH_MMCSDSPIPORTNO)
# define CONFIG_NSH_MMCSDSPIPORTNO CONFIG_PIC32MX_MMCSDSPIPORTNO
# elif CONFIG_NSH_MMCSDSPIPORTNO != CONFIG_PIC32MX_MMCSDSPIPORTNO
# warning "CONFIG_PIC32MX_MMCSDSPIPORTNO does not match CONFIG_NSH_MMCSDSPIPORTNO"
# undef CONFIG_NSH_MMCSDSPIPORTNO
# define CONFIG_NSH_MMCSDSPIPORTNO CONFIG_PIC32MX_MMCSDSPIPORTNO
# endif
/* Make sure that the NSH configuration uses the slot */
# if !defined(CONFIG_NSH_MMCSDSLOTNO) || CONFIG_NSH_MMCSDSLOTNO != 0
# warning "The PIC32 Starter Kit has only one slot (0)"
# undef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO 0
# endif
/* Make sure that the correct SPI is enabled in the configuration */
# if CONFIG_PIC32MX_MMCSDSPIPORTNO == 1 && !defined(CONFIG_PIC32MX_SPI1)
# warning "CONFIG_PIC32MX_SPI1 is not enabled"
# undef NSH_HAVEMMCSD
# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 2 && !defined(CONFIG_PIC32MX_SPI2)
# warning "CONFIG_PIC32MX_SPI2 is not enabled"
# undef NSH_HAVEMMCSD
# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 3 && !defined(CONFIG_PIC32MX_SPI3)
# warning "CONFIG_PIC32MX_SPI3 is not enabled"
# undef NSH_HAVEMMCSD
# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 4 && !defined(CONFIG_PIC32MX_SPI4)
# warning "CONFIG_PIC32MX_SPI4 is not enabled"
# undef NSH_HAVEMMCSD
# endif
#endif
/* Can't support MMC/SD features if mountpoints are disabled */
#if defined(CONFIG_DISABLE_MOUNTPOINT)
# undef NSH_HAVEMMCSD
#endif
/* Select /dev/mmcsd0 if no other minor number is provided */
#ifndef CONFIG_NSH_MMCSDMINOR
# define CONFIG_NSH_MMCSDMINOR 0
#endif
/* USB Host */
#ifdef CONFIG_USBHOST
# ifndef CONFIG_PIC32MX_USBHOST
# error "CONFIG_PIC32MX_USBHOST is not selected"
# undef NSH_HAVEUSBHOST
# endif
#endif
#ifdef CONFIG_PIC32MX_USBHOST
# ifndef CONFIG_USBHOST
# warning "CONFIG_USBHOST is not selected"
# undef NSH_HAVEUSBHOST
# endif
#endif
#if !defined(CONFIG_USBHOST) || !defined(CONFIG_PIC32MX_USBHOST)
# undef NSH_HAVEUSBHOST
#endif
#ifdef NSH_HAVEUSBHOST
# ifndef CONFIG_USBHOST_DEFPRIO
# define CONFIG_USBHOST_DEFPRIO 50
# endif
# ifndef CONFIG_USBHOST_STACKSIZE
# define CONFIG_USBHOST_STACKSIZE 1024
# endif
#endif
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lib_lowprintf(__VA_ARGS__)
# else
# define message(...) printf(__VA_ARGS__)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lib_lowprintf
# else
# define message printf
# endif
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef NSH_HAVEUSBHOST
static struct usbhost_driver_s *g_drvr;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_waiter
*
* Description:
* Wait for USB devices to be connected.
*
****************************************************************************/
#ifdef NSH_HAVEUSBHOST
static int nsh_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
message("nsh_waiter: Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, connected);
DEBUGASSERT(ret == OK);
connected = !connected;
message("nsh_waiter: %s\n", connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
{
/* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr);
}
}
/* Keep the compiler from complaining */
return 0;
}
#endif
/****************************************************************************
* Name: nsh_sdinitialize
*
* Description:
* Initialize SPI-based microSD.
*
****************************************************************************/
#ifdef NSH_HAVEMMCSD
static int nsh_sdinitialize(void)
{
FAR struct spi_dev_s *ssp;
int ret;
/* Get the SPI port */
ssp = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO);
if (!ssp)
{
message("nsh_archinitialize: Failed to initialize SPI port %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
ret = -ENODEV;
goto errout;
}
message("Successfully initialized SPI port %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
/* Bind the SPI port to the slot */
ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR,
CONFIG_NSH_MMCSDSLOTNO, ssp);
if (ret < 0)
{
message("nsh_sdinitialize: "
"Failed to bind SPI port %d to MMC/SD slot %d: %d\n",
CONFIG_NSH_MMCSDSPIPORTNO,
CONFIG_NSH_MMCSDSLOTNO, ret);
goto errout;
}
message("Successfuly bound SPI port %d to MMC/SD slot %d\n",
CONFIG_NSH_MMCSDSPIPORTNO,
CONFIG_NSH_MMCSDSLOTNO);
return OK;
errout:
return ret;
}
#else
# define nsh_sdinitialize() (OK)
#endif
/****************************************************************************
* Name: nsh_usbhostinitialize
*
* Description:
* Initialize SPI-based microSD.
*
****************************************************************************/
#ifdef NSH_HAVEUSBHOST
static int nsh_usbhostinitialize(void)
{
int pid;
int ret;
/* First, register all of the class drivers needed to support the drivers
* that we care about:
*/
message("nsh_usbhostinitialize: Register class drivers\n");
ret = usbhost_storageinit();
if (ret != OK)
{
message("nsh_usbhostinitialize: Failed to register the mass storage class\n");
}
/* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n");
g_drvr = usbhost_initialize(0);
if (g_drvr)
{
/* Start a thread to handle device connection. */
message("nsh_usbhostinitialize: Start nsh_waiter\n");
#ifndef CONFIG_CUSTOM_STACK
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
CONFIG_USBHOST_STACKSIZE,
(main_t)nsh_waiter, (const char **)NULL);
#else
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
(main_t)nsh_waiter, (const char **)NULL);
#endif
return pid < 0 ? -ENOEXEC : OK;
}
return -ENODEV;
}
#else
# define nsh_usbhostinitialize() (OK)
#endif
/****************************************************************************
* Name: nsh_usbdevinitialize
*
* Description:
* Initialize SPI-based microSD.
*
****************************************************************************/
#ifdef CONFIG_USBDEV
static int nsh_usbdevinitialize(void)
{
/* The PIC32 Starter Kit has no way to know when the USB is connected. So
* we will fake it and tell the USB driver that the USB is connected now.
*/
pic32mx_usbattach();
return OK;
}
#else
# define nsh_usbdevinitialize() (OK)
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int nsh_archinitialize(void)
{
int ret;
/* Initialize SPI-based microSD */
ret = nsh_sdinitialize();
if (ret == OK)
{
/* Initialize USB host */
ret = nsh_usbhostinitialize();
}
if (ret == OK)
{
/* Initialize USB device */
ret = nsh_usbdevinitialize();
}
return ret;
}
+223
View File
@@ -0,0 +1,223 @@
/************************************************************************************
* configs/pic32-starterkit/src/up_ssp.c
* arch/arm/src/board/up_ssp.c
*
* Copyright (C) 2011 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 <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/spi.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "chip.h"
#include "pic32mx-internal.h"
#include "starterkit_internal.h"
#if defined(CONFIG_PIC32MX_SPI1) || defined(CONFIG_PIC32MX_SPI2) || \
defined(CONFIG_PIC32MX_SPI3) || defined(CONFIG_PIC32MX_SPI4)
/************************************************************************************
* Definitions
************************************************************************************/
/* The following enable debug output from this file (needs CONFIG_DEBUG too).
*
* CONFIG_SPI_DEBUG - Define to enable basic SPI debug
* CONFIG_SPI_VERBOSE - Define to enable verbose SPI debug
*/
#ifdef CONFIG_SPI_DEBUG
# define sspdbg lldbg
# ifdef CONFIG_SPI_VERBOSE
# define sspvdbg lldbg
# else
# define sspvdbg(x...)
# endif
#else
# undef CONFIG_SPI_VERBOSE
# define sspdbg(x...)
# define sspvdbg(x...)
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: pic32mx_sspinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the Sure PIC32MX board.
*
************************************************************************************/
void weak_function pic32mx_sspinitialize(void)
{
/* Configure the SPI chip select GPIOs */
#warning "Missing logic"
}
/************************************************************************************
* Name: pic32mx_spiNselect, pic32mx_spiNstatus, and pic32mx_spiNcmddata
*
* Description:
* These external functions must be provided by board-specific logic. They are
* implementations of the select, status, and cmddata methods of the SPI interface
* defined by struct spi_ops_s (see include/nuttx/spi.h). All other methods
* including up_spiinitialize()) are provided by common PIC32MX logic. To use
* this common SPI logic on your board:
*
* 1. Provide logic in pic32mx_boardinitialize() to configure SPI/SSP chip select
* pins.
* 2. Provide pic32mx_spiNselect() and pic32mx_spiNstatus() functions
* in your board-specific logic. These functions will perform chip selection
* and status operations using GPIOs in the way your board is configured.
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
* pic32mx_spiNcmddata() functions in your board-specific logic. These
* functions will perform cmd/data selection operations using GPIOs in the way
* your board is configured.
* 3. Add a call to up_spiinitialize() in your low level application
* initialization logic
* 4. The handle returned by up_spiinitialize() 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).
*
************************************************************************************/
struct spi_dev_s;
enum spi_dev_e;
#ifdef CONFIG_PIC32MX_SPI1
void pic32mx_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
#warning "Missing logic"
}
uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
sspdbg("Returning nothing\n");
#warning "Missing logic"
return 0;
}
#ifdef CONFIG_SPI_CMDDATA
int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
#warning "Missing logic"
return 0;
}
#endif
#endif
#ifdef CONFIG_PIC31MX_SPI1
void pic31mx_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
#warning "Missing logic"
}
uint8_t pic31mx_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
sspdbg("Returning nothing\n");
#warning "Missing logic"
return 0;
}
#ifdef CONFIG_SPI_CMDDATA
int pic31mx_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
#warning "Missing logic"
return 0;
}
#endif
#endif
#ifdef CONFIG_PIC31MX_SPI3
void pic32mx_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
#warning "Missing logic"
}
uint8_t pic32mx_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
sspdbg("Returning nothing\n");
#warning "Missing logic"
return 0;
}
#ifdef CONFIG_SPI_CMDDATA
int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
#warning "Missing logic"
return 0;
}
#endif
#endif
#ifdef CONFIG_PIC32MX_SPI4
void pic32mx_spi4select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
#warning "Missing logic"
}
uint8_t pic32mx_spi4status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
sspdbg("Returning nothing\n");
#warning "Missing logic"
return 0;
}
#ifdef CONFIG_SPI_CMDDATA
int pic32mx_spi4cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
#warning "Missing logic"
return 0;
}
#endif
#endif
#endif /* CONFIG_PIC32MX_SPI1..4 */
@@ -0,0 +1,163 @@
/************************************************************************************
* configs/pic32-starterkit/src/up_usbdev.c
* arch/arm/src/board/up_usbdev.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 <debug.h>
#include <nuttx/usb/usbdev.h>
#include "pic32mx-internal.h"
#include "starterkit_internal.h"
#if defined(CONFIG_PIC32MX_USBDEV)
/************************************************************************************
* Definitions
************************************************************************************/
/*
* PIN NAME SIGNAL NOTES
* ---- ------------------------------- -------------- ------------------------------
* 20 VBUSON/C1IN+/AN5/CN7/RB5 VBUSON To USB VBUS circuitry
* 43 C2IN+/AN3/CN5/RB3 USB_PGOOD Power good (low if bad)
*/
#define GPIO_USB_VBUSON (GPIO_INPUT|GPIO_PORTB|GPIO_PIN5)
#define GPIO_USB_PGOOD (GPIO_INPUT|GPIO_PORTB|GPIO_PIN3)
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: pic32mx_usbdevinitialize
*
* Description:
* Called to configure the mini-A/B J5 on the PIC32 Ethernet Starter Kit for the
* USB device
*
************************************************************************************/
void weak_function pic32mx_usbdevinitialize(void)
{
/* Connect the PHY to the USB mini-B port. Order and timing matter! */
pic32mx_configgpio(GPIO_USB_PGOOD);
/* Notes from the Sure Electronics sample code:
*
* "The USB specifications require that USB peripheral devices must never source
* current onto the Vbus pin. Additionally, USB peripherals should not source
* current on D+ or D- when the host/hub is not actively powering the Vbus line.
* When designing a self powered (as opposed to bus powered) USB peripheral
* device, the firmware should make sure not to turn on the USB module and D+
* or D- pull up resistor unless Vbus is actively powered. Therefore, the
* firmware needs some means to detect when Vbus is being powered by the host.
* A 5V tolerant I/O pin can be connected to Vbus (through a resistor), and
* can be used to detect when Vbus is high (host actively powering), or low
* (host is shut down or otherwise not supplying power). The USB firmware
* can then periodically poll this I/O pin to know when it is okay to turn on
* the USB module/D+/D- pull up resistor. When designing a purely bus powered
* peripheral device, it is not possible to source current on D+ or D- when the
* host is not actively providing power on Vbus. Therefore, implementing this
* bus sense feature is optional. ..."
*/
#ifdef CONFIG_USBHOST
// pic32mx_configgpio(GPIO_USB_VBUSON);
#endif
/* "If the host PC sends a GetStatus (device) request, the firmware must respond
* and let the host know if the USB peripheral device is currently bus powered
* or self powered. See chapter 9 in the official USB specifications for details
* regarding this request. If the peripheral device is capable of being both
* self and bus powered, it should not return a hard coded value for this request.
* Instead, firmware should check if it is currently self or bus powered, and
* respond accordingly. If the hardware has been configured like demonstrated
* on the PICDEM FS USB Demo Board, an I/O pin can be polled to determine the
* currently selected power source. ..."
*/
#ifdef CONFIG_USB_PWRSENSE
// pic32mx_configgpio(GPIO_USB_PWRSENSE);
#endif
}
/************************************************************************************
* Name: pic32mx_usbpullup
*
* Description:
* If USB is supported and the board supports a pullup via GPIO (for USB
* software connect and disconnect), then the board software must provide
* stm32_pullup. See include/nuttx/usb/usbdev.h for additional description
* of this method. Alternatively, if no pull-up GPIO the following EXTERN
* can be redefined to be NULL.
*
************************************************************************************/
int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable)
{
/* The PIC32 Ethernet Starter Kit does not have a USB pull-up */
return OK;
}
/************************************************************************************
* Name: pic32mx_usbsuspend
*
* Description:
* Board logic must provide the stm32_usbsuspend logic if the USBDEV driver
* is used. This function is called whenever the USB enters or leaves
* suspend mode. This is an opportunity for the board logic to shutdown
* clocks, power, etc. while the USB is suspended.
*
************************************************************************************/
void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume)
{
/* Do nothing */
}
#endif /* CONFIG_PIC32MX_USBDEV */
@@ -0,0 +1,95 @@
/****************************************************************************
* configs/pic32-starterkit/src/up_usbmsc.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 "starterkit_internal.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lib_lowprintf(__VA_ARGS__)
# define msgflush()
# else
# define message(...) printf(__VA_ARGS__)
# define msgflush() fflush(stdout)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lib_lowprintf
# define msgflush()
# else
# define message printf
# define msgflush() fflush(stdout)
# endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: usbmsc_archinitialize
*
* Description:
* Perform architecture specific initialization as needed to establish
* the mass storage device that will be exported by the USB MSC device.
*
****************************************************************************/
int usbmsc_archinitialize(void)
{
/* If examples/usbmsc is built as an NSH command, then SD slot should
* already have been initized in nsh_archinitialize() (see up_nsh.c). In
* this case, there is nothing further to be done here.
*/
#ifndef CONFIG_EXAMPLES_USBMSC_BUILTIN
# warning "Missing Logic"
#endif /* CONFIG_EXAMPLES_USBMSC_BUILTIN */
return 0;
}
@@ -0,0 +1,105 @@
/************************************************************************************
* configs/pic32-starterkit/src/up_usbterm.c
* arch/arm/src/board/up_usbterm.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 <debug.h>
#include <nuttx/usb/usbdev.h>
#include "pic32mx-internal.h"
#include "starterkit_internal.h"
#if defined(CONFIG_PIC32MX_USBDEV) && defined(CONFIG_EXAMPLES_USBTERM_DEVINIT)
/************************************************************************************
* Definitions
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/****************************************************************************
* Name:
*
* Description:
* If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will
* call this user provided function as part of its initialization.
*
****************************************************************************/
int usbterm_devinit(void)
{
/* The PIO32 Starter Kit has no way to know when the USB is connected. So
* we will fake it and tell the USB driver that the USB is connected now.
*
* If examples/usbterm is built as an NSH built-in application, then
* pic32mx_usbattach() will be called in nsh_archinitialize().
*/
#ifndef CONFIG_EXAMPLES_USBTERM_BUILTIN
pic32mx_usbattach();
#endif
return OK;
}
/****************************************************************************
* Name:
*
* Description:
* If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will
* call this user provided function as part of its termination sequence.
*
****************************************************************************/
void usbterm_devuninit(void)
{
/* Tell the USB driver that the USB is no longer connected */
pic32mx_usbdetach();
}
#endif /* CONFIG_PIC32MX_USBDEV && CONFIG_EXAMPLES_USBTERM_DEVINIT */