Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SWO by
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 Thu Jul 14 2022 08:25:41 by
