實驗方法:
1、安裝USB CDC驅動,驅動安裝方法參考例程包中安裝方法文件。
2、將跳線冒跳至USB_OTG,通過Micro USB 線將iCore4 USB-OTG介面與電腦相連。
3、開啟上位機軟體usb.exe,點選開啟,測試按鈕即可測試。(如果該軟體沒能正常啟動,則重新安裝驅動)
實驗現象:
核心程式碼:
int main(void) { int i; static unsigned char data_number = 0; system_clock.initialize();//ϵͳʱÖÓ³õʼ»¯ led.initialize(); //LED³õʼ»¯ USBD_Init(&USB_OTG_dev, USB_OTG_HS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb); while(State==0); LED_GREEN_ON; while(1) { //½ÓÊÕÊý¾Ý²¢´¦Àí if(USB_ReceivedCount > 0){ LED_RED_ON; USB_ReceivedCount = 0; //Öظ´·¢ËÍ´ÎÊý data_number = USB_Rx_Buffer[0]; //·¢ËÍͼƬ do{ USB_StatusDataSended = 0; DCD_EP_Tx(&USB_OTG_dev,CDC_IN_EP,gImage_flower,sizeof(gImage_flower)); while(USB_StatusDataSended == 0){ for(i = 0;i < 10000;i++); } data_number--; }while(data_number > 0); LED_RED_OFF; } } }
原始碼下載連結:
連結:http://pan.baidu.com/s/1c1P0cyW 密碼:lzgb
iCore4連結: