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
Diff: SWO.cpp
- Revision:
- 3:e5af2e131b95
- Parent:
- 2:ef928f61a770
- Child:
- 4:53de8ef789f3
diff -r ef928f61a770 -r e5af2e131b95 SWO.cpp
--- a/SWO.cpp Sun Dec 21 15:09:10 2014 +0000
+++ b/SWO.cpp Tue Dec 23 21:05:52 2014 +0000
@@ -1,5 +1,6 @@
/* mbed SWO Library
* Copyright (c) 2014, v01: WH. Ported from Segger example (www.segger.com)
+ * v02: WH. Added Class with Stream support
*
* 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.
@@ -27,11 +28,47 @@
#include "mbed.h"
#include "SWO.h"
+//
+// This the Class implementation
+//
+
+/** Create and SWO interface for debugging that supports Stream
+ * @brief Currently works on nucleo ST-LINK using ST-Link Utility and other devices that support SWD/SWO using Segger SWO viewer
+ */
+SWO_Channel::SWO_Channel () {
+ //May want to add initialisation stuff here
+}
+
+/** Write a single character (Stream implementation)
+ *
+ * @param value character to be displayed
+ * @return value
+ */
+int SWO_Channel::_putc(int value) {
+
+ //Use CMSIS_core_DebugFunctions. See core_cm3.h
+ ITM_SendChar(value);
+
+ return value;
+}
+
+/** Get a single character (Stream implementation)
+ * @return -1 Not supported
+ */
+int SWO_Channel::_getc() {
+ return -1;
+}
+
+
+//
+//This is the classic implementation
+//
+
/**
* Defines for Cortex-M debug unit
*/
-#define ITM_STIM_U32(n) (*(volatile unsigned int*)(0xE0000000+4*n)) // Stimulus Port n Register word access
-#define ITM_STIM_U8(n) (*(volatile char*)(0xE0000000+4*n)) // Stimulus Port n Register byte access
+#define ITM_STIM_U32(n) (*(volatile unsigned int*) (0xE0000000+4*n)) // Stimulus Port n Register word access
+#define ITM_STIM_U8(n) (*(volatile unsigned char*)(0xE0000000+4*n)) // Stimulus Port n Register byte access
//#define ITM_STIM_U32_0 (*(volatile unsigned int*)0xE0000000) // Stimulus Port 0 Register word access
//#define ITM_STIM_U8_0 (*(volatile char*)0xE0000000) // Stimulus Port 0 Register byte access
#define ITM_ENA (*(volatile unsigned int*)0xE0000E00) // Trace Enable Ports Register
@@ -171,4 +208,7 @@
while (*s) {
SWO_PrintChar(*s++);
}
-}
\ No newline at end of file
+}
+
+
+
SWO viewer