USBDevice for STM support

Dependents:   Nucleo_Usb_JoyMouse Nucleo_usbmouse ELEC350_1-referral-2018-usb-hid USBJoystick_HelloWorld2_wip ... more

This library contains all mbed usb device library (mbed-os\features\unsupported\USBDevice).

Committer:
frq08711@LMECWL0871.LME.ST.COM
Date:
Thu Dec 15 17:40:59 2016 +0100
Revision:
1:2a3ae13b45ef
copy of git hub directory unsupported/USBDevice

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 1 /**************************************************************************//**
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 2 * @file em_usbdep.c
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 3 * @brief USB protocol stack library, USB device endpoint handlers.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 4 * @version 3.20.14
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 5 ******************************************************************************
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 6 * @section License
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 7 * <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 8 *******************************************************************************
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 9 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 10 * Licensed under the Apache License, Version 2.0 (the "License");
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 11 * you may not use this file except in compliance with the License.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 12 * You may obtain a copy of the License at
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 13 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 14 * http://www.apache.org/licenses/LICENSE-2.0
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 15 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 16 * Unless required by applicable law or agreed to in writing, software
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 17 * distributed under the License is distributed on an "AS IS" BASIS,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 19 * See the License for the specific language governing permissions and
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 20 * limitations under the License.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 21 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 22 ******************************************************************************/
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 23
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 24 #include "em_device.h"
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 25 #if defined( USB_PRESENT ) && ( USB_COUNT == 1 )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 26 #include "em_usb.h"
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 27 #if defined( USB_DEVICE )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 28
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 29 #include "em_usbtypes.h"
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 30 #include "em_usbhal.h"
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 31 #include "em_usbd.h"
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 32
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 33 #ifdef USB_USE_PRINTF
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 34 static const char *epStatusStr[] = {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 35 "IDLE","TRANS","RECV","IN_S","OUT_S"
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 36 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 37 #endif
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 38
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 39 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 40
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 41 /*
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 42 * USBDEP_Ep0Handler() is called each time a packet has been transmitted
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 43 * or recieved on the default endpoint.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 44 * A state machine navigate us through the phases of a control transfer
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 45 * according to "chapter 9" in the USB spec.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 46 */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 47 #if !defined( USB_DOEP0INT_STUPPKTRCVD )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 48 void USBDEP_Ep0Handler( USBD_Device_TypeDef *device )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 49 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 50 int status;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 51 USBD_Ep_TypeDef *ep;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 52 static bool statusIn;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 53 static uint32_t xferred;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 54 static USB_XferCompleteCb_TypeDef callback;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 55
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 56 ep = &device->ep[ 0 ];
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 57
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 58 #ifdef __MBED__
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 59
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 60 (void)xferred;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 61 (void)statusIn;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 62 (void)status;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 63
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 64 USB_PRINTF("USBDEP: ep0 %s, rem %ld, z %d\n", epStatusStr[ep->state], ep->remaining, ep->zlp);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 65
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 66 if ( ( ep->state == D_EP_TRANSMITTING ) || ( ep->state == D_EP_RECEIVING ) )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 67 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 68 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 69
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 70 if ( ep->xferCompleteCb )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 71 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 72 callback = ep->xferCompleteCb;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 73 ep->xferCompleteCb = NULL;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 74 callback( USB_STATUS_OK, ep->xferred, ep->remaining );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 75 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 76
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 77 USBDHAL_ReenableEp0Setup(device);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 78 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 79 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 80 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 81 device->callbacks->setupCmd(device->setup);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 82 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 83
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 84 #else /* not __MBED__ */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 85
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 86 switch ( ep->state )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 87 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 88 case D_EP_IDLE:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 89 ep->remaining = 0;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 90 ep->zlp = 0;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 91 callback = NULL;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 92 statusIn = false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 93
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 94 status = USBDCH9_SetupCmd( device );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 95
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 96 if ( status == USB_STATUS_REQ_ERR )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 97 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 98 ep->in = true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 99 USBDHAL_StallEp( ep ); /* Stall Ep0 IN */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 100 ep->in = false; /* OUT for next SETUP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 101 USBDHAL_StallEp( ep ); /* Stall Ep0 OUT */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 102 USBDHAL_ReenableEp0Setup( device ); /* Prepare for next SETUP packet*/
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 103 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 104 else /* ( Status == USB_STATUS_OK ) */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 105 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 106 if ( (ep->state == D_EP_RECEIVING) || (ep->state == D_EP_TRANSMITTING) )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 107 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 108 callback = ep->xferCompleteCb;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 109 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 110
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 111 if ( ep->state != D_EP_RECEIVING )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 112 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 113 if ( ep->remaining )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 114 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 115 /* Data will be sent to host, check if a ZLP must be appended */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 116 if ( ( ep->remaining < device->setup->wLength ) &&
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 117 ( ep->remaining % ep->packetSize == 0 ) )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 118 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 119 ep->zlp = 1;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 120 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 121 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 122 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 123 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 124 /* Prepare for next SETUP packet*/
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 125 USBDHAL_ReenableEp0Setup( device );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 126
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 127 /* No data stage, a ZLP may have been sent. If not, send one */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 128
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 129 xferred = 0;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 130 if ( ep->zlp == 0 )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 131 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 132 USBD_Write( 0, NULL, 0, NULL ); /* ACK to host */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 133 ep->state = D_EP0_IN_STATUS;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 134 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 135 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 136 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 137 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 138 ep->in = false; /* OUT for next SETUP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 139 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 140 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 141 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 142 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 143 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 144
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 145 case D_EP_RECEIVING:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 146 if ( ep->remaining )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 147 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 148 /* There is more data to receive */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 149 USBD_ReArmEp0( ep );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 150 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 151 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 152 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 153 status = USB_STATUS_OK;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 154 if ( callback != NULL )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 155 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 156 status = callback( USB_STATUS_OK, ep->xferred, 0 );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 157 callback = NULL;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 158 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 159
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 160 if ( status != USB_STATUS_OK )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 161 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 162 ep->in = true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 163 USBDHAL_StallEp( ep ); /* Stall Ep0 IN */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 164 ep->in = false; /* OUT for next SETUP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 165 USBDHAL_StallEp( ep ); /* Stall Ep0 OUT */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 166 USBDHAL_ReenableEp0Setup( device ); /* Prepare for next SETUP pkt. */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 167 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 168 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 169 else /* Everything OK, send a ZLP (ACK) to host */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 170 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 171 USBDHAL_ReenableEp0Setup( device );/* Prepare for next SETUP packet*/
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 172
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 173 ep->state = D_EP_IDLE; /* USBD_Write() sets state back*/
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 174 /* to EP_TRANSMITTING */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 175 USBD_Write( 0, NULL, 0, NULL );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 176 ep->state = D_EP0_IN_STATUS;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 177 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 178 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 179 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 180
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 181 case D_EP_TRANSMITTING:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 182 if ( ep->remaining )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 183 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 184 /* There is more data to transmit */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 185 USBD_ReArmEp0( ep );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 186 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 187 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 188 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 189 /* All data transferred, is a ZLP packet needed ? */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 190 if ( ep->zlp == 1 )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 191 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 192 xferred = ep->xferred;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 193 ep->state = D_EP_IDLE; /* USBD_Write() sets state back */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 194 /* to EP_TRANSMITTING */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 195 USBD_Write( 0, NULL, 0, NULL ); /* Send ZLP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 196 ep->zlp = 2;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 197 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 198 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 199 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 200 if ( ep->zlp == 0 )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 201 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 202 xferred = ep->xferred;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 203 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 204
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 205 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 206 USBD_Read( 0, NULL, 0, NULL ); /* Get ZLP packet (ACK) from host */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 207 statusIn = true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 208 ep->state = D_EP0_OUT_STATUS;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 209 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 210 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 211 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 212
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 213 case D_EP0_IN_STATUS:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 214 case D_EP0_OUT_STATUS:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 215 if ( statusIn )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 216 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 217 USBDHAL_ReenableEp0Setup( device );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 218 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 219
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 220 if ( callback != NULL )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 221 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 222 callback( USB_STATUS_OK, xferred, 0 );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 223 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 224
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 225 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 226 ep->in = false; /* OUT for next SETUP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 227 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 228
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 229 default:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 230 EFM_ASSERT( false );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 231 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 232 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 233 #endif /* __MBED__ */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 234 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 235 #endif
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 236
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 237 #if defined( USB_DOEP0INT_STUPPKTRCVD )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 238 void USBDEP_Ep0Handler( USBD_Device_TypeDef *device )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 239 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 240 int status;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 241 USBD_Ep_TypeDef *ep;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 242 static uint32_t xferred;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 243 static USB_XferCompleteCb_TypeDef callback;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 244
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 245 #ifdef __MBED__
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 246
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 247 (void)xferred;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 248 (void)status;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 249
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 250 ep = &device->ep[ 0 ];
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 251
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 252 if ( ( ep->state == D_EP_TRANSMITTING ) || ( ep->state == D_EP_RECEIVING ) )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 253 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 254 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 255
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 256 if ( ep->xferCompleteCb )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 257 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 258 callback = ep->xferCompleteCb;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 259 ep->xferCompleteCb = NULL;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 260 callback( USB_STATUS_OK, ep->xferred, ep->remaining );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 261 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 262
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 263 USBDHAL_StartEp0Setup( dev );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 264 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 265 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 266 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 267 device->callbacks->setupCmd(device->setup);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 268 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 269
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 270 #else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 271
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 272 ep = &device->ep[ 0 ];
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 273
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 274 switch ( ep->state )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 275 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 276 case D_EP_IDLE:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 277 ep->zlp = 0;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 278 ep->remaining = 0;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 279 callback = NULL;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 280
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 281 status = USBDCH9_SetupCmd( device );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 282
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 283 if ( status == USB_STATUS_REQ_ERR )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 284 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 285 ep->in = true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 286 USBDHAL_StallEp( ep ); /* Stall Ep0 IN */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 287 ep->in = false; /* OUT for next SETUP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 288 USBDHAL_StallEp( ep ); /* Stall Ep0 OUT */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 289 USBDHAL_StartEp0Setup( dev ); /* Prepare for next SETUP packet*/
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 290 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 291 else /* ( Status == USB_STATUS_OK ) */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 292 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 293 if ( (ep->state == D_EP_RECEIVING) || (ep->state == D_EP_TRANSMITTING) )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 294 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 295 callback = ep->xferCompleteCb;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 296 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 297
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 298 if ( ep->state != D_EP_RECEIVING )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 299 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 300 if ( ep->remaining )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 301 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 302 /* Data will be sent to host, check if a ZLP must be appended */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 303 if ( ( ep->remaining < device->setup->wLength ) &&
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 304 ( ep->remaining % ep->packetSize == 0 ) )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 305 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 306 ep->zlp = 1;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 307 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 308 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 309 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 310 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 311 /* No data stage, a ZLP may have been sent. If not, send one */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 312 xferred = 0;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 313 if ( ep->zlp == 0 )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 314 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 315 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 316 USBD_Write( 0, NULL, 0, NULL ); /* ACK to host */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 317 ep->state = D_EP0_IN_STATUS;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 318 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 319 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 320 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 321 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 322 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 323
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 324 case D_EP_RECEIVING:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 325 if ( ep->remaining )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 326 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 327 ep->in = false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 328 USBD_ReArmEp0( ep );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 329 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 330 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 331 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 332 status = USB_STATUS_OK;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 333 if ( callback != NULL )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 334 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 335 status = callback( USB_STATUS_OK, ep->xferred, 0 );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 336 callback = NULL;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 337 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 338
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 339 if ( status != USB_STATUS_OK )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 340 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 341 ep->in = true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 342 USBDHAL_StallEp( ep ); /* Stall Ep0 IN */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 343 ep->in = false; /* OUT for next SETUP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 344 USBDHAL_StallEp( ep ); /* Stall Ep0 OUT */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 345 USBDHAL_StartEp0Setup( dev ); /* Prepare for next SETUP pkt. */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 346 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 347 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 348 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 349 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 350
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 351 USBDHAL_StartEp0Setup( dev ); /* Prepare for next SETUP packet*/
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 352 ep->state = D_EP_IDLE; /* USBD_Write() sets state back */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 353 /* to EP_TRANSMITTING */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 354 USBD_Write( 0, NULL, 0, NULL );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 355 ep->state = D_EP0_IN_STATUS;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 356 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 357 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 358 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 359
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 360 case D_EP_TRANSMITTING:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 361 if ( ep->remaining )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 362 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 363 ep->in = true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 364 USBD_ReArmEp0( ep );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 365 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 366 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 367 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 368 if ( ep->zlp == 1 )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 369 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 370 xferred = ep->xferred;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 371 ep->state = D_EP_IDLE; /* USBD_Write() sets state back */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 372 /* to EP_TRANSMITTING */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 373 USBD_Write( 0, NULL, 0, NULL ); /* Send ZLP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 374 ep->zlp = 2;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 375 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 376 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 377 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 378 if ( ep->zlp == 0 )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 379 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 380 xferred = ep->xferred;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 381 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 382
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 383 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 384 USBD_Read( 0, NULL, 0, NULL ); /* Get ZLP packet (ACK) from host */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 385 ep->state = D_EP0_OUT_STATUS;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 386 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 387 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 388 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 389
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 390 case D_EP0_IN_STATUS:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 391 if ( ( USB->DOEP0CTL & USB_DOEP0CTL_EPENA ) == 0 )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 392 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 393 /* Prepare for more SETUP Packets */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 394 USBDHAL_StartEp0Setup( dev );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 395 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 396 if ( callback != NULL )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 397 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 398 callback( USB_STATUS_OK, xferred, 0 );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 399 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 400 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 401 ep->in = false; /* OUT for next SETUP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 402 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 403
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 404 case D_EP0_OUT_STATUS:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 405 USBDHAL_StartEp0Setup( dev ); /* Prepare for more SETUP Packets */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 406 if ( callback != NULL )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 407 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 408 callback( USB_STATUS_OK, xferred, 0 );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 409 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 410 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 411 ep->in = false; /* OUT for next SETUP */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 412 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 413 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 414 #endif /* __MBED__ */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 415 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 416 #endif
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 417
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 418 /*
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 419 * USBDEP_EpHandler() is called each time a packet has been transmitted
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 420 * or recieved on an endpoint other than the default endpoint.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 421 */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 422 void USBDEP_EpHandler( uint8_t epAddr )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 423 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 424 USB_XferCompleteCb_TypeDef callback;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 425 USBD_Ep_TypeDef *ep = USBD_GetEpFromAddr( epAddr );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 426
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 427 if ( ( ep->state == D_EP_TRANSMITTING ) || ( ep->state == D_EP_RECEIVING ) )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 428 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 429 ep->state = D_EP_IDLE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 430 if ( ep->xferCompleteCb )
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 431 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 432 callback = ep->xferCompleteCb;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 433 ep->xferCompleteCb = NULL;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 434 callback( USB_STATUS_OK, ep->xferred, ep->remaining );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 435 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 436 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 437 else
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 438 {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 439 EFM_ASSERT( false );
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 440 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 441 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 442
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 443 /** @endcond */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 444
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 445 #endif /* defined( USB_DEVICE ) */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 446 #endif /* defined( USB_PRESENT ) && ( USB_COUNT == 1 ) */