Serial Wire Output (SWO) viewer for tracing purposes. Tested on F401 and ST-LINK Utility as well as for F103 and Segger J-Link SWO viewer.

Dependents:   WiFi_Scanner mbed_nucleo_swo DISCO-F429ZI_LCDTS_demo_richard TEST_SM_SPEED

Revision:
4:53de8ef789f3
Parent:
3:e5af2e131b95
--- a/SWO.h	Tue Dec 23 21:05:52 2014 +0000
+++ b/SWO.h	Thu Aug 24 18:15:02 2017 +0000
@@ -1,6 +1,7 @@
 /* mbed SWO Library
  *  Copyright (c) 2014, v01: WH. Ported from Segger example
  *                      v02: WH. Added Class with Stream support
+ *                2017, v03: WH,PS. Added stream claim for stdout, proposed by Pavel Sorejs
  *
  * Simple implementation for tracing via Serial Wire Output(SWO) for Cortex-M processors.
  * It can be used with Host PC software such as ST-LINK Utility or Segger J-Link SWO viewer.
@@ -72,9 +73,35 @@
 public:
   /** Create an SWO interface for debugging that supports Stream
    *
+   * @param const char *name Channel name (default = none)   
    */
-  SWO_Channel();
+  SWO_Channel(const char *name=NULL);  
 
+ /**
+  * Function: claim
+  *
+  * Redirect a stream to this SWO object
+  *
+  * Important: A name parameter must have been added when creating the SWO object:
+  *
+  * @code
+  * #include "SWO.h"
+  * ...
+  * SWO_Channel pc("modser");
+  * 
+  * int main() {
+  *   pc.claim();            // capture <stdout>
+  *   pc.printf("Uses the SWO library\r\n");
+  *   printf("So does this!\r\n");
+  * }
+  * @endcode
+  *
+  * @ingroup API
+  * @param FILE *stream The stream to redirect (default = stdout)
+  * @return true if succeeded, else false
+  */  
+  bool claim(FILE *stream = stdout);
+  
 #if DOXYGEN_ONLY
   /** Write a character to the display
     *