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.
Debug.h
- Committer:
- bieleluk
- Date:
- 2019-05-09
- Revision:
- 22:e63aa0ea925a
- Parent:
- 21:f685c7326727
- Child:
- 23:2e1f37405365
File content as of revision 22:e63aa0ea925a:
#pragma once // include files //------------------------------------------------------------------------------------------------------------------ #include "mbed.h" // macros //------------------------------------------------------------------------------------------------------------------ #define name(var) #var // assembly functions //------------------------------------------------------------------------------------------------------------------ extern "C" int check_1_bit(uint32_t gpiox, uint32_t offset, uint32_t pin); extern "C" int check_2_bit(uint32_t gpiox, uint32_t offset, uint32_t pin); extern "C" int check_alternative_mode(uint32_t gpiox, uint32_t offset, uint32_t pin); extern "C" int read_word(uint32_t address, uint32_t offset); // structs //------------------------------------------------------------------------------------------------------------------ typedef struct Pin { char port; int number; } pin_t; /** Debug_complete class. * Class for stepping programme and printing actual position and complete configuration of certain peripherals. * * Functions printf, putc and getc are also defined in the class. * * Example program: * @code * // ---------------------------------------------------------------------------- * // Author: Lukas Bielesch * // Department of Measurement, Czech technical university in Prague, Czech Republic * // Date of publication: 15. Apr 2019 * // ---------------------------------------------------------------------------- * #include "Debug.h" * AnalogIn analog(PA_5); * PwmOut pwm(PA_6); * DigitalOut out(PA_4); * Debug_complete pc(PA_2, PA_3, 115200); * * int main(){ * out = 1; * pc.breakpoint(__LINE__); * pwm = 0.5; * pwm.period(1); * analog.read_u16(); * while(1){ * pc.breakpoint(__LINE__); * wait(1); * pc.breakpoint(); * } * } * @endcode */ class Debug_complete { public: /** Create object of class Debug_complete * @param tx_pin TX pin of serial port of the board * @param rx_pin RX pin of serial port of the board * @param baudrate desired baudrate value of serial port */ Debug_complete(PinName tx_pin, PinName rx_pin, int baudrate = 115200); /** Perform one breakpoint * @param line_number line number of the breakpoint */ void breakpoint(int line_number = -1); private: // objects Serial pc; //debug serial device // variables int breakpoint_count; //stores number of the current breakpoint //functions // print alternate function of pin void print_af_mode( char portx, int pin_number, int af_mode); // show configuration of all pins void show_all_pins_config(); // show configuration of one pin void show_pin_config(pin_t pin); // print config of all timers void show_all_timers_config(); // print configuration of timer void show_tim_config(int timer); // print configuration of pin in pwm output mode void show_pwm_config(int timer, int channel); // print configuration of pin in analog input mode void show_analog_config(int channel); // print configuration of adc1 converter void show_adc1_config(); //print configuration of board's clock void show_clk_config(); // clear screen from m line up to n line //void clear_from_n_up_to_m(int m, int n); //initialization function void init(); void line(); };