Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SWD USBDevice mbed BaseDAP
test_USBMSD2_HID.cpp
00001 // test_USBMSD2_HID.cpp 2013/9/28 00002 #if 0 00003 #include "mbed.h" 00004 #include "USBMSD_Drop.h" 00005 #include "BaseDAP.h" 00006 #define MY_DEBUG 1 00007 #include "mydebug.h" 00008 #include "mytest.h" 00009 00010 Serial pc(USBTX, USBRX); 00011 00012 #ifdef TARGET_LPC1768 00013 Serial target_uart(p9,p10); // RXD(dp15),TXD(dp16) 00014 SWD swd(p21,p22,p17); // SWDIO(dp12),SWCLK(dp3),nReset(dp23) 00015 DigitalOut connected(LED1); 00016 DigitalOut running(LED2); 00017 class myDAP : public BaseDAP { 00018 public: 00019 myDAP(SWD* swd):BaseDAP(swd){}; 00020 virtual void infoLED(int select, int value) { 00021 switch(select) { 00022 case 0: connected = value; break; 00023 case 1: running = value; break; 00024 } 00025 } 00026 }; 00027 #endif 00028 00029 #ifdef TARGET_KL25Z 00030 SWD swd(PTB8,PTB9,PTB10); // SWDIO(dp12),SWCLK(dp3),nReset(dp23) 00031 DigitalOut connected(LED_GREEN); 00032 DigitalOut running(LED_RED); 00033 class myDAP : public BaseDAP { 00034 public: 00035 myDAP(SWD* swd):BaseDAP(swd){}; 00036 virtual void infoLED(int select, int value) { 00037 switch(select) { 00038 case 0: 00039 connected = value^1; 00040 running = 1; 00041 break; 00042 case 1: 00043 running = value^1; 00044 connected = 1; 00045 break; 00046 } 00047 } 00048 }; 00049 #endif 00050 00051 class myUSBMSD_Drop : public USBMSD_Drop { 00052 public: 00053 virtual void Drop(const uint8_t* data, int len, int offset, int total) { 00054 TEST_PRINT("offset=%d, total=%d", offset, total); 00055 } 00056 }; 00057 00058 HID_REPORT send_report; 00059 HID_REPORT recv_report; 00060 00061 myDAP* dap; 00062 myUSBMSD_Drop* hid; 00063 00064 TEST(USBMSD2_HID,test1) { 00065 dap = new myDAP(&swd); 00066 hid = new myUSBMSD_Drop(); 00067 } 00068 00069 #if 0 00070 TEST(USBMSD2_HID,test2) { 00071 while(1) { // forever 00072 if(hid->readNB(&recv_report)) { 00073 dap->Command(recv_report.data, send_report.data); 00074 send_report.length = 64; 00075 hid->send(&send_report); 00076 } 00077 } 00078 } 00079 #endif 00080 00081 TEST(USBMSD2_HID,test3) { 00082 while(1) { // forever 00083 if(hid->readNB(&recv_report)) { 00084 dap->Command(recv_report.data, send_report.data); 00085 send_report.length = 64; 00086 hid->send(&send_report); 00087 } 00088 #ifdef TARGET_LPC1768 00089 if (target_uart.readable()) { 00090 hid->putc(target_uart.getc()); 00091 } 00092 if(hid->readable()) { 00093 target_uart.putc(hid->getc()); 00094 } 00095 #endif 00096 } 00097 } 00098 00099 int main() { 00100 pc.baud(921600); 00101 //pc.baud(9600); 00102 DBG("%s", __FILE__); 00103 00104 RUN_ALL_TESTS(); 00105 exit(0); 00106 } 00107 #endif
Generated on Wed Jul 13 2022 08:08:25 by
1.7.2