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.
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
trace.cpp
00001 // trace.cpp - trace a message depending on verbose level 00002 // 00003 00004 #include <stdio.h> 00005 #include "bricks/trace.h" 00006 00007 static Serial pc(USBTX, USBRX); // serial port to PC terminal 00008 00009 //============================================================================== 00010 // Managing the Verbose Lewvel 00011 //============================================================================== 00012 00013 static int threshold = 0; // verbose threshold, no verbose messages 00014 00015 void verbose(O&o, int level) // setup verbose level 00016 { 00017 threshold = level; // update verbose threshold 00018 } 00019 00020 //============================================================================== 00021 // Printing Trace Messages 00022 //============================================================================== 00023 00024 void trace(O&o, int level, const char *msg) // trace a message 00025 { 00026 if (level <= threshold) // update verbose threshold 00027 { char buf[2] = " "; // must be terminated 00028 00029 for (; *msg; msg++) 00030 { buf[0] = *msg; 00031 printf(buf); 00032 if (*msg == '\n') 00033 { buf[0] = '\r'; // auto adding carriage return 00034 printf(buf); 00035 } 00036 } 00037 } 00038 } 00039 00040 void trace(O&o, int level, const char*format, int value) 00041 { 00042 char buf[80]; 00043 if (strlen(format) > 70) 00044 trace(o,level," *** buffer overflow *** "); 00045 else 00046 { sprintf(buf,format,value); 00047 trace(o,level,buf); 00048 } 00049 } 00050 00051 void traceln(O&o, int level, const char*msg) // trace with CR & LF 00052 { 00053 trace(o,level,msg); trace(o,level,"\r\n"); 00054 }
Generated on Sat Jul 16 2022 07:45:39 by
1.7.2
