Debugging tool for mbed enabled microcontrollers, especially for NUCLEO-F303RE and STM32F042F6P6.

Revision:
23:e1ffe5277331
Parent:
22:ac9b2cbb31a8
Child:
24:014f13c3f871
--- a/Debug.h	Sun Mar 21 20:16:42 2021 +0000
+++ b/Debug.h	Sun Mar 21 20:32:26 2021 +0000
@@ -26,90 +26,114 @@
 
 //------------------------------------------------------------------------------------------------------------------
 /** Debug_serial class.
- *  Class for stepping the program and printing actual position of the running programme with optional print of one variable (int, float, char or char*).
+ *  Class for stepping the program, printing the curent position of breakpoint and optional print of one variable (int, float, char or char*).
  *  Functions printf, putc and getc are also defined in the class. \n
  *
- * Example program:
+ * Example program for STM32F042F6P6::
  * @code
  * // ----------------------------------------------------------------------------
+ * // Example program of Debug_serial class for STM32F042F6P6
  * // Author: Lukas Bielesch 
  * // Department of Measurement, Czech technical university in Prague, Czech Republic 
- * // Date of publication: 13. May 2019
+ * // Date of publication: 20. March 2021
  * // ----------------------------------------------------------------------------
+ * #include "mbed.h"
  * #include "Debug.h"
- * AnalogIn analog(PA_4);
- * PwmOut pwm(PA_6);
- * DigitalOut out(PA_5);
- * Debug_serial pc(PA_2, PA_3, 115200);
+ * 
+ * // two pwm generators based on one timer TIM1
+ * PwmOut led1(PA_7);
+ * PwmOut led2(PB_1);
+ * 
+ * // debug serial port on PA_2 and PA_3 with default baudrate of 115200 Bd/s
+ * Debug_serial pc(PA_2, PA_3); 
  * 
  * int main(){
- *     int var = 0;
- *     char character;
- *     out = 1;
- *     float pi = 3.14159265359;
- *     pc.breakpoint(__LINE__,name(pi),pi);
- *     char* arr = "this is string";
- *     pc.breakpoint(__LINE__,name(arr),arr);    
- *     pwm = 0.5;
- *     pwm.period(1);
- *     while(1){
- *         pc.breakpoint(__LINE__,name(var),var);
- *         pc.printf("insert character\n\r");
- *         while (!pc.readable()){}
- *         character = pc.getc();
- *         pc.printf("you have inserted %c\n\r",character);
- *         var++;
- *         pc.breakpoint(__LINE__, 0x48000000);
- *         wait(1);
- *     }
+ *     
+ *     float float_var = 3.14;
+ *     int int_var = 42;
+ *     char* str_var = "this is string";
+ *     
+ *     // class Debug_serial works as normal serial port
+ *     pc.printf("insert character\n\r");
+ *     while (!pc.readable()){}
+ *     pc.printf("you have inserted %c\n\r", pc.getc());
+ *     
+ *     
+ *     led1.period(1); // set period of led1 to 1s
+ *     led1 = 0.6; // set stride of led1 to 60% 
+ *     
+ *     // breakpoint with 3 parameters: line of the breakpoint, name and value of the variable to be shown
+ *     pc.breakpoint(__LINE__, name(float_var), float_var);
+ *     
+ *     // period of both LEDs is changed to 0.5s
+ *     led2.period(0.5);
+ *     
+ *     pc.breakpoint(__LINE__, name(int_var), int_var);
+ *     
+ *     // set stride of led2 to 40%
+ *     led2 = 0.4;
+ *     
+ *     pc.breakpoint(__LINE__, name(str_var), str_var);
+ *     
+ *     // period of both LEDs is changed to 2s 
+ *     led2.period(2);
+ *     
+ *     // breakpoint with 2 parameters: line of the breakpoint and address of 4-byte word to be read
+ *     pc.breakpoint(__LINE__, 0x48000000);
+ *     
+ *     
+ *     pc.printf("end of program\n\r");
+ *         
+ *     while(1){}
+ *     
  * }
  * @endcode
  */
 class Debug_serial {
 public:
 
-    /** Create object of Debug_serial class
+    /** Create object of Debug_serial class.
      * @param tx_pin TX pin of debug serial port
      * @param rx_pin RX pin of debug serial port
      * @param baudrate(optional) desired baudrate value of debug serial port, default baudrate is 115200 Bd/s
      */
     Debug_serial(PinName tx_pin, PinName rx_pin, int baudrate = 115200);
     
-    /** Perform one breakpoint without printing variable
-     * @param line_number(optional) line number of breakpoint,macro __LINE__ is recommended
+    /** Perform one breakpoint.
+     * @param line_number (optional) line number of breakpoint, macro __LINE__ could be used.
      */ 
     void breakpoint(int line_number = -1);
 
     /** Perform one breakpoint and print variable of type int
-     * @param line_number line number of breakpoint, macro __LINE__ is recommended
-     * @param name name of printed variable(max length is 19) , macro name(variable) is recommended
+     * @param line_number line number of breakpoint, macro __LINE__ could be used.
+     * @param name name of printed variable(max length is 19) , macro name(variable) could be used.
      * @param variable variable of type int
      */     
     void breakpoint(int line_number, char name[20], int variable);
     
     /** Perform one breakpoint and print variable of type char
-     * @param line_number line number of breakpoint, macro __LINE__ is recommended
-     * @param name name of printed variable(max length is 19) , macro name(variable) is recommended
+     * @param line_number line number of breakpoint, macro __LINE__ could be used.
+     * @param name name of printed variable(max length is 19) , macro name(variable) could be used.
      * @param variable variable of type int
      */     
     void breakpoint(int line_number, char name[20], char variable);
     
     /** Perform one breakpoint and print string variable
-     * @param line_number line number of breakpoint, macro __LINE__ is recommended
-     * @param name name of printed variable(max length is 19) , macro name(variable) is recommended
+     * @param line_number line number of breakpoint, macro __LINE__ could be used.
+     * @param name name of printed variable(max length is 19) , macro name(variable) could be used.
      * @param variable variable of type char*
      */     
     void breakpoint(int line_number, char name[20], char * variable);
     
     /** Perform one breakpoint and print variable of type float
-     * @param line_number line number of breakpoint, macro __LINE__ is recommended
-     * @param name name of printed variable(max length is 19) , macro name(variable) is recommended
+     * @param line_number line number of breakpoint, macro __LINE__ could be used.
+     * @param name name of printed variable(max length is 19) , macro name(variable) could be used.
      * @param variable variable of type float
      */ 
     void breakpoint(int line_number, char name[20], float variable);
     
     /** Perform one breakpoint and print one register value
-     * @param line_number line number of breakpoint, macro __LINE__ is recommended
+     * @param line_number line number of breakpoint, macro __LINE__ could be used.
      * @param address address of register, must be divisible by 4
      */ 
     void breakpoint(int line_number, uint32_t address);