Wim Huiskamp
/
mbed_nucleo_swo
Test for SWO viewer library.
See here for more information.
Diff: main.cpp
- Revision:
- 1:3308ab077592
- Parent:
- 0:de9d7358fcd0
- Child:
- 2:9c50385f83c5
--- a/main.cpp Sat Dec 20 22:33:52 2014 +0000 +++ b/main.cpp Tue Dec 23 21:06:11 2014 +0000 @@ -5,12 +5,19 @@ //Single Wire Output(SWO) Test //Hook up to Host PC software ST-LINK Utility or Segger J-Link SWO viewer // -#define D_SWO 1 +#define D_SWO 1 //Enable SWO output +#define D_STREAM 1 //Select Stream or Classic implementation + + +#if(D_STREAM == 1) +//Stream implementation DigitalOut myled(LED1); Serial pc(SERIAL_TX, SERIAL_RX); +SWO_Channel SWO; + int main() { pc.printf("Hello World\n\r"); // pc.printf("\r\nMy Program - build " MBED_BUILD_TIMESTAMP "\r\n"); @@ -18,12 +25,11 @@ pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); #if (D_SWO == 1) - SWO_PrintString("\r\nHello World from SWO\r\n"); - char message[64]; - sprintf(message, "CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); - SWO_PrintString(message); -#endif - +//Stream + SWO.printf("\r\nHello World from SWO\r\n"); + SWO.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); +#endif + while(1) { myled = 1; // LED is ON wait(0.2); // 200 ms @@ -31,10 +37,49 @@ wait(1.0); // 1 sec #if (D_SWO == 1) + //Stream + SWO.putc('#'); +#endif + + } +} + +#else +//Classic implementation + +DigitalOut myled(LED1); + +Serial pc(SERIAL_TX, SERIAL_RX); + +SWO_Channel SWO; + +int main() { + pc.printf("Hello World\n\r"); +// pc.printf("\r\nMy Program - build " MBED_BUILD_TIMESTAMP "\r\n"); + pc.printf("\r\nMy Program - (partial) build " __DATE__ " " __TIME__ "\r\n"); + pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); + +#if (D_SWO == 1) +//Classic + SWO_PrintString("\r\nHello World from SWO\r\n"); + char message[64]; + sprintf(message, "CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); + SWO_PrintString(message); +#endif + + while(1) { + myled = 1; // LED is ON + wait(0.2); // 200 ms + myled = 0; // LED is OFF + wait(1.0); // 1 sec + +#if (D_SWO == 1) +//Classic // SWO_PrintString("#"); SWO_PrintChar('+'); #endif } } +#endif