USB 端口1代码- SetEPType(ENDP1, EP_BULK);
- // SetEPTxAddr(ENDP1, ENDP1_TXADDR);
-
- SetEPDoubleBuff(ENDP1); //
- SetEPDblBuffAddr(ENDP1, ENDP1_TXADDR, ENDP1_TXADDR_BUF); //
- //SetEPDblBuffCount(ENDP1, EP_DBUF_IN, VIRTUAL_COM_PORT_DATA_SIZE); //
- ClearDTOG_RX(ENDP1); //
- ClearDTOG_TX(ENDP1); //
- ToggleDTOG_RX(ENDP1); //
- SetEPTxStatus(ENDP1, EP_TX_NAK);
- SetEPRxStatus(ENDP1, EP_RX_DIS);
- void EP1_IN_Callback (void)
- {
- uint16_t USB_Tx_ptr;
- uint16_t USB_Tx_length;
-
- if (USB_Tx_State == 1)
- {
- if (AD_Tx_length == 0)
- {
- USB_Tx_State = 0;
- }
- else
- {
- if (AD_Tx_length > (VIRTUAL_COM_PORT_DATA_SIZE)){
- USB_Tx_ptr = AD_Tx_ptr_out;
- USB_Tx_length = (VIRTUAL_COM_PORT_DATA_SIZE) ;
- AD_Tx_ptr_out += (VIRTUAL_COM_PORT_DATA_SIZE);
- AD_Tx_length -= (VIRTUAL_COM_PORT_DATA_SIZE);
- }
- else
- {
- USB_Tx_ptr = AD_Tx_ptr_out;
- USB_Tx_length = AD_Tx_length;
-
- AD_Tx_ptr_out += AD_Tx_length;
- AD_Tx_length = 0;
- }
- if (GetENDPOINT(ENDP1) & EP_DTOG_RX)
- {
- UserToPMABufferCopy(&AD_Tx_Buffer[USB_Tx_ptr], ENDP1_TXADDR_BUF, USB_Tx_length);
- FreeUserBuffer(ENDP1, EP_DBUF_IN);
- SetEPTxCount(ENDP1, USB_Tx_length);
- SetEPTxValid(ENDP1);
- }
- else
- {
- UserToPMABufferCopy(&AD_Tx_Buffer[USB_Tx_ptr], ENDP1_TXADDR, USB_Tx_length);
- FreeUserBuffer(ENDP1, EP_DBUF_IN);
- SetEPTxCount(ENDP1, USB_Tx_length);
- SetEPTxValid(ENDP1);
- }
- }
- }
- }
|