使用EVT\EXAM\USB\USBHS\DEVICE\SimulateCDC-HID这个例子来修改,上传速度只能达到19MB/s,是不是我程序修改有问题?
/********************************************************************* ?*?@fn??????UART2_DataRx_Deal ?* ?*?@brief???Uart2?data?receiving?processing ?* ?*?@return??none ?*/ void?UART2_DataRx_Deal(?void?) { ????uint16_t?temp16; ????uint32_t?remain_len; ????uint16_t?packlen; //????/*?Serial?port?1?data?DMA?receive?processing?*/ //????NVIC_DisableIRQ(?USBHS_IRQn?); //????NVIC_DisableIRQ(?USBHS_IRQn?); //????UARTx_Rx_DMACurCount?=?DEF_UART2_RX_DMA_CH->CNTR; //????if(?UARTx_Rx_DMALastCount?!=?UARTx_Rx_DMACurCount?) //????{ //????????if(?UARTx_Rx_DMALastCount?>?UARTx_Rx_DMACurCount?) //????????{ //????????????temp16?=?UARTx_Rx_DMALastCount?-?UARTx_Rx_DMACurCount; //????????} //????????else //????????{ //????????????temp16?=?DEF_UARTx_RX_BUF_LEN?-?UARTx_Rx_DMACurCount; //????????????temp16?+=?UARTx_Rx_DMALastCount; //????????} //????????UARTx_Rx_DMALastCount?=?UARTx_Rx_DMACurCount; //????????if(?(?Uart.Rx_RemainLen?+?temp16?)?>?DEF_UARTx_RX_BUF_LEN?) //????????{ //????????????/*?Overflow?handling?*/ //????????????/*?Save?frame?error?status?*/ //????????????DUG_PRINTF("U0_O:%08lx\n",(uint32_t)Uart.Rx_RemainLen); //????????} //????????else //????????{ //????????????Uart.Rx_RemainLen?+=?temp16; //????????} // //????????/*?Setting?reception?status?*/ //????????Uart.Rx_TimeOut?=?0x00; //????} //????NVIC_EnableIRQ(?USBHS_IRQn?); ????/*****************************************************************/ ????/*?Serial?port?1?data?processing?via?USB?upload?and?reception?*/ //????if(?Uart.Rx_RemainLen?) ????{ ????????if(?Uart.USB_Up_IngFlag?==?0?) ????????{ ????????????/*?Calculate?the?length?of?this?upload?*/ ????????????remain_len?=?Uart.Rx_RemainLen; ????????????packlen?=?0x00; ????????????if(?remain_len?>=?DEF_USBD_HS_PACK_SIZE?) ????????????{ ????????????????packlen?=?DEF_USBD_HS_PACK_SIZE; ????????????} ????????????else ????????????{ ????????????????if(?Uart.Rx_TimeOut?>=?Uart.Rx_TimeOutMax?) ????????????????{ ????????????????????packlen?=?remain_len; ????????????????} ????????????} ????????????if(?packlen?>?(?DEF_UARTx_RX_BUF_LEN?-?Uart.Rx_DealPtr?)?) ????????????{ ????????????????packlen?=?(?DEF_UARTx_RX_BUF_LEN?-?Uart.Rx_DealPtr?); ????????????} ????????????/*?Upload?serial?data?via?usb?*/ ????????????if(?packlen=512?)//每次固定发送512字节 ????????????{ ????????????????NVIC_DisableIRQ(?USBHS_IRQn?); ????????????????NVIC_DisableIRQ(?USBHS_IRQn?); ????????????????Uart.USB_Up_IngFlag?=?0x01; ????????????????Uart.USB_Up_TimeOut?=?0x00; ????????????????USBHSD->UEP2_TX_DMA?=?(uint32_t)(uint8_t?*)&UART2_Rx_Buf[?0?]; ????????????????USBHSD->UEP2_TX_LEN??=?packlen; ????????????????USBHSD->UEP2_TX_CTRL?&=?~USBHS_UEP_T_RES_MASK; ????????????????USBHSD->UEP2_TX_CTRL?|=?USBHS_UEP_T_RES_ACK; ????????????????NVIC_EnableIRQ(?USBHS_IRQn?); ????????????????/*?Calculate?the?variables?of?interest?*/ ????????????????Uart.Rx_RemainLen?-=?packlen; ????????????????Uart.Rx_DealPtr?+=?packlen; ????????????????if(?Uart.Rx_DealPtr?>=?DEF_UARTx_RX_BUF_LEN?) ????????????????{ ????????????????????Uart.Rx_DealPtr?=?0x00; ????????????????} ????????????????/*?Start?0-length?packet?timeout?timer?*/ ????????????????if(?packlen?==?DEF_USBD_HS_PACK_SIZE?) ????????????????{ ????????????????????Uart.USB_Up_Pack0_Flag?=?0x01; ????????????????} ????????????} ????????} ????????else ????????{ ????????????/*?Set?the?upload?success?flag?directly?if?the?upload?is?not?successful?after?the?timeout?*/ ????????????if(?Uart.USB_Up_TimeOut?>=?DEF_UARTx_USB_UP_TIMEOUT?) ????????????{ ????????????????Uart.USB_Up_IngFlag?=?0x00; ????????????????USBHS_Endp_Busy[?DEF_UEP2?]?=?0; ????????????} ????????} ????} ????/*****************************************************************/ ????/*?Determine?if?a?0-length?packet?needs?to?be?uploaded?(required?for?CDC?mode)?*/ //????if(?Uart.USB_Up_Pack0_Flag?) //????{ //????????if(?Uart.USB_Up_IngFlag?==?0?) //????????{ //????????????if(?Uart.USB_Up_TimeOut?>=?(?DEF_UARTx_RX_TIMEOUT?*?20?)?) //????????????{ //????????????????NVIC_DisableIRQ(?USBHS_IRQn?); //????????????????NVIC_DisableIRQ(?USBHS_IRQn?); //????????????????Uart.USB_Up_IngFlag?=?0x01; //????????????????Uart.USB_Up_TimeOut?=?0x00; //????????????????USBHSD->UEP2_TX_LEN??=?0x00; //????????????????USBHSD->UEP2_TX_CTRL?&=?~USBHS_UEP_T_RES_MASK; //????????????????USBHSD->UEP2_TX_CTRL?|=?USBHS_UEP_T_RES_ACK; //????????????????Uart.USB_Up_IngFlag?=?0; //????????????????NVIC_EnableIRQ(?USBHS_IRQn?); //????????????????Uart.USB_Up_Pack0_Flag?=?0x00; //????????????} //????????} //????} }