A little STM32 logic in the PIC32 USB driver

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4235 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2011-12-28 19:40:37 +00:00
parent 617a772aff
commit 0acfb62c65
5 changed files with 618 additions and 932 deletions

View File

@ -389,8 +389,8 @@ static inline uint16_t
stm32_geteptxstatus(uint8_t epno); stm32_geteptxstatus(uint8_t epno);
static inline uint16_t static inline uint16_t
stm32_geteprxstatus(uint8_t epno); stm32_geteprxstatus(uint8_t epno);
static uint16_t stm32_eptxstalled(uint8_t epno); static bool stm32_eptxstalled(uint8_t epno);
static uint16_t stm32_eprxstalled(uint8_t epno); static bool stm32_eprxstalled(uint8_t epno);
static void stm32_setimask(struct stm32_usbdev_s *priv, uint16_t setbits, static void stm32_setimask(struct stm32_usbdev_s *priv, uint16_t setbits,
uint16_t clrbits); uint16_t clrbits);
@ -595,7 +595,7 @@ static void stm32_putreg(uint16_t val, uint32_t addr)
/* Write the value */ /* Write the value */
putreg32(val, addr); putreg16(val, addr);
} }
#endif #endif
@ -983,7 +983,7 @@ static void stm32_seteprxstatus(uint8_t epno, uint16_t state)
* Name: stm32_eptxstalled * Name: stm32_eptxstalled
****************************************************************************/ ****************************************************************************/
static inline uint16_t stm32_eptxstalled(uint8_t epno) static inline bool stm32_eptxstalled(uint8_t epno)
{ {
return (stm32_geteptxstatus(epno) == USB_EPR_STATTX_STALL); return (stm32_geteptxstatus(epno) == USB_EPR_STATTX_STALL);
} }
@ -992,7 +992,7 @@ static inline uint16_t stm32_eptxstalled(uint8_t epno)
* Name: stm32_eprxstalled * Name: stm32_eprxstalled
****************************************************************************/ ****************************************************************************/
static inline uint16_t stm32_eprxstalled(uint8_t epno) static inline bool stm32_eprxstalled(uint8_t epno)
{ {
return (stm32_geteprxstatus(epno) == USB_EPR_STATRX_STALL); return (stm32_geteprxstatus(epno) == USB_EPR_STATRX_STALL);
} }

View File

@ -551,32 +551,33 @@ EXTERN void pic32mx_dmadump(DMA_HANDLE handle, const struct pic32mx_dmaregs_s *r
#endif #endif
#endif #endif
/************************************************************************************ /****************************************************************************
* Name: pic32mx_usbpullup * Name: pic32mx_usbpullup
* *
* Description: * Description:
* If USB is supported and the board supports a pullup via GPIO (for USB software * If USB is supported and the board supports a pullup via GPIO (for USB
* connect and disconnect), then the board software must provide stm32_pullup. * software connect and disconnect), then the board software must provide
* See include/nuttx/usb/usbdev.h for additional description of this method. * stm32_pullup. See include/nuttx/usb/usbdev.h for additional description
* Alternatively, if no pull-up GPIO the following EXTERN can be redefined to be * of this method. Alternatively, if no pull-up GPIO the following EXTERN
* NULL. * can be redefined to be NULL.
* *
************************************************************************************/ ****************************************************************************/
#ifdef CONFIG_PIC32MX_USBDEV #ifdef CONFIG_PIC32MX_USBDEV
struct usbdev_s;
EXTERN int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable); EXTERN int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable);
#endif #endif
/************************************************************************************ /****************************************************************************
* Name: pic32mx_usbsuspend * Name: pic32mx_usbsuspend
* *
* Description: * Description:
* Board logic must provide the stm32_usbsuspend logic if the USBDEV driver is * Board logic must provide the stm32_usbsuspend logic if the USBDEV driver
* used. This function is called whenever the USB enters or leaves suspend mode. * is used. This function is called whenever the USB enters or leaves
* This is an opportunity for the board logic to shutdown clocks, power, etc. * suspend mode. This is an opportunity for the board logic to shutdown
* while the USB is suspended. * clocks, power, etc. while the USB is suspended.
* *
************************************************************************************/ ****************************************************************************/
#ifdef CONFIG_PIC32MX_USBDEV #ifdef CONFIG_PIC32MX_USBDEV
EXTERN void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume); EXTERN void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume);

File diff suppressed because it is too large Load Diff

View File

@ -209,6 +209,12 @@
#define USB_STAT_ENDPT_MASK (15 << USB_STAT_ENDPT_SHIFT) #define USB_STAT_ENDPT_MASK (15 << USB_STAT_ENDPT_SHIFT)
# define USB_STAT_ENDPT(n) ((n) << USB_STAT_ENDPT_SHIFT) /* Endpoint n, n=0..15 */ # define USB_STAT_ENDPT(n) ((n) << USB_STAT_ENDPT_SHIFT) /* Endpoint n, n=0..15 */
#define USB_STAT_PPBI_ODD USB_STAT_PPBI /* The last transaction was to the ODD BD bank */
#define USB_STAT_PPBI_EVEN 0 /* The last transaction was to the EVEN BD bank */
#define USB_STAT_DIR_IN USB_STAT_DIR /* Last transaction was a transmit transfer (TX) */
#define USB_STAT_DIR_OUT 0 /* Last transaction was a receive transfer (RX) */
/* USB Module Control Register */ /* USB Module Control Register */
#define USB_CON_USBEN (1 << 0) /* Bit 0: USB Module Enable */ #define USB_CON_USBEN (1 << 0) /* Bit 0: USB Module Enable */

View File

@ -47,6 +47,11 @@
/************************************************************************************ /************************************************************************************
* Preprocessor Definitions * Preprocessor Definitions
************************************************************************************/ ************************************************************************************/
/* USB Tokens (See chapter 8 in the USB specification) */
#define USB_SETUP_TOKEN 0x0d
#define USB_OUT_TOKEN 0x01
#define USB_IN_TOKEN 0x09
/* All 16-bit values must be little-endian */ /* All 16-bit values must be little-endian */
@ -209,6 +214,14 @@
# define USB_EP_ATTR_USAGE_IMPLICIT (2 << USB_EP_ATTR_USAGE_SHIFT) # define USB_EP_ATTR_USAGE_IMPLICIT (2 << USB_EP_ATTR_USAGE_SHIFT)
#define USB_EP_ATTR_MAX_ADJUSTABLE (1 << 7) #define USB_EP_ATTR_MAX_ADJUSTABLE (1 << 7)
/* OTG Definitions */
/* OTG SET FEATURE Constants */
#define USBOTG_FEATURE_B_HNP_ENABLE 3 /* Enable B device to perform HNP */
#define USBOTG_FEATURE_A_HNP_SUPPORT 4 /* A device supports HNP */
#define USBOTG_FEATURE_A_ALT_HNP_SUPPORT 5 /* Another port on the A device supports HNP */
/************************************************************************************ /************************************************************************************
* Public Types * Public Types
************************************************************************************/ ************************************************************************************/