forked from Archive/PX4-Autopilot
STM32 GPIO fix; Fixes for PIC32 USB term example
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4241 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
parent
79e67d26b3
commit
2901574aff
|
@ -1116,6 +1116,11 @@ examples/usbterm
|
|||
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.
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
|
||||
* 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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -58,3 +58,6 @@ ifeq ($(CONFIG_CAN),y)
|
|||
CONFIGURED_APPS += examples/can
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PIC32MX_USBDEV),y)
|
||||
CONFIGURED_APPS += examples/usbterm
|
||||
endif
|
||||
|
|
|
@ -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
|
||||
#
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
/************************************************************************************
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
Loading…
Reference in New Issue