本帖最后由 viphotman 于 2021-12-22 14:26 编辑
RCSN 发表于 2021-12-22 10:10 437系列都是用的新库,你如果用老库的接口也可以,感觉都一样,使用cdc设备,替换掉usb_vcp_send_d ...
没有测试成功;
1 新版本
新版本AT32F415_Firmware_Library-master 和例程BSP\AT32F415_Firmware_Library-master\project\at_start_f415\examples\usb_device\vcp_loopback 烧录进去,micro USB插入,没有在电脑上识别出USB 串口;
2 老版本 AT32F4xx_StdPeriph_Lib_V1.3.0
直接用CDC_Send_DATA 函数传数据 ,
只传几K数据就停了;
3 修改你上面的函数,cdc_send_buffer((uint8_t *)gImage_pic,(320*240*2));
传数据就不停了
extern uint8_t usb_packet_sent ;
#define USB_TX_LEN_MAX 2000 // 0X9600
static void cdc_send_buffer(u8 *buf,u32 len)
{
int32_t _len = len;
int32_t send_len = 0;
int32_t inc_len = 0;
uint8_t send_zero_packet = 0;
uint32_t timeout = 0;
while((_len > 0) || (send_zero_packet == 1))
{
if(_len > 0)
send_zero_packet = 1;
if(_len == 0)
send_zero_packet = 0;
timeout = 100000;
send_len = (_len > USB_TX_LEN_MAX ? USB_TX_LEN_MAX : _len);
do
{
/* send data to host */
//if(usb_vcp_send_data(&otg_core_struct.dev,&buf[inc_len],send_len) == SUCCESS)
CDC_Send_DATA((uint8_t *)gImage_pic,(320*240*2));
if(usb_packet_sent== 0)
{
break;
}
}while(timeout --);
_len -= send_len;
inc_len += send_len;
}
}
//-----------------
static uint16_t CDC_DataTx (void)
...
USB_DCD_EPT_Tx (&USB_OTG_dev, CDC_IN_EP, &usb_txfifo.fifo[SendPtr] , dwSendLen );
usb_packet_sent = 0;//modify
return USB_DEVICE_OK;
}
对USB不熟,你看要怎么修改;