Simple USBHost library for LPC4088. Backward compatibility of official-USBHost.
Dependencies: FATFileSystem mbed-rtos
EA LPC4088 QSB専用の簡易USBホストライブラリです。
official-USBHostの下位互換で対応プログラムを僅かな修正で動かすことが出来ます。
examples:
Import programLPC4088-USBHostMSD_HelloWorld
Simple USBHost MSD(USB flash drive) for EA LPC4088 QSB test program
Import programLPC4088-BTstack_example
BTstack for EA LPC4088 QSB example program
Import programLPC4088-USBHostC270_example
Simple USBHost WebCam for EA LPC4088 QSB/LPC1768 test program
USBHost/BaseUsbHostDebug.cpp@0:148fca6fd246, 2014-04-25 (annotated)
- Committer:
- va009039
- Date:
- Fri Apr 25 05:18:55 2014 +0000
- Revision:
- 0:148fca6fd246
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:148fca6fd246 | 1 | // BaseUseHostDebug.cpp 2014/4/21 |
va009039 | 0:148fca6fd246 | 2 | #include "USBHost.h" |
va009039 | 0:148fca6fd246 | 3 | #include "BaseUsbHostDebug.h" |
va009039 | 0:148fca6fd246 | 4 | |
va009039 | 0:148fca6fd246 | 5 | void print_td(FILE* stream, HCTD* td) |
va009039 | 0:148fca6fd246 | 6 | { |
va009039 | 0:148fca6fd246 | 7 | if (td == NULL) { |
va009039 | 0:148fca6fd246 | 8 | fprintf(stream, "TD %p:\n", td); |
va009039 | 0:148fca6fd246 | 9 | return; |
va009039 | 0:148fca6fd246 | 10 | } |
va009039 | 0:148fca6fd246 | 11 | uint32_t* p = reinterpret_cast<uint32_t*>(td); |
va009039 | 0:148fca6fd246 | 12 | fprintf(stream, "TD %p: %08X %08X %08X %08X", p, p[0], p[1], p[2], p[3]); |
va009039 | 0:148fca6fd246 | 13 | fprintf(stream, " ep=%p\n", td->ep); |
va009039 | 0:148fca6fd246 | 14 | uint8_t* bp = reinterpret_cast<uint8_t*>(p[1]); |
va009039 | 0:148fca6fd246 | 15 | uint8_t* be = reinterpret_cast<uint8_t*>(p[3]); |
va009039 | 0:148fca6fd246 | 16 | if (bp) { |
va009039 | 0:148fca6fd246 | 17 | fprintf(stream, "BF %p:", bp); |
va009039 | 0:148fca6fd246 | 18 | while(bp <= be) { |
va009039 | 0:148fca6fd246 | 19 | fprintf(stream, " %02X", *bp); |
va009039 | 0:148fca6fd246 | 20 | bp++; |
va009039 | 0:148fca6fd246 | 21 | } |
va009039 | 0:148fca6fd246 | 22 | fprintf(stream, "\n"); |
va009039 | 0:148fca6fd246 | 23 | } |
va009039 | 0:148fca6fd246 | 24 | } |
va009039 | 0:148fca6fd246 | 25 | |
va009039 | 0:148fca6fd246 | 26 | void print_ed(FILE* stream, HCED* ed) |
va009039 | 0:148fca6fd246 | 27 | { |
va009039 | 0:148fca6fd246 | 28 | uint32_t* p = reinterpret_cast<uint32_t*>(ed); |
va009039 | 0:148fca6fd246 | 29 | while(p) { |
va009039 | 0:148fca6fd246 | 30 | fprintf(stream, "ED %p: %08X %08X %08X %08X\n", p, p[0], p[1], p[2], p[3]); |
va009039 | 0:148fca6fd246 | 31 | HCTD* td = reinterpret_cast<HCTD*>(p[2] & ~3); |
va009039 | 0:148fca6fd246 | 32 | HCTD* tdtail = reinterpret_cast<HCTD*>(p[1]); |
va009039 | 0:148fca6fd246 | 33 | while(td != NULL && td != tdtail) { |
va009039 | 0:148fca6fd246 | 34 | print_td(stream, td); |
va009039 | 0:148fca6fd246 | 35 | td = td->Next; |
va009039 | 0:148fca6fd246 | 36 | } |
va009039 | 0:148fca6fd246 | 37 | p = reinterpret_cast<uint32_t*>(p[3]); |
va009039 | 0:148fca6fd246 | 38 | } |
va009039 | 0:148fca6fd246 | 39 | } |
va009039 | 0:148fca6fd246 | 40 | |
va009039 | 0:148fca6fd246 | 41 | void print_itd(FILE* stream, HCITD* itd) |
va009039 | 0:148fca6fd246 | 42 | { |
va009039 | 0:148fca6fd246 | 43 | if (itd == NULL) { |
va009039 | 0:148fca6fd246 | 44 | fprintf(stream, "ITD %p:\n", itd); |
va009039 | 0:148fca6fd246 | 45 | return; |
va009039 | 0:148fca6fd246 | 46 | } |
va009039 | 0:148fca6fd246 | 47 | uint32_t* p = reinterpret_cast<uint32_t*>(itd); |
va009039 | 0:148fca6fd246 | 48 | fprintf(stream, "ITD %p: %08X %08X %08X %08X", p, p[0], p[1], p[2], p[3]); |
va009039 | 0:148fca6fd246 | 49 | fprintf(stream, " ep=%p\n", itd->ep); |
va009039 | 0:148fca6fd246 | 50 | uint16_t* offset = reinterpret_cast<uint16_t*>(p+4); |
va009039 | 0:148fca6fd246 | 51 | fprintf(stream, "ITD %p: %04X %04X %04X %04X %04X %04X %04X %04X\n", offset, |
va009039 | 0:148fca6fd246 | 52 | offset[0], offset[1], offset[2], offset[3], offset[4], offset[5], offset[6], offset[7]); |
va009039 | 0:148fca6fd246 | 53 | } |
va009039 | 0:148fca6fd246 | 54 | |
va009039 | 0:148fca6fd246 | 55 | void print_ied(FILE* stream, HCED* ed) |
va009039 | 0:148fca6fd246 | 56 | { |
va009039 | 0:148fca6fd246 | 57 | uint32_t* p = reinterpret_cast<uint32_t*>(ed); |
va009039 | 0:148fca6fd246 | 58 | while(p) { |
va009039 | 0:148fca6fd246 | 59 | fprintf(stream, "ED %p: %08X %08X %08X %08X\n", p, p[0], p[1], p[2], p[3]); |
va009039 | 0:148fca6fd246 | 60 | HCITD* itd = reinterpret_cast<HCITD*>(p[2] & ~3); |
va009039 | 0:148fca6fd246 | 61 | HCITD* itdtail = reinterpret_cast<HCITD*>(p[1]); |
va009039 | 0:148fca6fd246 | 62 | while(itd != NULL && itd != itdtail) { |
va009039 | 0:148fca6fd246 | 63 | print_itd(stream, itd); |
va009039 | 0:148fca6fd246 | 64 | itd = itd->Next; |
va009039 | 0:148fca6fd246 | 65 | } |
va009039 | 0:148fca6fd246 | 66 | p = reinterpret_cast<uint32_t*>(p[3]); |
va009039 | 0:148fca6fd246 | 67 | } |
va009039 | 0:148fca6fd246 | 68 | } |
va009039 | 0:148fca6fd246 | 69 | |
va009039 | 0:148fca6fd246 | 70 | void print_bytes(FILE* stream, char* s, uint8_t* buf, int len) |
va009039 | 0:148fca6fd246 | 71 | { |
va009039 | 0:148fca6fd246 | 72 | fprintf(stream, "%s %d:", s, len); |
va009039 | 0:148fca6fd246 | 73 | for(int i = 0; i < len; i++) { |
va009039 | 0:148fca6fd246 | 74 | fprintf(stream, " %02X", buf[i]); |
va009039 | 0:148fca6fd246 | 75 | } |
va009039 | 0:148fca6fd246 | 76 | fprintf(stream, "\n"); |
va009039 | 0:148fca6fd246 | 77 | } |
va009039 | 0:148fca6fd246 | 78 | |
va009039 | 0:148fca6fd246 | 79 | void print_hex(FILE* stream, uint8_t* p, int len) |
va009039 | 0:148fca6fd246 | 80 | { |
va009039 | 0:148fca6fd246 | 81 | for(int i = 0; i < len; i++) { |
va009039 | 0:148fca6fd246 | 82 | if (i%16 == 0) { |
va009039 | 0:148fca6fd246 | 83 | fprintf(stream, "%p:", p); |
va009039 | 0:148fca6fd246 | 84 | } |
va009039 | 0:148fca6fd246 | 85 | fprintf(stream, " %02X", *p); |
va009039 | 0:148fca6fd246 | 86 | p++; |
va009039 | 0:148fca6fd246 | 87 | if (i%16 == 15) { |
va009039 | 0:148fca6fd246 | 88 | fprintf(stream, "\n"); |
va009039 | 0:148fca6fd246 | 89 | } |
va009039 | 0:148fca6fd246 | 90 | } |
va009039 | 0:148fca6fd246 | 91 | fprintf(stream, "\n"); |
va009039 | 0:148fca6fd246 | 92 | } |
va009039 | 0:148fca6fd246 | 93 | |
va009039 | 0:148fca6fd246 | 94 | void assert_print(const char* pf, int line, const char* msg) { |
va009039 | 0:148fca6fd246 | 95 | fprintf(stderr, "\n\n%s@%d %s ASSERT!\n\n", pf, line, msg); |
va009039 | 0:148fca6fd246 | 96 | exit(1); |
va009039 | 0:148fca6fd246 | 97 | } |
va009039 | 0:148fca6fd246 | 98 |