![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
USB composite device example program, drag-and-drop flash writer.
Dependencies: SWD USBDevice mbed BaseDAP
tests/test_USBMSD_Drop.cpp@1:ea8e179320d7, 2013-09-28 (annotated)
- Committer:
- va009039
- Date:
- Sat Sep 28 03:21:14 2013 +0000
- Revision:
- 1:ea8e179320d7
add USBMSD_Drop class. add CDC(Virtual COM) and HID(for example CMSIS-DAP), but KL25Z not work.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 1:ea8e179320d7 | 1 | // test_USBMSD_Drop.cpp 2013/9/26 |
va009039 | 1:ea8e179320d7 | 2 | #if 0 |
va009039 | 1:ea8e179320d7 | 3 | #include "mbed.h" |
va009039 | 1:ea8e179320d7 | 4 | #include "USBMSD_Drop.h" |
va009039 | 1:ea8e179320d7 | 5 | #include "mytest.h" |
va009039 | 1:ea8e179320d7 | 6 | #include "mydebug.h" |
va009039 | 1:ea8e179320d7 | 7 | |
va009039 | 1:ea8e179320d7 | 8 | Serial pc(USBTX, USBRX); |
va009039 | 1:ea8e179320d7 | 9 | |
va009039 | 1:ea8e179320d7 | 10 | class myUSBMSD_Drop : public USBMSD_Drop { |
va009039 | 1:ea8e179320d7 | 11 | public: |
va009039 | 1:ea8e179320d7 | 12 | virtual void Drop(const uint8_t* data, int len, int offset, int total) { |
va009039 | 1:ea8e179320d7 | 13 | TEST_PRINT("offset=%d, total=%d", offset, total); |
va009039 | 1:ea8e179320d7 | 14 | } |
va009039 | 1:ea8e179320d7 | 15 | }; |
va009039 | 1:ea8e179320d7 | 16 | |
va009039 | 1:ea8e179320d7 | 17 | TEST(USBMSD_Drop,test1) { |
va009039 | 1:ea8e179320d7 | 18 | myUSBMSD_Drop* intf = new myUSBMSD_Drop(); |
va009039 | 1:ea8e179320d7 | 19 | Timer t; |
va009039 | 1:ea8e179320d7 | 20 | t.reset(); |
va009039 | 1:ea8e179320d7 | 21 | t.start(); |
va009039 | 1:ea8e179320d7 | 22 | int n = 0; |
va009039 | 1:ea8e179320d7 | 23 | while(1) { // forever |
va009039 | 1:ea8e179320d7 | 24 | if (intf->readable()) { |
va009039 | 1:ea8e179320d7 | 25 | int c = intf->getc(); |
va009039 | 1:ea8e179320d7 | 26 | debug("%02x[%c]\n", c, c > ' ' ? c : '.'); |
va009039 | 1:ea8e179320d7 | 27 | } |
va009039 | 1:ea8e179320d7 | 28 | if (t.read_ms() > 1000*1) { |
va009039 | 1:ea8e179320d7 | 29 | t.reset(); |
va009039 | 1:ea8e179320d7 | 30 | intf->putc('A'+ n%26); |
va009039 | 1:ea8e179320d7 | 31 | n++; |
va009039 | 1:ea8e179320d7 | 32 | } |
va009039 | 1:ea8e179320d7 | 33 | } |
va009039 | 1:ea8e179320d7 | 34 | } |
va009039 | 1:ea8e179320d7 | 35 | |
va009039 | 1:ea8e179320d7 | 36 | int main() { |
va009039 | 1:ea8e179320d7 | 37 | pc.baud(921600); |
va009039 | 1:ea8e179320d7 | 38 | //pc.baud(9600); |
va009039 | 1:ea8e179320d7 | 39 | DBG("%s", __FILE__); |
va009039 | 1:ea8e179320d7 | 40 | |
va009039 | 1:ea8e179320d7 | 41 | RUN_ALL_TESTS(); |
va009039 | 1:ea8e179320d7 | 42 | exit(0); |
va009039 | 1:ea8e179320d7 | 43 | } |
va009039 | 1:ea8e179320d7 | 44 | #endif |