/** * Close the stream. All pending transfers are canceled. * \param pAudf Pointer to AUDDSpeakerPhone instance. * \param bInterface Stream interface number */ uint32_t AUDDSpeakerPhone_CloseStream( AUDDSpeakerPhone *pAudf, uint32_t bInterface) { if (pAudf->pSpeaker->bAsInterface == bInterface) { USBD_HAL_ResetEPs(1 << pAudf->pSpeaker->bEndpointOut, USBRC_CANCELED, 1); } else if (pAudf->pMicrophone->bAsInterface == bInterface) { USBD_HAL_ResetEPs(1 << pAudf->pMicrophone->bEndpointIn, USBRC_CANCELED, 1); } return USBRC_SUCCESS; }
/** * Handle the USB reset event, should be invoked whenever * HW found USB reset signal on bus, which usually is called * "end of bus reset" status. */ void USBD_ResetHandler() { /* The device enters the Default state */ deviceState = USBD_STATE_DEFAULT; /* Active the USB HW */ USBD_HAL_Activate(); /* Only EP0 enabled */ USBD_HAL_ResetEPs(0xFFFFFFFF, USBD_STATUS_RESET, 0); USBD_ConfigureEndpoint(0); /* Invoke the Reset callback */ USBDCallbacks_Reset(); }
/** * Sets the current device configuration. * \param cfgnum - Configuration number to set. */ void USBD_SetConfiguration(uint8_t cfgnum) { TRACE_INFO_WP("SetCfg(%d) ", cfgnum); USBD_HAL_SetConfiguration(cfgnum); if (cfgnum != 0) { deviceState = USBD_STATE_CONFIGURED; } else { deviceState = USBD_STATE_ADDRESS; /* Reset all endpoints */ USBD_HAL_ResetEPs(0xFFFFFFFF, USBD_STATUS_RESET, 0); } }
/** * Close the stream. All pending transfers are canceled. * \param pStream Pointer to AUDDStream instance. */ uint32_t AUDDStream_Close(AUDDStream *pStream) { uint32_t bmEPs = 0; /* Close output stream */ if (pStream->bEndpointIn) { bmEPs |= 1 << pStream->bEndpointIn; } /* Close input stream */ if (pStream->bEndpointOut) { bmEPs |= 1 << pStream->bEndpointOut; } USBD_HAL_ResetEPs(bmEPs, USBRC_CANCELED, 1); return USBRC_SUCCESS; }