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:
patacongo
2011-12-30 14:54:43 +00:00
parent 79e67d26b3
commit 2901574aff
13 changed files with 342 additions and 42 deletions
+3
View File
@@ -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
/************************************************************************************
+37 -5
View File
@@ -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 */
+103
View File
@@ -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 */