Test for SWO viewer library.

Dependencies:   SWO mbed

See here for more information.

Committer:
wim
Date:
Sat Dec 20 22:33:52 2014 +0000
Revision:
0:de9d7358fcd0
Child:
1:3308ab077592
Test for SWO viewer library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 0:de9d7358fcd0 1
wim 0:de9d7358fcd0 2 #include "mbed.h"
wim 0:de9d7358fcd0 3 #include "SWO.h"
wim 0:de9d7358fcd0 4
wim 0:de9d7358fcd0 5 //Single Wire Output(SWO) Test
wim 0:de9d7358fcd0 6 //Hook up to Host PC software ST-LINK Utility or Segger J-Link SWO viewer
wim 0:de9d7358fcd0 7 //
wim 0:de9d7358fcd0 8 #define D_SWO 1
wim 0:de9d7358fcd0 9
wim 0:de9d7358fcd0 10 DigitalOut myled(LED1);
wim 0:de9d7358fcd0 11
wim 0:de9d7358fcd0 12 Serial pc(SERIAL_TX, SERIAL_RX);
wim 0:de9d7358fcd0 13
wim 0:de9d7358fcd0 14 int main() {
wim 0:de9d7358fcd0 15 pc.printf("Hello World\n\r");
wim 0:de9d7358fcd0 16 // pc.printf("\r\nMy Program - build " MBED_BUILD_TIMESTAMP "\r\n");
wim 0:de9d7358fcd0 17 pc.printf("\r\nMy Program - (partial) build " __DATE__ " " __TIME__ "\r\n");
wim 0:de9d7358fcd0 18 pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock);
wim 0:de9d7358fcd0 19
wim 0:de9d7358fcd0 20 #if (D_SWO == 1)
wim 0:de9d7358fcd0 21 SWO_PrintString("\r\nHello World from SWO\r\n");
wim 0:de9d7358fcd0 22 char message[64];
wim 0:de9d7358fcd0 23 sprintf(message, "CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock);
wim 0:de9d7358fcd0 24 SWO_PrintString(message);
wim 0:de9d7358fcd0 25 #endif
wim 0:de9d7358fcd0 26
wim 0:de9d7358fcd0 27 while(1) {
wim 0:de9d7358fcd0 28 myled = 1; // LED is ON
wim 0:de9d7358fcd0 29 wait(0.2); // 200 ms
wim 0:de9d7358fcd0 30 myled = 0; // LED is OFF
wim 0:de9d7358fcd0 31 wait(1.0); // 1 sec
wim 0:de9d7358fcd0 32
wim 0:de9d7358fcd0 33 #if (D_SWO == 1)
wim 0:de9d7358fcd0 34 // SWO_PrintString("#");
wim 0:de9d7358fcd0 35 SWO_PrintChar('+');
wim 0:de9d7358fcd0 36 #endif
wim 0:de9d7358fcd0 37
wim 0:de9d7358fcd0 38 }
wim 0:de9d7358fcd0 39 }
wim 0:de9d7358fcd0 40