20 #if defined( USB_PRESENT ) && ( USB_COUNT == 1 )
22 #if defined( USB_DEVICE )
30 #if defined( DEBUG_USB_API )
31 #define DEBUG_TRACE_ABORT( x ) \
33 if ( x == USB_STATUS_EP_STALLED ) \
34 { DEBUG_USB_API_PUTS( "\nEP cb(), EP stalled" ); } \
35 else if ( x == USB_STATUS_EP_ABORTED ) \
36 { DEBUG_USB_API_PUTS( "\nEP cb(), EP aborted" ); } \
37 else if ( x == USB_STATUS_DEVICE_UNCONFIGURED ) \
38 { DEBUG_USB_API_PUTS( "\nEP cb(), device unconfigured" ); } \
39 else if ( x == USB_STATUS_DEVICE_SUSPENDED ) \
40 { DEBUG_USB_API_PUTS( "\nEP cb(), device suspended" ); } \
42 { DEBUG_USB_API_PUTS( "\nEP cb(), device reset" ); } \
45 #define DEBUG_TRACE_ABORT( x )
48 extern USBD_Device_TypeDef *dev;
49 extern volatile bool USBD_poweredDown;
51 __STATIC_INLINE
void USBD_ArmEp0( USBD_Ep_TypeDef *ep );
52 __STATIC_INLINE
void USBD_ArmEpN( USBD_Ep_TypeDef *ep );
53 __STATIC_INLINE
void USBD_AbortEp( USBD_Ep_TypeDef *ep );
57 int USBDCH9_SetupCmd( USBD_Device_TypeDef *device );
59 void USBDEP_Ep0Handler( USBD_Device_TypeDef *device );
60 void USBDEP_EpHandler( uint8_t epAddr );
62 void USBDINT_RemoteWakeup(
void);
64 __STATIC_INLINE
void USBD_ActivateAllEps(
bool forceIdle )
68 for ( i = 1; i <= NUM_EP_USED; i++ )
70 USBDHAL_ActivateEp( &dev->ep[ i ], forceIdle );
74 __STATIC_INLINE
void USBD_ArmEp( USBD_Ep_TypeDef *ep )
86 __STATIC_INLINE
void USBD_ArmEp0( USBD_Ep_TypeDef *ep )
90 if ( ep->remaining == 0 )
95 USBDHAL_SetEp0InDmaPtr( ep->buf );
96 USBDHAL_StartEp0In(
SL_MIN( ep->remaining, ep->packetSize ),
101 USBDHAL_SetEp0OutDmaPtr( ep->buf );
102 USBDHAL_StartEp0Out( ep->packetSize, dev->ep0MpsCode );
106 __STATIC_INLINE
void USBD_ArmEpN( USBD_Ep_TypeDef *ep )
110 USBDHAL_StartEpIn( ep );
114 USBDHAL_StartEpOut( ep );
123 for ( i = 1; i <= NUM_EP_USED; i++ )
127 if ( ep->state == D_EP_IDLE )
129 USBDHAL_DeactivateEp( ep );
133 USBDHAL_AbortAllTransfers( reason );
136 __STATIC_INLINE USBD_Ep_TypeDef *USBD_GetEpFromAddr( uint8_t epAddr )
139 USBD_Ep_TypeDef *ep = NULL;
152 ep = &dev->ep[ epIndex ];
162 __STATIC_INLINE
void USBD_ReArmEp0( USBD_Ep_TypeDef *ep )
166 USBDHAL_StartEp0In(
SL_MIN( ep->remaining, ep->packetSize ),
171 USBDHAL_StartEp0Out( ep->packetSize, dev->ep0MpsCode );
175 __STATIC_INLINE
void USBD_AbortEp( USBD_Ep_TypeDef *ep )
177 if ( ep->state == D_EP_IDLE )
184 USBDHAL_AbortEpIn( ep );
188 USBDHAL_AbortEpOut( ep );
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define USB_SETUP_DIR_MASK
USBD_State_TypeDef
USB device state enumerator.
USB_Status_TypeDef
USB transfer status enumerator.
USB protocol stack library API for EFM32/EZR32.
#define SL_MIN(a, b)
Macro for getting minimum value. No sideeffects, a and b are evaluated once only. ...