From 2de4db2fcb1fa9eb604512ea4df1b325d63dd747 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 30 Dec 2011 14:54:43 +0000 Subject: [PATCH] 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 --- ChangeLog | 16 ++-- arch/arm/src/stm32/stm32_gpio.c | 20 ++-- arch/arm/src/stm32/stm32_start.c | 3 - arch/mips/src/pic32mx/pic32mx-usbdev.c | 22 ++--- configs/sure-pic32mx/nsh/appconfig | 3 + configs/sure-pic32mx/nsh/defconfig | 112 +++++++++++++++++++++++ configs/sure-pic32mx/src/Makefile | 3 + configs/sure-pic32mx/src/sure-internal.h | 4 +- configs/sure-pic32mx/src/up_usbdev.c | 42 ++++++++- configs/sure-pic32mx/src/up_usbterm.c | 103 +++++++++++++++++++++ 10 files changed, 290 insertions(+), 38 deletions(-) create mode 100644 configs/sure-pic32mx/src/up_usbterm.c diff --git a/ChangeLog b/ChangeLog index 42f87a8464..895aa6d8b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2286,24 +2286,26 @@ * drivers/mtd/mp25x.c: Add ability to use different SPI modes and different manufacturers codes. Fix a error in the wait for not busy (submitted by Mohammad Elwakeel. - * arch/arm/src/stm32/stm32_can.c. Add a low-level STM32 CAN driver. (Initial + * arch/arm/src/stm32/stm32_can.c: Add a low-level STM32 CAN driver. (Initial check is incomplete). Add loopback support to the driver. - * arch/arm/src/stm32/stm32_adc.c. The ADC is now functional. A more complete + * arch/arm/src/stm32/stm32_adc.c: The ADC is now functional. A more complete driver would require DMA support. I have some questions still about the accuracy of the timer-driven sampling. - * configs/sure-pic32mx/nsh. The PIC32 port is (finally) functional. Add an + * configs/sure-pic32mx/nsh: The PIC32 port is (finally) functional. Add an NSH configuration for the Sure PIC32MX board. * configs/sure-pic32mx/*/defconfig. Calibrated all PIC32 delay loops. - * configs/pcblogic-pic32mx/nsh. Add an NSH configuration for the PCBLogic + * configs/pcblogic-pic32mx/nsh: Add an NSH configuration for the PCBLogic PIC32 board. * Both PIC32 OS test and NSH configurations have now been verified. 6.14 2012-xx-xx Gregory Nutt - * tools/Makefile.txport, mkexport.sh, and configure.sh. Changes submitted + * tools/Makefile.txport, mkexport.sh, and configure.sh: Changes submitted by Mike Smith to support configuration and 'make export' on MAC OS. - * arch/arm/src/stm32/stm32_gpio.c. Disabled interrupts while configuring + * arch/arm/src/stm32/stm32_gpio.c: Disabled interrupts while configuring GPIO pins so that we have exclusive access to the GPIO configuration registers. - * arch/mips/src/pic32mx/pic32mx_usbdev.c. Add a USB device-side driver + * arch/mips/src/pic32mx/pic32mx_usbdev.c: Add a USB device-side driver for the PIC32MX family. + * arch/arm/src/stm32/stm32_gpio.c: Correct an error in some of the GPIO + initialization logic. Fix submitted by Mike Smith. diff --git a/arch/arm/src/stm32/stm32_gpio.c b/arch/arm/src/stm32/stm32_gpio.c index 6787c57778..c514ff954e 100644 --- a/arch/arm/src/stm32/stm32_gpio.c +++ b/arch/arm/src/stm32/stm32_gpio.c @@ -563,9 +563,17 @@ int stm32_configgpio(uint32_t cfgset) putreg32(regval, base + STM32_GPIO_OTYPER_OFFSET); - /* If it is an input pin, hould it configured as an EXTI interrupt? */ + /* If it is an output... set the pin to the correct initial state. */ - if ((cfgset & GPIO_EXTI) != 0) + if (pinmode == GPIO_MODER_OUTPUT) + { + bool value = ((cfgset & GPIO_OUTPUT_SET) != 0); + stm32_gpiowrite(cfgset, value); + } + + /* Otherwise, it is an input pin. Should it configured as an EXTI interrupt? */ + + else if ((cfgset & GPIO_EXTI) != 0) { /* "In STM32 F1 the selection of the EXTI line source is performed through * the EXTIx bits in the AFIO_EXTICRx registers, while in F2 series this @@ -590,14 +598,6 @@ int stm32_configgpio(uint32_t cfgset) putreg32(regval, regaddr); } - - /* If it is an output... set the pin to the correct initial state. */ - - else if (pinmode == GPIO_MODER_OUTPUT) - { - bool value = ((cfgset & GPIO_OUTPUT_SET) != 0); - stm32_gpiowrite(cfgset, value); - } irqrestore(flags); return OK; diff --git a/arch/arm/src/stm32/stm32_start.c b/arch/arm/src/stm32/stm32_start.c index 7ac7ac1f9e..5434e3429a 100644 --- a/arch/arm/src/stm32/stm32_start.c +++ b/arch/arm/src/stm32/stm32_start.c @@ -78,9 +78,6 @@ * Configure the FPU. The the MCU has an FPU, then enable full access * to coprocessors CP10 and CP11. * - * This is implemented as a macro because the stack has not yet been - * initialized. - * ****************************************************************************/ #ifdef CONFIG_ARCH_FPU diff --git a/arch/mips/src/pic32mx/pic32mx-usbdev.c b/arch/mips/src/pic32mx/pic32mx-usbdev.c index 316b9676bf..7b9ac0eefb 100644 --- a/arch/mips/src/pic32mx/pic32mx-usbdev.c +++ b/arch/mips/src/pic32mx/pic32mx-usbdev.c @@ -919,7 +919,7 @@ static int pic32mx_rdcomplete(struct pic32mx_usbdev_s *priv, * RX will be marked valid when the data phase completes. */ - usbtrace(TRACE_COMPLETE(epno), privreq->req.xfrd); + usbtrace(TRACE_COMPLETE(USB_EPNO(privep->ep.eplog)), privreq->req.xfrd); pic32mx_reqcomplete(privep, OK); } @@ -1141,7 +1141,7 @@ static void pic32mx_ep0stall(struct pic32mx_usbdev_s *priv) uint16_t status = (USB_BDT_UOWN| USB_BDT_DATA0 | USB_BDT_DTS | USB_BDT_BSTALL); - regdbg("EP0 BDT OUT {%08x, %08x}\n", status, ep0->bdtout->status->addr); + regdbg("EP0 BDT OUT {%08x, %08x}\n", status, ep0->bdtout->addr); ep0->bdtout->status = status; } @@ -1172,7 +1172,7 @@ static void pic32mx_eptransfer(struct pic32mx_usbdev_s *priv, uint8_t epno, { /* OUT: host-to-device */ - usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EPOUTDONE), epr); + usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EPOUTDONE), status); /* Handle read requests. First check if a read request is available to * accept the host data. @@ -1197,7 +1197,7 @@ static void pic32mx_eptransfer(struct pic32mx_usbdev_s *priv, uint8_t epno, { /* IN: device-to-host */ - usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EPINDONE), epr); + usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EPINDONE), status); /* Handle write requests */ @@ -1286,7 +1286,7 @@ static void pic32mx_ep0done(struct pic32mx_usbdev_s *priv, bdtout->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl); - regdbg("EP0 BDT OUT (Next) {%08x, %08x}\n", status, ep0->btdnext->addr); + regdbg("EP0 BDT OUT (Next) {%08x, %08x}\n", status, bdtout->addr); bdtout->status = status; @@ -1297,7 +1297,7 @@ static void pic32mx_ep0done(struct pic32mx_usbdev_s *priv, btdnext->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl); - regdbg("EP0 BDT OUT {%08x, %08x}\n", status, ep0->bdtout->addr); + regdbg("EP0 BDT OUT {%08x, %08x}\n", status, btdnext->addr); btdnext->status = status; #endif @@ -1310,7 +1310,7 @@ static void pic32mx_ep0done(struct pic32mx_usbdev_s *priv, ep0->bdtin->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl); - regdbg("EP0 BDT IN {%08x, %08x}\n", status, p0->bdtin->addr); + regdbg("EP0 BDT IN {%08x, %08x}\n", status, ep0->bdtin->addr); ep0->bdtin->status = status; } @@ -2106,14 +2106,14 @@ static void pic32mx_ep0transfer(struct pic32mx_usbdev_s *priv, uint16_t status) /* Handle the control OUT transfer */ - usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EP0SETUPDONE), epr); + usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EP0SETUPDONE), bdt->status); pic32mx_ep0setup(priv); } else { /* Handle the data OUT transfer */ - usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EP0OUTDONE), epr); + usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EP0OUTDONE), status); pic32mx_ep0out(priv); } } @@ -2122,7 +2122,7 @@ static void pic32mx_ep0transfer(struct pic32mx_usbdev_s *priv, uint16_t status) else /* if ((status & USB_STAT_DIR) == USB_STAT_DIR_IN) */ { - usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EP0INDONE), epr); + usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_EP0INDONE), status); /* Handle the IN transfer */ @@ -3493,6 +3493,7 @@ static void pic32mx_hwreset(struct pic32mx_usbdev_s *priv) /* Initialize EP0 as a Ctrl EP */ pic32mx_putreg(PIC32MX_EP_CONTROL, PIC32MX_USB_EP0); + regdbg("PIC32MX_USB_EP0: %04x\n", getreg16(PIC32MX_USB_EP0)); /* Flush any pending transactions */ @@ -3514,7 +3515,6 @@ static void pic32mx_hwreset(struct pic32mx_usbdev_s *priv) /* Indicate that we are now in the detached state */ priv->devstate = DEVSTATE_DETACHED; - regdbg("PIC32MX_USB_EP%d: %04x\n", epno, getreg16(PIC32MX_USB_EP(epno))); } /**************************************************************************** diff --git a/configs/sure-pic32mx/nsh/appconfig b/configs/sure-pic32mx/nsh/appconfig index 0cff7b1d3d..be2d77112f 100644 --- a/configs/sure-pic32mx/nsh/appconfig +++ b/configs/sure-pic32mx/nsh/appconfig @@ -58,3 +58,6 @@ ifeq ($(CONFIG_CAN),y) CONFIGURED_APPS += examples/can endif +ifeq ($(CONFIG_PIC32MX_USBDEV),y) +CONFIGURED_APPS += examples/usbterm +endif diff --git a/configs/sure-pic32mx/nsh/defconfig b/configs/sure-pic32mx/nsh/defconfig index 70d4017cf9..3f2d9edcbf 100644 --- a/configs/sure-pic32mx/nsh/defconfig +++ b/configs/sure-pic32mx/nsh/defconfig @@ -324,10 +324,14 @@ CONFIG_HAVE_LIBM=n # CONFIG_SCHED_ATEXIT - Enabled the atexit() API # #CONFIG_APPS_DIR= + CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_SYMBOLS=n CONFIG_DEBUG_SCHED=n +CONFIG_DEBUG_USB=n +CONFIG_PIC32MX_USBDEV_REGDEBUG=n + CONFIG_HAVE_CXX=n CONFIG_MM_REGIONS=1 CONFIG_ARCH_LOWPUTC=y @@ -686,6 +690,75 @@ CONFIG_USBSER_PRODUCTSTR="USBdev Serial" CONFIG_USBSER_RXBUFSIZE=512 CONFIG_USBSER_TXBUFSIZE=512 +# +# USB serial device class driver (Standard CDC ACM class) +# +# CONFIG_CDCSER +# Enable compilation of the USB serial driver +# CONFIG_CDCSER_EP0MAXPACKET +# Endpoint 0 max packet size. Default 64 +# CONFIG_CDCSER_EPINTIN +# The logical 7-bit address of a hardware endpoint that supports +# interrupt IN operation. Default 2. +# CONFIG_CDCSER_EPINTIN_FSSIZE +# Max package size for the interrupt IN endpoint if full speed mode. +# Default 64. +# CONFIG_CDCSER_EPINTIN_HSSIZE +# Max package size for the interrupt IN endpoint if high speed mode. +# Default 64 +# CONFIG_CDCSER_EPBULKOUT +# The logical 7-bit address of a hardware endpoint that supports +# bulk OUT operation +# CONFIG_CDCSER_EPBULKOUT_FSSIZE +# Max package size for the bulk OUT endpoint if full speed mode. +# Default 64. +# CONFIG_CDCSER_EPBULKOUT_HSSIZE +# Max package size for the bulk OUT endpoint if high speed mode. +# Default 512. +# CONFIG_CDCSER_EPBULKIN +# The logical 7-bit address of a hardware endpoint that supports +# bulk IN operation +# CONFIG_CDCSER_EPBULKIN_FSSIZE +# Max package size for the bulk IN endpoint if full speed mode. +# Default 64. +# CONFIG_CDCSER_EPBULKIN_HSSIZE +# Max package size for the bulk IN endpoint if high speed mode. +# Default 512. +# CONFIG_CDCSER_NWRREQS and CONFIG_CDCSER_NRDREQS +# The number of write/read requests that can be in flight. +# Default 256. +# CONFIG_CDCSER_VENDORID and CONFIG_CDCSER_VENDORSTR +# The vendor ID code/string. Default 0x0525 and "NuttX" +# 0x0525 is the Netchip vendor and should not be used in any +# products. This default VID was selected for compatibility with +# the Linux CDC ACM default VID. +# CONFIG_CDCSER_PRODUCTID and CONFIG_CDCSER_PRODUCTSTR +# The product ID code/string. Default 0xara7 and "CDC/ACM Serial" +# 0xa4a7 was selected for compatibility with the Linux CDC ACM +# default PID. +# CONFIG_CDCSER_RXBUFSIZE and CONFIG_CDCSER_TXBUFSIZE +# Size of the serial receive/transmit buffers. Default 256. +# +CONFIG_CDCSER=n +#CONFIG_CDCSER_EP0MAXPACKET +#CONFIG_CDCSER_EPINTIN +#CONFIG_CDCSER_EPINTIN_FSSIZE +#CONFIG_CDCSER_EPINTIN_HSSIZE +#CONFIG_CDCSER_EPBULKOUT +#CONFIG_CDCSER_EPBULKOUT_FSSIZE +#CONFIG_CDCSER_EPBULKOUT_HSSIZE +#CONFIG_CDCSER_EPBULKIN +#CONFIG_CDCSER_EPBULKIN_FSSIZE +#CONFIG_CDCSER_EPBULKIN_HSSIZE +#CONFIG_CDCSER_NWRREQS +#CONFIG_CDCSER_NRDREQS +#CONFIG_CDCSER_VENDORID +#CONFIG_CDCSER_VENDORSTR +#CONFIG_CDCSER_PRODUCTID +#CONFIG_CDCSER_PRODUCTSTR +#CONFIG_CDCSER_RXBUFSIZE +#CONFIG_CDCSER_TXBUFSIZE + # # USB Storage Device Configuration # @@ -901,6 +974,45 @@ CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n +# +# Settings for examples/usbterm +# +# CONFIG_EXAMPLES_USBTERM_BUILTIN - Build the usbterm example as an NSH +# built-in command. NOTE: This is not fully functional as of this +# writing.. It should work, but there is no mechanism in place yet +# to exit the USB terminal program and return to NSH. +# CONFIG_EXAMPLES_USBTERM_DEVINIT - If defined, then the example will +# call a user provided function as part of its initialization: +# int usbterm_devinit(void); +# And another user provided function at termination: +# void usbterm_devuninit(void); +# CONFIG_EXAMPLES_USBTERM_BUFLEN - The size of the input and output +# buffers used for receiving data. Default 256 bytes. +# +# If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB, or +# CONFIG_USBDEV_TRACE), then the example code will also manage the USB trace +# output. The amount of trace output can be controlled using: +# +# CONFIG_EXAMPLES_USBTERM_TRACEINIT +# Show initialization events +# CONFIG_EXAMPLES_USBTERM_TRACECLASS +# Show class driver events +# CONFIG_EXAMPLES_USBTERM_TRACETRANSFERS +# Show data transfer events +# CONFIG_EXAMPLES_USBTERM_TRACECONTROLLER +# Show controller events +# CONFIG_EXAMPLES_USBTERM_TRACEINTERRUPTS +# Show interrupt-related events. +# +CONFIG_EXAMPLES_USBTERM_BUILTIN=y +CONFIG_EXAMPLES_USBTERM_DEVINIT=y +#CONFIG_EXAMPLES_USBTERM_BUFLEN +CONFIG_EXAMPLES_USBTERM_TRACEINIT=n +CONFIG_EXAMPLES_USBTERM_TRACECLASS=n +CONFIG_EXAMPLES_USBTERM_TRACETRANSFERS=n +CONFIG_EXAMPLES_USBTERM_TRACECONTROLLER=n +CONFIG_EXAMPLES_USBTERM_TRACEINTERRUPTS=n + # # Stack and heap information # diff --git a/configs/sure-pic32mx/src/Makefile b/configs/sure-pic32mx/src/Makefile index fa8dc47cf7..22f03d2bce 100644 --- a/configs/sure-pic32mx/src/Makefile +++ b/configs/sure-pic32mx/src/Makefile @@ -50,6 +50,9 @@ endif 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) diff --git a/configs/sure-pic32mx/src/sure-internal.h b/configs/sure-pic32mx/src/sure-internal.h index 826c05efab..34e881f411 100644 --- a/configs/sure-pic32mx/src/sure-internal.h +++ b/configs/sure-pic32mx/src/sure-internal.h @@ -90,7 +90,7 @@ EXTERN void weak_function pic32mx_spiinitialize(void); #endif /************************************************************************************ - * Name: pic32mx_usdbinitialize + * Name: pic32mx_usbdevinitialize * * Description: * Called to configure the mini-B PHY on the Sure PIC32MX board for the USB device @@ -98,7 +98,7 @@ EXTERN void weak_function pic32mx_spiinitialize(void); ************************************************************************************/ #if defined(CONFIG_PIC32MX_USBDEV) -EXTERN void weak_function pic32mx_usdbinitialize(void); +EXTERN void weak_function pic32mx_usbdevinitialize(void); #endif /************************************************************************************ diff --git a/configs/sure-pic32mx/src/up_usbdev.c b/configs/sure-pic32mx/src/up_usbdev.c index 5fb12b5377..6cc56406a7 100644 --- a/configs/sure-pic32mx/src/up_usbdev.c +++ b/configs/sure-pic32mx/src/up_usbdev.c @@ -43,15 +43,11 @@ #include -#include #include #include -#include -#include +#include -#include "up_arch.h" -#include "chip.h" #include "pic32mx-internal.h" #include "sure-internal.h" @@ -133,4 +129,40 @@ void weak_function pic32mx_usbdevinitialize(void) // 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 Sure PIC32MX 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 */ diff --git a/configs/sure-pic32mx/src/up_usbterm.c b/configs/sure-pic32mx/src/up_usbterm.c new file mode 100644 index 0000000000..2b307dbb3c --- /dev/null +++ b/configs/sure-pic32mx/src/up_usbterm.c @@ -0,0 +1,103 @@ +/************************************************************************************ + * configs/sure-pic32mx/src/up_usbdev.c + * arch/arm/src/board/up_usbdev.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * References: + * - Sample code and schematics provided with the Sure Electronics PIC32 board. + * + * 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 + +#include +#include + +#include + +#include "pic32mx-internal.h" +#include "sure-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 Sure board 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; +} + +/**************************************************************************** + * Name: + * + * Description: + * If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will + * call this user provided function as part of its termination sequeunce. + * + ****************************************************************************/ + +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 */