semihost server example program
Dependencies: SWD mbed USBLocalFileSystem BaseDAP USBDAP
LPCXpresso LPC11U68 | LPCXpresso LPC1549 | FRDM-KL46Z | EA LPC4088 QSB app-board | LPC1768 app-board | LPC810 | LPC1114FN28 | |
---|---|---|---|---|---|---|---|
server | server | server | server | server | client | client | |
SWDIO | D12 | D12 | D12 | p25 | p21 | p4(P0_2) | p12 |
SWCLK | D10 | D10 | D10 | p26 | p22 | p3(P0_3) | p3 |
nRESET *option | D6 | D6 | D6 | p34 | p30 | p1(P0_5) | p23 |
GND | GND | GND | GND | p1 | p1 | p7 | p22 |
3.3V | P3V3 | P3V3 | P3V3 | p44 | p40 | p6 | p21 |
flash write | SW2(P0_1) | SW3(P1_9) | SW1 | p14 joystick center | p14 joystick center |
client example:
Import programlpc810-semihost_helloworld
semihost client example program
tests/mytest.h
- Committer:
- va009039
- Date:
- 2014-06-22
- Revision:
- 18:5ed1759e863b
- Parent:
- 1:eb30547ba84d
File content as of revision 18:5ed1759e863b:
// mytest.h 2013/6/28 #pragma once #include "mbed_debug.h" class BaseTest { public: virtual void _run() = 0; char* m_a; char* m_b; int m_line; char* m_file; BaseTest* next; }; class reg { BaseTest* head; BaseTest* tail; reg() { head = NULL; tail = NULL; } public: static reg* inst() { static reg regtest; return ®test; } void add(BaseTest* test) { test->next = NULL; if (head == NULL) { head = test; tail = test; } else { tail->next = test; tail = test; } } int run_all_tests(char* a = "") { BaseTest* test = head; int pass = 0; int count = 0; char* file = ""; while(test) { if (strcmp(a, "") == 0 || strcmp(a, test->m_a) == 0) { if (strcmp(file, test->m_file) != 0) { file = test->m_file; debug("%s\n", file); } debug("TEST(%s,%s)@%d ... ",test->m_a, test->m_b, test->m_line); Timer t; t.start(); test->_run(); debug("OK (%d ms)\n", t.read_ms()); pass++; } test = test->next; count++; } debug("%d/%d TESTS PASSED!!!\n", pass, count); return 0; } }; #define TEST(A,B) \ class class_##A##_##B : public BaseTest { \ public: \ class_##A##_##B(char* a, char* b, char* file, int line) { \ m_a = a; m_b = b; \ m_file = file; m_line = line; \ reg::inst()->add(this); \ } \ virtual void _run(); \ }; \ class_##A##_##B instance_##A##_##B(#A,#B,__FILE__,__LINE__); \ void class_##A##_##B::_run() #define RUN_TEST(A,B) instance_##A##_##B._run() #define RUN_ALL_TESTS(A) reg::inst()->run_all_tests(#A) #define ASSERT_TRUE(A) if(A){}else{debug("\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);}; #ifndef DBG #define DBG(FMT, ...) do{debug("[%s:%d]"FMT"\r\n", __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);}while(0); #endif #define TEST_PRINT(FMT, ...) do{debug("[TEST: %d]"FMT"\r\n", __LINE__, ##__VA_ARGS__);}while(0);