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
SWO_Channel Class Reference
An SWO interface for debugging that supports Stream. More...
#include <SWO.h>
Public Member Functions | |
SWO_Channel (const char *name=NULL) | |
Create an SWO interface for debugging that supports Stream. | |
bool | claim (FILE *stream=stdout) |
Function: claim. | |
int | putc (int c) |
Write a character to the display. | |
int | printf (const char *format,...) |
Write a formatted string to the display. | |
Protected Member Functions | |
virtual int | _putc (int value) |
Write a single character (Stream implementation) | |
virtual int | _getc () |
Get a single character (Stream implementation) |
Detailed Description
An SWO interface for debugging that supports Stream.
#include "mbed.h" #include "SWO.h" DigitalOut myled(LED1); Serial pc(SERIAL_TX, SERIAL_RX); SWO_Channel SWO(); int main() { pc.printf("Hello World\n\r"); SWO.printf("\r\nHello World from SWO\r\n"); SWO.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); while(1) { myled = 1; // LED is ON wait(0.2); // 200 ms myled = 0; // LED is OFF wait(1.0); // 1 sec SWO.putc('#'); } }
Currently works on nucleo ST-LINK using ST-Link Utility and other devices that support SWD/SWO using Segger SWO viewer
Definition at line 71 of file SWO.h.
Constructor & Destructor Documentation
SWO_Channel | ( | const char * | name = NULL ) |
Create an SWO interface for debugging that supports Stream.
Create and SWO interface for debugging that supports Stream.
- Parameters:
-
const char *name Channel name (default = none)
Currently works on nucleo ST-LINK using ST-Link Utility and other devices that support SWD/SWO using Segger SWO viewer
Member Function Documentation
int _getc | ( | ) | [protected, virtual] |
int _putc | ( | int | value ) | [protected, virtual] |
bool claim | ( | FILE * | stream = stdout ) |
Function: claim.
Claim and redirect a stream to this SWO object Important: A name parameter must have been added when creating the SWO object.
Redirect a stream to this SWO object
Important: A name parameter must have been added when creating the SWO object:
#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"); }
- Parameters:
-
FILE *stream The stream to redirect (default = stdout)
- Returns:
- true if succeeded, else false
- Parameters:
-
FILE *stream The stream to redirect (default = stdout)
- Returns:
- true if succeeded, else false
int printf | ( | const char * | format, |
... | |||
) |
Write a formatted string to the display.
- Parameters:
-
format A printf-style format string, followed by the variables to use in formatting the string.
int putc | ( | int | c ) |
Write a character to the display.
- Parameters:
-
c The character to write to the display
Generated on Wed Jul 13 2022 12:16:26 by 1.7.2