summaryrefslogtreecommitdiff
path: root/apps/nshlib/nsh_usbdev.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-06 20:21:57 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-06 20:21:57 +0000
commit2cb26d0787b41ae1dc7607ef11ac11047491d7dc (patch)
tree0bfa100d6337879837dd6abf9612a0a7f889129b /apps/nshlib/nsh_usbdev.c
parent829c1351e2be18265cd8ea8c481eec674192a6d5 (diff)
downloadnuttx-2cb26d0787b41ae1dc7607ef11ac11047491d7dc.tar.gz
nuttx-2cb26d0787b41ae1dc7607ef11ac11047491d7dc.tar.bz2
nuttx-2cb26d0787b41ae1dc7607ef11ac11047491d7dc.zip
Add support for use of a USB serial device to provide NSH console I/O. Verified on the Sure PIPIC32MX board
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4458 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/nshlib/nsh_usbdev.c')
-rw-r--r--apps/nshlib/nsh_usbdev.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/apps/nshlib/nsh_usbdev.c b/apps/nshlib/nsh_usbdev.c
index c8115bfc7..a784c6b77 100644
--- a/apps/nshlib/nsh_usbdev.c
+++ b/apps/nshlib/nsh_usbdev.c
@@ -39,7 +39,19 @@
#include <nuttx/config.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <assert.h>
+
+#ifdef CONFIG_CDCACM
+# include <nuttx/usb/cdcacm.h>
+#endif
+
+#ifdef CONFIG_CDCACM
+# include <nuttx/usb/pl2303.h>
+#endif
#include "nsh.h"
@@ -80,8 +92,8 @@
#ifdef HAVE_USB_CONSOLE
int nsh_usbconsole(void)
{
- int errval;
int fd;
+ int ret;
/* Don't start the NSH console until the console device is ready. Chances
* are, we get here with no functional console. The USB console will not
@@ -89,6 +101,15 @@ int nsh_usbconsole(void)
* host-side application opens the connection.
*/
+ /* Initialize the USB serial driver */
+
+#ifdef CONFIG_CDCACM
+ ret = cdcacm_initialize(0, NULL);
+#else
+ ret = usbdev_serialinitialize(0);
+#endif
+ DEBUGASSERT(ret == OK);
+
/* Make sure the stdin, stdout, and stderr are closed */
(void)fclose(stdin);
@@ -131,7 +152,7 @@ int nsh_usbconsole(void)
}
/* fdopen to get the stdin, stdout and stderr streams. The following logic depends
- * on the fact that the library* layer will allocate FILEs in order. And since
+ * on the fact that the library layer will allocate FILEs in order. And since
* we closed stdin, stdout, and stderr above, that is what we should get.
*
* fd = 0 is stdin (read-only)