semihost server example program

Dependencies:   SWD mbed USBLocalFileSystem BaseDAP USBDAP

/media/uploads/va009039/kl46z-lpc800-360x480.jpg

LPCXpresso
LPC11U68
LPCXpresso
LPC1549
FRDM-KL46ZEA LPC4088 QSB
app-board
LPC1768
app-board
LPC810LPC1114FN28
serverserverserverserverserverclientclient
SWDIOD12D12D12p25p21p4(P0_2)p12
SWCLKD10D10D10p26p22p3(P0_3)p3
nRESET
*option
D6D6D6p34p30p1(P0_5)p23
GNDGNDGNDGNDp1p1p7p22
3.3VP3V3P3V3P3V3p44p40p6p21
flash writeSW2(P0_1)SW3(P1_9)SW1p14
joystick
center
p14
joystick
center

client example:

Import programlpc810-semihost_helloworld

semihost client example program

Committer:
va009039
Date:
Sun Jun 22 12:04:16 2014 +0000
Revision:
18:5ed1759e863b
Parent:
5:2774358f5e4f
add LPC11U68 interface.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 5:2774358f5e4f 1 // test2_BaseDAP.cpp 2013/9/13
va009039 5:2774358f5e4f 2 #if 0
va009039 5:2774358f5e4f 3 #include "BaseDAP.h"
va009039 5:2774358f5e4f 4 #include "USBDAP.h"
va009039 5:2774358f5e4f 5 #include "mytest.h"
va009039 5:2774358f5e4f 6 #include "mydebug.h"
va009039 5:2774358f5e4f 7
va009039 5:2774358f5e4f 8 Serial pc(USBTX, USBRX);
va009039 5:2774358f5e4f 9
va009039 5:2774358f5e4f 10 #ifdef TARGET_LPC1768
va009039 5:2774358f5e4f 11 SWD swd(p21,p22,p17); // SWDIO(dp12),SWCLK(dp3),nReset(dp23)
va009039 5:2774358f5e4f 12 DigitalOut connected(LED1);
va009039 5:2774358f5e4f 13 DigitalOut running(LED2);
va009039 5:2774358f5e4f 14 class myDAP : public BaseDAP {
va009039 5:2774358f5e4f 15 public:
va009039 5:2774358f5e4f 16 myDAP(SWD* swd):BaseDAP(swd){};
va009039 5:2774358f5e4f 17 virtual void infoLED(int select, int value) {
va009039 5:2774358f5e4f 18 switch(select) {
va009039 5:2774358f5e4f 19 case 0: connected = value; break;
va009039 5:2774358f5e4f 20 case 1: running = value; break;
va009039 5:2774358f5e4f 21 }
va009039 5:2774358f5e4f 22 }
va009039 5:2774358f5e4f 23 };
va009039 5:2774358f5e4f 24 #endif
va009039 5:2774358f5e4f 25
va009039 5:2774358f5e4f 26 #ifdef TARGET_KL25Z
va009039 5:2774358f5e4f 27 SWD swd(PTB8,PTB9,PTB10); // SWDIO(dp12),SWCLK(dp3),nReset(dp23)
va009039 5:2774358f5e4f 28 DigitalOut connected(LED_GREEN);
va009039 5:2774358f5e4f 29 DigitalOut running(LED_RED);
va009039 5:2774358f5e4f 30 class myDAP : public BaseDAP {
va009039 5:2774358f5e4f 31 public:
va009039 5:2774358f5e4f 32 myDAP(SWD* swd):BaseDAP(swd){};
va009039 5:2774358f5e4f 33 virtual void infoLED(int select, int value) {
va009039 5:2774358f5e4f 34 switch(select) {
va009039 5:2774358f5e4f 35 case 0:
va009039 5:2774358f5e4f 36 connected = value^1;
va009039 5:2774358f5e4f 37 running = 1;
va009039 5:2774358f5e4f 38 break;
va009039 5:2774358f5e4f 39 case 1:
va009039 5:2774358f5e4f 40 running = value^1;
va009039 5:2774358f5e4f 41 connected = 1;
va009039 5:2774358f5e4f 42 break;
va009039 5:2774358f5e4f 43 }
va009039 5:2774358f5e4f 44 }
va009039 5:2774358f5e4f 45 };
va009039 5:2774358f5e4f 46 #endif
va009039 5:2774358f5e4f 47
va009039 5:2774358f5e4f 48 myDAP* dap = NULL;
va009039 5:2774358f5e4f 49 USBDAP* hid = NULL;
va009039 5:2774358f5e4f 50
va009039 5:2774358f5e4f 51 HID_REPORT send_report;
va009039 5:2774358f5e4f 52 HID_REPORT recv_report;
va009039 5:2774358f5e4f 53
va009039 5:2774358f5e4f 54 TEST(DAP2,setup2) {
va009039 5:2774358f5e4f 55 dap = new myDAP(&swd);
va009039 5:2774358f5e4f 56 }
va009039 5:2774358f5e4f 57
va009039 5:2774358f5e4f 58 TEST(DAP2,setup3) {
va009039 5:2774358f5e4f 59 hid = new USBDAP(64, 64, 0x0d28, 0x0204);
va009039 5:2774358f5e4f 60 }
va009039 5:2774358f5e4f 61
va009039 5:2774358f5e4f 62 TEST(DAP2,test1) {
va009039 5:2774358f5e4f 63 ASSERT_TRUE(hid);
va009039 5:2774358f5e4f 64 ASSERT_TRUE(dap);
va009039 5:2774358f5e4f 65 if(hid->readNB(&recv_report)) {
va009039 5:2774358f5e4f 66 dap->Command(recv_report.data, send_report.data);
va009039 5:2774358f5e4f 67 send_report.length = 64;
va009039 5:2774358f5e4f 68 hid->send(&send_report);
va009039 5:2774358f5e4f 69 }
va009039 5:2774358f5e4f 70 }
va009039 5:2774358f5e4f 71
va009039 5:2774358f5e4f 72 static void hex_dump(uint8_t* buf, int size)
va009039 5:2774358f5e4f 73 {
va009039 5:2774358f5e4f 74 for(int i = 0; i < size; i++) {
va009039 5:2774358f5e4f 75 printf("%02x ", buf[i]);
va009039 5:2774358f5e4f 76 }
va009039 5:2774358f5e4f 77 printf("\n");
va009039 5:2774358f5e4f 78 }
va009039 5:2774358f5e4f 79
va009039 5:2774358f5e4f 80 TEST(DAP2,forever1) {
va009039 5:2774358f5e4f 81 while(1) {
va009039 5:2774358f5e4f 82 if(hid->readNB(&recv_report)) {
va009039 5:2774358f5e4f 83 //DBG("%02x", recv_report.data[0]);
va009039 5:2774358f5e4f 84 hex_dump(recv_report.data, 32);
va009039 5:2774358f5e4f 85 uint8_t cmd = recv_report.data[0];
va009039 5:2774358f5e4f 86 dap->Command(recv_report.data, send_report.data);
va009039 5:2774358f5e4f 87 send_report.length = 64;
va009039 5:2774358f5e4f 88 uint8_t* buf = send_report.data;
va009039 5:2774358f5e4f 89 DBG("%02x: %02x %02x %02x %02x %02x", cmd, buf[0], buf[1], buf[2], buf[3], buf[4]);
va009039 5:2774358f5e4f 90 bool r = hid->send(&send_report);
va009039 5:2774358f5e4f 91 ASSERT_TRUE(r);
va009039 5:2774358f5e4f 92 }
va009039 5:2774358f5e4f 93 }
va009039 5:2774358f5e4f 94 }
va009039 5:2774358f5e4f 95
va009039 5:2774358f5e4f 96 int main() {
va009039 5:2774358f5e4f 97 pc.baud(921600);
va009039 5:2774358f5e4f 98 //pc.baud(9600);
va009039 5:2774358f5e4f 99 DBG("%s", __FILE__);
va009039 5:2774358f5e4f 100
va009039 5:2774358f5e4f 101 RUN_ALL_TESTS();
va009039 5:2774358f5e4f 102 exit(0);
va009039 5:2774358f5e4f 103 }
va009039 5:2774358f5e4f 104 #endif