diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-12-30 14:54:43 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-12-30 14:54:43 +0000 |
commit | b3aa316f2e4affe5e17c50a178e6c25c08be30c5 (patch) | |
tree | 5049d401a207143ebb88ae56dc470424168093c5 /apps/examples/usbterm | |
parent | e20ee86ffd4d06095641bcecd3dfb0f91552eb89 (diff) | |
download | nuttx-b3aa316f2e4affe5e17c50a178e6c25c08be30c5.tar.gz nuttx-b3aa316f2e4affe5e17c50a178e6c25c08be30c5.tar.bz2 nuttx-b3aa316f2e4affe5e17c50a178e6c25c08be30c5.zip |
STM32 GPIO fix; Fixes for PIC32 USB term example
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4241 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/usbterm')
-rw-r--r-- | apps/examples/usbterm/usbterm.h | 25 | ||||
-rw-r--r-- | apps/examples/usbterm/usbterm_main.c | 26 |
2 files changed, 47 insertions, 4 deletions
diff --git a/apps/examples/usbterm/usbterm.h b/apps/examples/usbterm/usbterm.h index 97ccf5405..241db610a 100644 --- a/apps/examples/usbterm/usbterm.h +++ b/apps/examples/usbterm/usbterm.h @@ -144,5 +144,30 @@ extern struct usbterm_globals_s g_usbterm; /**************************************************************************** * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: + * + * Description: + * If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will + * call this user provided function as part of its initialization. + * + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_USBTERM_DEVINIT +int usbterm_devinit(void); +#endif + +/**************************************************************************** + * Name: + * + * Description: + * If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will + * call this user provided function as part of its termination sequeunce. + * + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_USBTERM_DEVINIT +void usbterm_devuninit(void); +#endif #endif /* __APPS_EXAMPLES_USBTERM_USBTERM_H */ diff --git a/apps/examples/usbterm/usbterm_main.c b/apps/examples/usbterm/usbterm_main.c index 092fd7a6f..cb8435788 100644 --- a/apps/examples/usbterm/usbterm_main.c +++ b/apps/examples/usbterm/usbterm_main.c @@ -2,7 +2,7 @@ * examples/usbterm/usbterm_main.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -167,7 +167,7 @@ FAR void *usbterm_listener(FAR void *parameter) ****************************************************************************/ #ifdef CONFIG_EXAMPLES_USBTERM_BUILTIN -# define MAIN_NAME term_main +# define MAIN_NAME usbterm_main # define MAIN_STRING "usbterm_main: " #else # define MAIN_NAME user_start @@ -179,6 +179,20 @@ int MAIN_NAME(int argc, char *argv[]) pthread_attr_t attr; int ret; + /* Initialization of the USB hardware may be performed by logic external to + * this test. + */ + +#ifdef CONFIG_EXAMPLES_USBTERM_DEVINIT + message(MAIN_STRING "Performing external device initialization\n"); + ret = usbterm_devinit(); + if (ret != OK) + { + message(MAIN_STRING "usbterm_devinit failed: %d\n", ret); + goto errout; + } +#endif + /* Initialize the USB serial driver */ message(MAIN_STRING "Registering USB serial driver\n"); @@ -190,7 +204,7 @@ int MAIN_NAME(int argc, char *argv[]) if (ret < 0) { message(MAIN_STRING "ERROR: Failed to create the USB serial device: %d\n", -ret); - goto errout; + goto errout_with_devinit; } message(MAIN_STRING "Successfully registered the serial driver\n"); @@ -231,7 +245,7 @@ int MAIN_NAME(int argc, char *argv[]) { /* Give up on other errors */ - goto errout; + goto errout_with_devinit; } } @@ -308,7 +322,11 @@ errout_with_streams: fclose(g_usbterm.instream); errout_with_outstream: fclose(g_usbterm.outstream); +errout_with_devinit: +#ifdef CONFIG_EXAMPLES_USBTERM_DEVINIT + usbterm_devuninit(); errout: +#endif message(MAIN_STRING " Aborting\n"); return 1; } |