DAP(Debug Access Port) interface
Dependents: USBMSD_LPC_HelloWorld lpcterm2 Simple-CMSIS-DAP 11u35_usbLocalFilesystem
BaseDAP.h@0:76588be01e71, 2013-09-14 (annotated)
- Committer:
- va009039
- Date:
- Sat Sep 14 11:21:12 2013 +0000
- Revision:
- 0:76588be01e71
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:76588be01e71 | 1 | // BaseDAP.h 2013/9/14 |
va009039 | 0:76588be01e71 | 2 | #pragma once |
va009039 | 0:76588be01e71 | 3 | #include "SWD.h" |
va009039 | 0:76588be01e71 | 4 | #include "TransferCore.h" |
va009039 | 0:76588be01e71 | 5 | |
va009039 | 0:76588be01e71 | 6 | // DAP Status Code |
va009039 | 0:76588be01e71 | 7 | #define DAP_OK 0 |
va009039 | 0:76588be01e71 | 8 | #define DAP_ERROR 0xFF |
va009039 | 0:76588be01e71 | 9 | |
va009039 | 0:76588be01e71 | 10 | // DAP Port |
va009039 | 0:76588be01e71 | 11 | #define DAP_PORT_AUTODETECT 0 // Autodetect Port |
va009039 | 0:76588be01e71 | 12 | #define DAP_PORT_DISABLED 0 // Port Disabled (I/O pins in High-Z) |
va009039 | 0:76588be01e71 | 13 | #define DAP_PORT_SWD 1 // SWD Port (SWCLK, SWDIO) + nRESET |
va009039 | 0:76588be01e71 | 14 | |
va009039 | 0:76588be01e71 | 15 | /** DAP(Debug Access Port) interface |
va009039 | 0:76588be01e71 | 16 | * |
va009039 | 0:76588be01e71 | 17 | * Example: |
va009039 | 0:76588be01e71 | 18 | * @code |
va009039 | 0:76588be01e71 | 19 | * #include "BaseDAP.h" |
va009039 | 0:76588be01e71 | 20 | * #include "USBDAP.h" |
va009039 | 0:76588be01e71 | 21 | * |
va009039 | 0:76588be01e71 | 22 | * USBDAP hid(64, 64, 0x0d28, 0x0204); |
va009039 | 0:76588be01e71 | 23 | * |
va009039 | 0:76588be01e71 | 24 | * SWD swd(p21,p22,p17); // SWDIO(dp12),SWCLK(dp3),nReset(dp23) |
va009039 | 0:76588be01e71 | 25 | * DigitalOut connected(LED1); |
va009039 | 0:76588be01e71 | 26 | * DigitalOut running(LED2); |
va009039 | 0:76588be01e71 | 27 | * class myDAP : public BaseDAP { |
va009039 | 0:76588be01e71 | 28 | * public: |
va009039 | 0:76588be01e71 | 29 | * myDAP(SWD* swd):BaseDAP(swd){}; |
va009039 | 0:76588be01e71 | 30 | * virtual void infoLED(int select, int value) { |
va009039 | 0:76588be01e71 | 31 | * switch(select) { |
va009039 | 0:76588be01e71 | 32 | * case 0: connected = value; break; |
va009039 | 0:76588be01e71 | 33 | * case 1: running = value; break; |
va009039 | 0:76588be01e71 | 34 | * } |
va009039 | 0:76588be01e71 | 35 | * } |
va009039 | 0:76588be01e71 | 36 | * }; |
va009039 | 0:76588be01e71 | 37 | * |
va009039 | 0:76588be01e71 | 38 | * int main() |
va009039 | 0:76588be01e71 | 39 | * { |
va009039 | 0:76588be01e71 | 40 | * HID_REPORT recv_report; |
va009039 | 0:76588be01e71 | 41 | * HID_REPORT send_report; |
va009039 | 0:76588be01e71 | 42 | * |
va009039 | 0:76588be01e71 | 43 | * myDAP* dap = new myDAP(&swd); |
va009039 | 0:76588be01e71 | 44 | * while(1) { |
va009039 | 0:76588be01e71 | 45 | * if(hid.readNB(&recv_report)) { |
va009039 | 0:76588be01e71 | 46 | * dap->Command(recv_report.data, send_report.data); |
va009039 | 0:76588be01e71 | 47 | * send_report.length = 64; |
va009039 | 0:76588be01e71 | 48 | * hid.send(&send_report); |
va009039 | 0:76588be01e71 | 49 | * } |
va009039 | 0:76588be01e71 | 50 | * } |
va009039 | 0:76588be01e71 | 51 | * } |
va009039 | 0:76588be01e71 | 52 | * @endcode |
va009039 | 0:76588be01e71 | 53 | */ |
va009039 | 0:76588be01e71 | 54 | class BaseDAP { |
va009039 | 0:76588be01e71 | 55 | public: |
va009039 | 0:76588be01e71 | 56 | /** Create a DAP(Debug Access Port) interface |
va009039 | 0:76588be01e71 | 57 | * @param swd assign SWD interface |
va009039 | 0:76588be01e71 | 58 | */ |
va009039 | 0:76588be01e71 | 59 | BaseDAP(SWD* swd); |
va009039 | 0:76588be01e71 | 60 | virtual ~BaseDAP(); |
va009039 | 0:76588be01e71 | 61 | /** Process command |
va009039 | 0:76588be01e71 | 62 | * @param request request data(64 bytes) |
va009039 | 0:76588be01e71 | 63 | * @param response response data(64 bytes) |
va009039 | 0:76588be01e71 | 64 | * @returns response length |
va009039 | 0:76588be01e71 | 65 | */ |
va009039 | 0:76588be01e71 | 66 | int Command(uint8_t* request, uint8_t* response); |
va009039 | 0:76588be01e71 | 67 | protected: |
va009039 | 0:76588be01e71 | 68 | virtual const char* getInfo(int id); |
va009039 | 0:76588be01e71 | 69 | /** LED indicator |
va009039 | 0:76588be01e71 | 70 | * @param selct 0...connected LED, 1...running LED |
va009039 | 0:76588be01e71 | 71 | * @param value 0...OFF, 1...ON |
va009039 | 0:76588be01e71 | 72 | */ |
va009039 | 0:76588be01e71 | 73 | virtual void infoLED(int select, int value); |
va009039 | 0:76588be01e71 | 74 | |
va009039 | 0:76588be01e71 | 75 | virtual int Info(uint8_t* request, uint8_t* response); // 0x00 |
va009039 | 0:76588be01e71 | 76 | int LED(uint8_t* request, uint8_t* response); // 0x01 |
va009039 | 0:76588be01e71 | 77 | int Connect(uint8_t* request, uint8_t* response); // 0x02 |
va009039 | 0:76588be01e71 | 78 | int Disconnect(uint8_t* request, uint8_t* response); // 0x03 |
va009039 | 0:76588be01e71 | 79 | int TransferConfigure(uint8_t* request, uint8_t* response);// 0x04 |
va009039 | 0:76588be01e71 | 80 | int Transfer(uint8_t* request, uint8_t* response); // 0x05 |
va009039 | 0:76588be01e71 | 81 | int TransferBlock(uint8_t* request, uint8_t* response); // 0x06 |
va009039 | 0:76588be01e71 | 82 | |
va009039 | 0:76588be01e71 | 83 | int WriteABORT(uint8_t* request, uint8_t* response); // 0x08 |
va009039 | 0:76588be01e71 | 84 | int Delay(uint8_t* request, uint8_t* response); // 0x09 |
va009039 | 0:76588be01e71 | 85 | int ResetTarget(uint8_t* request, uint8_t* response); // 0x0A |
va009039 | 0:76588be01e71 | 86 | int SWJ_Pins(uint8_t* request, uint8_t* response); // 0x10 |
va009039 | 0:76588be01e71 | 87 | int SWJ_Clock(uint8_t* request, uint8_t* response); // 0x11 |
va009039 | 0:76588be01e71 | 88 | int SWJ_Sequence(uint8_t* request, uint8_t* response); // 0x12 |
va009039 | 0:76588be01e71 | 89 | int SWD_Configure(uint8_t* request, uint8_t* response); // 0x13 |
va009039 | 0:76588be01e71 | 90 | int Vendor0(uint8_t* request, uint8_t* response); // 0x80 |
va009039 | 0:76588be01e71 | 91 | /** vendor command |
va009039 | 0:76588be01e71 | 92 | */ |
va009039 | 0:76588be01e71 | 93 | virtual int Vendor(uint8_t* request, uint8_t* response);// 0x80-0x9f |
va009039 | 0:76588be01e71 | 94 | virtual int Invalid(uint8_t* request, uint8_t* response); |
va009039 | 0:76588be01e71 | 95 | |
va009039 | 0:76588be01e71 | 96 | TransferCore transfer; |
va009039 | 0:76588be01e71 | 97 | SWD* _swd; |
va009039 | 0:76588be01e71 | 98 | }; |