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 /nuttx/configs | |
parent | e20ee86ffd4d06095641bcecd3dfb0f91552eb89 (diff) | |
download | px4-nuttx-b3aa316f2e4affe5e17c50a178e6c25c08be30c5.tar.gz px4-nuttx-b3aa316f2e4affe5e17c50a178e6c25c08be30c5.tar.bz2 px4-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 'nuttx/configs')
-rw-r--r-- | nuttx/configs/sure-pic32mx/nsh/appconfig | 3 | ||||
-rw-r--r-- | nuttx/configs/sure-pic32mx/nsh/defconfig | 112 | ||||
-rw-r--r-- | nuttx/configs/sure-pic32mx/src/Makefile | 3 | ||||
-rw-r--r-- | nuttx/configs/sure-pic32mx/src/sure-internal.h | 4 | ||||
-rw-r--r-- | nuttx/configs/sure-pic32mx/src/up_usbdev.c | 42 | ||||
-rw-r--r-- | nuttx/configs/sure-pic32mx/src/up_usbterm.c | 103 |
6 files changed, 260 insertions, 7 deletions
diff --git a/nuttx/configs/sure-pic32mx/nsh/appconfig b/nuttx/configs/sure-pic32mx/nsh/appconfig index 0cff7b1d3..be2d77112 100644 --- a/nuttx/configs/sure-pic32mx/nsh/appconfig +++ b/nuttx/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/nuttx/configs/sure-pic32mx/nsh/defconfig b/nuttx/configs/sure-pic32mx/nsh/defconfig index 70d4017cf..3f2d9edcb 100644 --- a/nuttx/configs/sure-pic32mx/nsh/defconfig +++ b/nuttx/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 @@ -687,6 +691,75 @@ 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 # # CONFIG_USBSTRG @@ -902,6 +975,45 @@ 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 # # CONFIG_BOOT_RUNFROMFLASH - Some configurations support XIP diff --git a/nuttx/configs/sure-pic32mx/src/Makefile b/nuttx/configs/sure-pic32mx/src/Makefile index fa8dc47cf..22f03d2bc 100644 --- a/nuttx/configs/sure-pic32mx/src/Makefile +++ b/nuttx/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/nuttx/configs/sure-pic32mx/src/sure-internal.h b/nuttx/configs/sure-pic32mx/src/sure-internal.h index 826c05efa..34e881f41 100644 --- a/nuttx/configs/sure-pic32mx/src/sure-internal.h +++ b/nuttx/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/nuttx/configs/sure-pic32mx/src/up_usbdev.c b/nuttx/configs/sure-pic32mx/src/up_usbdev.c index 5fb12b537..6cc56406a 100644 --- a/nuttx/configs/sure-pic32mx/src/up_usbdev.c +++ b/nuttx/configs/sure-pic32mx/src/up_usbdev.c @@ -43,15 +43,11 @@ #include <nuttx/config.h> -#include <stdint.h> #include <stdbool.h> #include <debug.h> -#include <nuttx/spi.h> -#include <arch/board/board.h> +#include <nuttx/usb/usbdev.h> -#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/nuttx/configs/sure-pic32mx/src/up_usbterm.c b/nuttx/configs/sure-pic32mx/src/up_usbterm.c new file mode 100644 index 000000000..2b307dbb3 --- /dev/null +++ b/nuttx/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 <gnutt@nuttx.org> + * + * 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 <nuttx/config.h> + +#include <stdbool.h> +#include <debug.h> + +#include <nuttx/usb/usbdev.h> + +#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 */ |