USB composite device example program, drag-and-drop flash writer.

Dependencies:   SWD USBDevice mbed BaseDAP

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers test_USBMSD_Drop.cpp Source File

test_USBMSD_Drop.cpp

00001 // test_USBMSD_Drop.cpp 2013/9/26
00002 #if 0
00003 #include "mbed.h"
00004 #include "USBMSD_Drop.h"
00005 #include "mytest.h"
00006 #include "mydebug.h"
00007 
00008 Serial pc(USBTX, USBRX);
00009 
00010 class myUSBMSD_Drop : public USBMSD_Drop {
00011 public:
00012     virtual void Drop(const uint8_t* data, int len, int offset, int total) {
00013         TEST_PRINT("offset=%d, total=%d", offset, total);
00014     }
00015 };
00016 
00017 TEST(USBMSD_Drop,test1) {
00018     myUSBMSD_Drop* intf = new myUSBMSD_Drop();
00019     Timer t;
00020     t.reset();
00021     t.start();
00022     int n = 0;
00023     while(1) { // forever
00024         if (intf->readable()) {
00025             int c = intf->getc();
00026             debug("%02x[%c]\n", c, c > ' ' ? c : '.');
00027         }
00028         if (t.read_ms() > 1000*1) {
00029             t.reset();
00030             intf->putc('A'+ n%26);
00031             n++;
00032         }
00033     }
00034 }
00035 
00036 int main() {
00037     pc.baud(921600);
00038     //pc.baud(9600);
00039     DBG("%s", __FILE__);
00040 
00041     RUN_ALL_TESTS();
00042     exit(0);
00043 }
00044 #endif