/****************************************************************************** * Function: void USBCtrlTrfInHandler(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: This routine handles an IN transaction according to * which control transfer state is currently active. * * * Note: A Set Address Request must not change the acutal address * of the device until the completion of the control * transfer. The end of the control transfer for Set Address * Request is an IN transaction. Therefore it is necessary * to service this unique situation when the condition is * right. Macro mUSBCheckAdrPendingState is defined in * usb9.h and its function is to specifically service this * event. *****************************************************************************/ void USBCtrlTrfInHandler(void) { mUSBCheckAdrPendingState(); // Must check if in ADR_PENDING_STATE if(ctrl_trf_state == CTRL_TRF_TX) { USBCtrlTrfTxService(); if(ep0Bi.Stat.DTS == 0) ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; else ep0Bi.Stat._byte = _USIE|_DAT0|_DTSEN; } else // CTRL_TRF_RX USBPrepareForNextSetupTrf(); }//end USBCtrlTrfInHandler
/****************************************************************************** * Function: void USBCtrlTrfInHandler(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: This routine handles an IN transaction according to * which control transfer state is currently active. * * * Note: A Set Address Request must not change the acutal address * of the device until the completion of the control * transfer. The end of the control transfer for Set Address * Request is an IN transaction. Therefore it is necessary * to service this unique situation when the condition is * right. Macro mUSBCheckAdrPendingState is defined in * usb9.h and its function is to specifically service this * event. *****************************************************************************/ void USBCtrlTrfInHandler(void) { CTRL_TRF_SETUP xxx; xxx.bAltID = 1; mUSBCheckAdrPendingState(); // Must check if in ADR_PENDING_STATE if(ctrl_trf_state == CTRL_TRF_TX) { USBCtrlTrfTxService(); /******************************************************************** Bug Fix: May 14, 2007 (#F7 - Partial 2/4) ********************************************************************* For a control transfer read, if the host tries to read more data than what it has requested, the peripheral device should stall the extra IN transactions and the status stage. Typically, a host does not try to read more data than what it has requested. The original firmware did not handle this situation. Instead of stalling extra IN transactions, the device kept sending out zero length packets. This work around checks if a short IN packet has been sent or not. If it has, the IN endpoint will be set to install the next IN token. If not, then the original endpoint setup code will be executed. ********************************************************************/ if(short_pkt_status == SHORT_PKT_SENT) { // If a short packet has been sent, don't want to send any more, // stall next time if host is still trying to read. ep0Bi.Stat._byte = _USIE|_BSTALL; } /*******************************************************************/ else { if(ep0Bi.Stat.DTS == 0) ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; else ep0Bi.Stat._byte = _USIE|_DAT0|_DTSEN; }//end if(...)else } else // CTRL_TRF_RX USBPrepareForNextSetupTrf(); }//end USBCtrlTrfInHandler