本帖最后由 abswzp 于 2015-10-9 11:11 编辑
在stm32给的例子,STM32_USB-FS-Device_Lib_V4.0.0中的Audio_Speaker端点1就是双缓冲的,自己找下,配置源码给你截取一段
usb_prop.c里void Virtual_Com_Port_Reset(void)函数
/* Initialize Endpoint 1 */
SetEPType(ENDP1, EP_ISOCHRONOUS);
SetEPDblBuffAddr(ENDP1, ENDP1_BUF0Addr, ENDP1_BUF1Addr);
SetEPDblBuffCount(ENDP1, EP_DBUF_OUT, 0x40);
ClearDTOG_RX(ENDP1);
ClearDTOG_TX(ENDP1);
ToggleDTOG_TX(ENDP1);
SetEPRxStatus(ENDP1, EP_RX_VALID);
SetEPTxStatus(ENDP1, EP_TX_DIS);
SetEPRxValid(ENDP0);
/* Set this device to response on default address */
SetDeviceAddress(0);
bDeviceState = ATTACHED;
In_Data_Offset = 0;
Out_Data_Offset = 0;
usb_endp.c
void EP1_OUT_Callback(void)
{
uint16_t Data_Len; /* data length*/
if (GetENDPOINT(ENDP1) & EP_DTOG_TX)
{
/*read from ENDP1_BUF0Addr buffer*/
Data_Len = GetEPDblBuf0Count(ENDP1);
PMAToUserBufferCopy(Stream_Buff, ENDP1_BUF0Addr, Data_Len);
}
else
{
/*read from ENDP1_BUF1Addr buffer*/
Data_Len = GetEPDblBuf1Count(ENDP1);
PMAToUserBufferCopy(Stream_Buff, ENDP1_BUF1Addr, Data_Len);
}
FreeUserBuffer(ENDP1, EP_DBUF_OUT);
In_Data_Offset += Data_Len;
}
|