From 3aa8654e3a5533f54086ba1311b4feeafd9d7795 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 26 Apr 2014 09:49:10 +0000 Subject: [PATCH] Updated the STM32 USB drivers to the new setup phase convention. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6884 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/usb.h | 3 --- os/hal/platforms/Rx62n/usb_lld.c | 1 - os/hal/platforms/Rx62n/usb_lld.h | 2 +- os/hal/platforms/STM32/OTGv1/usb_lld.h | 5 +++++ os/hal/platforms/STM32/USBv1/usb_lld.h | 5 +++++ os/hal/src/usb.c | 11 +++++------ 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/os/hal/include/usb.h b/os/hal/include/usb.h index 9cfc0fb00..3d34708eb 100644 --- a/os/hal/include/usb.h +++ b/os/hal/include/usb.h @@ -451,9 +451,6 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp, (usbp)->ep0endcb = (endcb); \ } -#define usbSetupEnd(usbp, ep) \ - usb_lld_end_transaction(usbp, ep) - /** * @brief Reads a setup packet from the dedicated packet buffer. * @details This function must be invoked in the context of the @p setup_cb diff --git a/os/hal/platforms/Rx62n/usb_lld.c b/os/hal/platforms/Rx62n/usb_lld.c index f5b7a965f..d80e2e766 100644 --- a/os/hal/platforms/Rx62n/usb_lld.c +++ b/os/hal/platforms/Rx62n/usb_lld.c @@ -25,7 +25,6 @@ #include "ch.h" #include "hal.h" - #if HAL_USE_USB || defined(__DOXYGEN__) /*===========================================================================*/ diff --git a/os/hal/platforms/Rx62n/usb_lld.h b/os/hal/platforms/Rx62n/usb_lld.h index 5482fab50..20f0e130c 100644 --- a/os/hal/platforms/Rx62n/usb_lld.h +++ b/os/hal/platforms/Rx62n/usb_lld.h @@ -457,7 +457,7 @@ struct USBDriver { * * @notapi */ -#define usb_lld_end_transaction(usbp, ep) \ +#define usb_lld_end_setup(usbp, ep) \ ((usbp)->usb->DCPCTR.BIT.CCPL=1) /** diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.h b/os/hal/platforms/STM32/OTGv1/usb_lld.h index 570309750..5be12e66e 100644 --- a/os/hal/platforms/STM32/OTGv1/usb_lld.h +++ b/os/hal/platforms/STM32/OTGv1/usb_lld.h @@ -42,6 +42,11 @@ #define USB_MAX_ENDPOINTS 5 #endif +/** + * @brief Status stage handling method. + */ +#define USB_EP0_STATUS_STAGE USB_EP0_STATUS_STAGE_SW + /** * @brief The address can be changed immediately upon packet reception. */ diff --git a/os/hal/platforms/STM32/USBv1/usb_lld.h b/os/hal/platforms/STM32/USBv1/usb_lld.h index a0092a334..74618900f 100644 --- a/os/hal/platforms/STM32/USBv1/usb_lld.h +++ b/os/hal/platforms/STM32/USBv1/usb_lld.h @@ -38,6 +38,11 @@ */ #define USB_MAX_ENDPOINTS USB_ENDOPOINTS_NUMBER +/** + * @brief Status stage handling method. + */ +#define USB_EP0_STATUS_STAGE USB_EP0_STATUS_STAGE_SW + /** * @brief This device requires the address change after the status packet. */ diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c index 55ae89d84..b0a6390e7 100644 --- a/os/hal/src/usb.c +++ b/os/hal/src/usb.c @@ -628,8 +628,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { } } #if (USB_SET_ADDRESS_ACK_HANDLING == USB_SET_ADDRESS_ACK_HW) - if (usbp->setup[1] == USB_REQ_SET_ADDRESS) - { + if (usbp->setup[1] == USB_REQ_SET_ADDRESS) { /* Zero-length packet sent by hardware */ return; } @@ -661,7 +660,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { usbStartReceiveI(usbp, 0); chSysUnlockFromIsr(); #else - usbSetupEnd(usbp, ep); + usb_lld_end_setup(usbp, ep); #endif } } @@ -685,7 +684,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { usbStartTransmitI(usbp, 0); chSysUnlockFromIsr(); #else - usbSetupEnd(usbp, ep); + usb_lld_end_setup(usbp, ep); #endif } } @@ -729,7 +728,7 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) { usbStartReceiveI(usbp, 0); chSysUnlockFromIsr(); #else - usbSetupEnd(usbp, ep); + usb_lld_end_setup(usbp, ep); #endif return; case USB_EP0_SENDING_STS: @@ -773,7 +772,7 @@ void _usb_ep0out(USBDriver *usbp, usbep_t ep) { usbStartTransmitI(usbp, 0); chSysUnlockFromIsr(); #else - usbSetupEnd(usbp, ep); + usb_lld_end_setup(usbp, ep); #endif return; case USB_EP0_WAITING_STS: