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.
Dependents: USBMSD_LPC_HelloWorld lpcterm2 Simple-CMSIS-DAP 11u35_usbLocalFilesystem
BaseDAP.h
00001 // BaseDAP.h 2013/9/14 00002 #pragma once 00003 #include "SWD.h" 00004 #include "TransferCore.h" 00005 00006 // DAP Status Code 00007 #define DAP_OK 0 00008 #define DAP_ERROR 0xFF 00009 00010 // DAP Port 00011 #define DAP_PORT_AUTODETECT 0 // Autodetect Port 00012 #define DAP_PORT_DISABLED 0 // Port Disabled (I/O pins in High-Z) 00013 #define DAP_PORT_SWD 1 // SWD Port (SWCLK, SWDIO) + nRESET 00014 00015 /** DAP(Debug Access Port) interface 00016 * 00017 * Example: 00018 * @code 00019 * #include "BaseDAP.h" 00020 * #include "USBDAP.h" 00021 * 00022 * USBDAP hid(64, 64, 0x0d28, 0x0204); 00023 * 00024 * SWD swd(p21,p22,p17); // SWDIO(dp12),SWCLK(dp3),nReset(dp23) 00025 * DigitalOut connected(LED1); 00026 * DigitalOut running(LED2); 00027 * class myDAP : public BaseDAP { 00028 * public: 00029 * myDAP(SWD* swd):BaseDAP(swd){}; 00030 * virtual void infoLED(int select, int value) { 00031 * switch(select) { 00032 * case 0: connected = value; break; 00033 * case 1: running = value; break; 00034 * } 00035 * } 00036 * }; 00037 * 00038 * int main() 00039 * { 00040 * HID_REPORT recv_report; 00041 * HID_REPORT send_report; 00042 * 00043 * myDAP* dap = new myDAP(&swd); 00044 * while(1) { 00045 * if(hid.readNB(&recv_report)) { 00046 * dap->Command(recv_report.data, send_report.data); 00047 * send_report.length = 64; 00048 * hid.send(&send_report); 00049 * } 00050 * } 00051 * } 00052 * @endcode 00053 */ 00054 class BaseDAP { 00055 public: 00056 /** Create a DAP(Debug Access Port) interface 00057 * @param swd assign SWD interface 00058 */ 00059 BaseDAP(SWD* swd); 00060 virtual ~BaseDAP(); 00061 /** Process command 00062 * @param request request data(64 bytes) 00063 * @param response response data(64 bytes) 00064 * @returns response length 00065 */ 00066 int Command(uint8_t* request, uint8_t* response); 00067 protected: 00068 virtual const char* getInfo(int id); 00069 /** LED indicator 00070 * @param selct 0...connected LED, 1...running LED 00071 * @param value 0...OFF, 1...ON 00072 */ 00073 virtual void infoLED(int select, int value); 00074 00075 virtual int Info(uint8_t* request, uint8_t* response); // 0x00 00076 int LED(uint8_t* request, uint8_t* response); // 0x01 00077 int Connect(uint8_t* request, uint8_t* response); // 0x02 00078 int Disconnect(uint8_t* request, uint8_t* response); // 0x03 00079 int TransferConfigure(uint8_t* request, uint8_t* response);// 0x04 00080 int Transfer(uint8_t* request, uint8_t* response); // 0x05 00081 int TransferBlock(uint8_t* request, uint8_t* response); // 0x06 00082 00083 int WriteABORT(uint8_t* request, uint8_t* response); // 0x08 00084 int Delay(uint8_t* request, uint8_t* response); // 0x09 00085 int ResetTarget(uint8_t* request, uint8_t* response); // 0x0A 00086 int SWJ_Pins(uint8_t* request, uint8_t* response); // 0x10 00087 int SWJ_Clock(uint8_t* request, uint8_t* response); // 0x11 00088 int SWJ_Sequence(uint8_t* request, uint8_t* response); // 0x12 00089 int SWD_Configure(uint8_t* request, uint8_t* response); // 0x13 00090 int Vendor0(uint8_t* request, uint8_t* response); // 0x80 00091 /** vendor command 00092 */ 00093 virtual int Vendor(uint8_t* request, uint8_t* response);// 0x80-0x9f 00094 virtual int Invalid(uint8_t* request, uint8_t* response); 00095 00096 TransferCore transfer; 00097 SWD* _swd; 00098 };
Generated on Mon Jul 18 2022 08:44:24 by
1.7.2