summaryrefslogtreecommitdiff
path: root/nuttx/configs/sam4s-xplained-pro/src
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-04-21 18:16:44 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-04-21 18:16:44 -0600
commite9061d44dd8a3b3e359971fe5ba67e50f7889d30 (patch)
tree0f73827ceb92f869e89b256cea47914b4bc741fe /nuttx/configs/sam4s-xplained-pro/src
parent02ecd1566eca23face3c4edc3a4c71355d8725d6 (diff)
downloadnuttx-e9061d44dd8a3b3e359971fe5ba67e50f7889d30.tar.gz
nuttx-e9061d44dd8a3b3e359971fe5ba67e50f7889d30.tar.bz2
nuttx-e9061d44dd8a3b3e359971fe5ba67e50f7889d30.zip
SAM4S Xplained: Add logic to autostart the USB monitor
Diffstat (limited to 'nuttx/configs/sam4s-xplained-pro/src')
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h23
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam_nsh.c31
2 files changed, 47 insertions, 7 deletions
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h b/nuttx/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h
index 9b3a2f713..9226f2d0d 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h
+++ b/nuttx/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h
@@ -57,6 +57,8 @@
#define HAVE_HSMCI 1
#define HAVE_PROC 1
+#define HAVE_USBDEV 1
+#undef HAVE_USBMONITOR
/* HSMCI */
/* Can't support MMC/SD if the card interface is not enabled */
@@ -71,7 +73,7 @@
/* Can't support MMC/SD features if mountpoints are disabled */
-if defined(HAVE_HSMCI) && defined(CONFIG_DISABLE_MOUNTPOINT)
+#if defined(HAVE_HSMCI) && defined(CONFIG_DISABLE_MOUNTPOINT)
# warning Mountpoints disabled. No MMC/SD support
# undef HAVE_HSMCI
#endif
@@ -88,6 +90,25 @@ if defined(HAVE_HSMCI) && defined(CONFIG_DISABLE_MOUNTPOINT)
# undef HAVE_HSMCI
#endif
+/* USB Device */
+/* CONFIG_SAM34_UDP and CONFIG_USBDEV must be defined, or there is no USB
+ * device.
+ */
+
+#if !defined(CONFIG_SAM34_UDP) || !defined(CONFIG_USBDEV)
+# undef HAVE_USBDEV
+#endif
+
+/* Check if we should enable the USB monitor before starting NSH */
+
+#ifndef HAVE_USBDEV
+# undef CONFIG_USBDEV_TRACE
+#endif
+
+#if !defined(CONFIG_SYSTEM_USBMONITOR) && !defined(CONFIG_USBDEV_TRACE)
+# undef HAVE_USBMONITOR
+#endif
+
/* There are four LEDs on board the SAM4S Xplained board, two of these can be
* controlled by software in the SAM4S:
*
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam_nsh.c b/nuttx/configs/sam4s-xplained-pro/src/sam_nsh.c
index 4c1909c19..ce4de7f57 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_nsh.c
+++ b/nuttx/configs/sam4s-xplained-pro/src/sam_nsh.c
@@ -1,6 +1,6 @@
/****************************************************************************
* config/sam4s-xplained-pro/src/sam_nsh.c
- *
+ *
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
@@ -50,6 +50,14 @@
# include <apps/usbmonitor.h>
#endif
+#ifdef CONFIG_CDCACM
+# include <nuttx/usb/cdcacm.h>
+#endif
+
+#ifdef CONFIG_PL2303
+# include <nuttx/usb/pl2303.h>
+#endif
+
#include "sam4s-xplained-pro.h"
/****************************************************************************
@@ -86,7 +94,7 @@
int nsh_archinitialize(void)
{
-#if (defined(HAVE_HSMCI) || defined (HAVE_PROC))
+#if defined(HAVE_HSMCI) || defined (HAVE_PROC) || defined(HAVE_USBMONITOR)
int ret;
#endif
@@ -94,7 +102,7 @@ int nsh_archinitialize(void)
#ifdef HAVE_HSMCI
/* Initialize the HSMCI driver */
-
+
ret = sam_hsmci_initialize();
if (ret < 0)
{
@@ -105,20 +113,31 @@ int nsh_archinitialize(void)
#ifdef HAVE_PROC
/* mount the proc filesystem */
-
+
ret = mount(NULL, "/proc", "procfs", 0, NULL);
if (ret < 0)
{
- fdbg("ERROR: Failed to mount the PROC filesystem: %d\n", errno);
+ message("ERROR: Failed to mount the PROC filesystem: %d\n", errno);
return ret;
}
#endif
+#ifdef HAVE_USBMONITOR
+ /* Start the USB Monitor */
+
+ ret = usbmonitor_start(0, NULL);
+ if (ret != OK)
+ {
+ message("nsh_archinitialize: Start USB monitor: %d\n", ret);
+ return ret;
+ }
+#endif
+
#warning "add automount config...."
ret = mount("/dev/mmcsd0", "/fat", "vfat", 0, NULL);
if (ret < 0)
{
- fdbg("ERROR: Failed to mount the FAT filesystem: %d\n", errno);
+ message("ERROR: Failed to mount the FAT filesystem: %d\n", errno);
return ret;
}