semihost client example program

Dependencies:   mbed

Committer:
va009039
Date:
Thu Feb 20 09:23:19 2014 +0000
Revision:
0:7a8fdb1e6615
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:7a8fdb1e6615 1 #include "mbed.h"
va009039 0:7a8fdb1e6615 2
va009039 0:7a8fdb1e6615 3 DigitalOut led1(P0_1);
va009039 0:7a8fdb1e6615 4
va009039 0:7a8fdb1e6615 5 #define SYS_WRITEC 0x03
va009039 0:7a8fdb1e6615 6
va009039 0:7a8fdb1e6615 7 int semihost_putc(int c)
va009039 0:7a8fdb1e6615 8 {
va009039 0:7a8fdb1e6615 9 // LPC810 cannot access core debug register by self.
va009039 0:7a8fdb1e6615 10 return __semihost(SYS_WRITEC, &c);
va009039 0:7a8fdb1e6615 11 }
va009039 0:7a8fdb1e6615 12 // semihosting client
va009039 0:7a8fdb1e6615 13 int main() {
va009039 0:7a8fdb1e6615 14 const char* msg = "Hello from LPC810.";
va009039 0:7a8fdb1e6615 15 while(1) {
va009039 0:7a8fdb1e6615 16 for(const char* p = msg; *p; p++) {
va009039 0:7a8fdb1e6615 17 semihost_putc(*p);
va009039 0:7a8fdb1e6615 18 led1 = !led1;
va009039 0:7a8fdb1e6615 19 wait_ms(200);
va009039 0:7a8fdb1e6615 20 }
va009039 0:7a8fdb1e6615 21 }
va009039 0:7a8fdb1e6615 22 }