使用STM32操作CH374T控制CP2102時(shí),在讀取CP2102數(shù)據(jù)時(shí)當(dāng)?shù)簟? CP2102能夠正常枚舉出來,但在CP2102_Res_Data獲取接受長度時(shí)會(huì)死在里面 u8 CP2102_Res_Data(u8 *p ) { u8 result = 0; u8 count; result = WaitHostTransact374(mDiskBulkInEndp,DEF_USB_PID_IN,mSaveDevEndpTog,20); //1000); if(result!=USB_INT_SUCCESS) { return result; } else { count = CDeviceCH374t_SPIBus_ReadByte(REG_USB_LENGTH); CDeviceCH374t_SPIBus_ReadBuffer(RAM_HOST_RECV, count , p); mSaveDevEndpTog = mSaveDevEndpTog? FALSE : TRUE;; } return result; }
void CDeviceCH374t_USBDeviceUse() { u8 s; u8 buf[250]; if (Query374DeviceIn()) { if(uid == 0x10C4 || pid == 0xEA60) { s=CP2102_Start_stop(0x0001); if(s != USB_INT_SUCCESS) { usbStatus = USB_FREE; return; } s = CP2102_Uart_Bound(19200); if(s!=USB_INT_SUCCESS) { usbStatus = USB_FREE; return; } s=CP2102_Uart_Bit(0x0810); if(s!=USB_INT_SUCCESS) { usbStatus = USB_FREE; return; } CP2102_Res_Data(buf); s = CP2102_Start_stop(0x0000); if(s != USB_INT_SUCCESS) { usbStatus = USB_FREE; return; }
} } else { HostSetBusFree( ); // USB總線空閑 usbStatus = USB_FREE; }
}