CMSIS-DAP debug adapter

Dependencies:   BaseDAP SWD USBDAP USBDevice mbed

Fork of Simple-CMSIS-DAP by Norimasa Okamoto

SWDTG-LPC11U35-501
SWDIOp6(P0_8)
SWCLKp8(P0_7)
nRESETp30(P0_1)

main.cpp

Committer:
va009039
Date:
2015-07-05
Revision:
2:f9c48f0a3efe
Parent:
1:2957e24bb52f

File content as of revision 2:f9c48f0a3efe:

#include "mbed.h"
#include "USBDAP.h"
#include "BaseDAP.h"

#if defined(TARGET_MCU_LPC11U35_501)
SWD swd(p6, p8, p30); // SWDIO,SWCLK,nRESET
DigitalOut connected(LED1);
DigitalOut running(LED2);
#else
SWD swd(D12, D10, D6); // SWDIO,SWCLK,nRESET
DigitalOut connected(LED_GREEN);
DigitalOut running(LED_RED);
#endif

class myDAP : public BaseDAP {
public:
    myDAP(SWD* swd):BaseDAP(swd){};
    virtual void infoLED(int select, int value) {
        switch(select) {
            case 0:
                connected = value^1; 
                running = 1;
                break;
            case 1: 
                running = value^1; 
                connected = 1;
                break;
        }
    } 
};

int main() {
   USBDAP* hid = new USBDAP("CMSIS-DAP");
   myDAP* dap = new myDAP(&swd);
   while(1) {
        HID_REPORT recv_report;
        if(hid->readNB(&recv_report)) {
            HID_REPORT send_report;
            dap->Command(recv_report.data, send_report.data);
            send_report.length = 64;
            hid->send(&send_report);
        }
    }    
}