Debugging library
MDebugger.h@0:57b729dee92c, 2014-06-25 (annotated)
- Committer:
- Gofs
- Date:
- Wed Jun 25 14:33:12 2014 +0000
- Revision:
- 0:57b729dee92c
Concept
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gofs | 0:57b729dee92c | 1 | #ifndef MDEBUGGER_H |
Gofs | 0:57b729dee92c | 2 | #define MDEBUGGER_H |
Gofs | 0:57b729dee92c | 3 | |
Gofs | 0:57b729dee92c | 4 | #ifdef __cplusplus |
Gofs | 0:57b729dee92c | 5 | extern "C" { |
Gofs | 0:57b729dee92c | 6 | #endif |
Gofs | 0:57b729dee92c | 7 | |
Gofs | 0:57b729dee92c | 8 | #include <stdint.h> |
Gofs | 0:57b729dee92c | 9 | #include <cmsis.h> |
Gofs | 0:57b729dee92c | 10 | |
Gofs | 0:57b729dee92c | 11 | #define MDEBUGGER_CIRCULAR_BUFFER_SIZE_IN_BYTES 32 |
Gofs | 0:57b729dee92c | 12 | #define MDEBUGGER_NUMBER_OF_ADDRESS_CHANNELS 2 |
Gofs | 0:57b729dee92c | 13 | |
Gofs | 0:57b729dee92c | 14 | /* @brief Function which user has to provide to put a character to the stream associated with given channel number. |
Gofs | 0:57b729dee92c | 15 | |
Gofs | 0:57b729dee92c | 16 | To make the MDebugger working this function has to be provided by the user. |
Gofs | 0:57b729dee92c | 17 | It will be called every time the debug library wants to send a character from the message which has to be passed. |
Gofs | 0:57b729dee92c | 18 | |
Gofs | 0:57b729dee92c | 19 | @param[in] data_byte A characted byte which has to be sent. |
Gofs | 0:57b729dee92c | 20 | @param[in] channel Channel number where the character byte has to be sent. |
Gofs | 0:57b729dee92c | 21 | |
Gofs | 0:57b729dee92c | 22 | */ |
Gofs | 0:57b729dee92c | 23 | void mdebug_putc(unsigned char data_byte, uint32_t channel); |
Gofs | 0:57b729dee92c | 24 | |
Gofs | 0:57b729dee92c | 25 | |
Gofs | 0:57b729dee92c | 26 | /* |
Gofs | 0:57b729dee92c | 27 | @brief Function which writes data to the output buffer of the MDebugger library. |
Gofs | 0:57b729dee92c | 28 | |
Gofs | 0:57b729dee92c | 29 | This function should be used if the user wants to send a binary data to the debug channel. |
Gofs | 0:57b729dee92c | 30 | Saying more precisely - to send data which can contain NULL character. |
Gofs | 0:57b729dee92c | 31 | This function is not parsing anything and is fastest than mdebug_printf version. |
Gofs | 0:57b729dee92c | 32 | Underneath this function there is a circular buffer which is used in the first place to store the data. |
Gofs | 0:57b729dee92c | 33 | If the buffer will fill to the maximum during copying data the mdebug_flush function will be called to write the data to the stream. |
Gofs | 0:57b729dee92c | 34 | |
Gofs | 0:57b729dee92c | 35 | @param[in] in_buffer Pointer to buffer which contains data to be send. |
Gofs | 0:57b729dee92c | 36 | @param[in] in_buffer_size Size of data in the passed buffer. |
Gofs | 0:57b729dee92c | 37 | @param[in] channel Channel number where the data has to be sent. |
Gofs | 0:57b729dee92c | 38 | */ |
Gofs | 0:57b729dee92c | 39 | void mdebug_write(unsigned char *in_buffer, uint32_t in_buffer_size, uint32_t channel); |
Gofs | 0:57b729dee92c | 40 | |
Gofs | 0:57b729dee92c | 41 | /* |
Gofs | 0:57b729dee92c | 42 | @brief Function which writes data straight to the output stream of the MDebugger library. |
Gofs | 0:57b729dee92c | 43 | |
Gofs | 0:57b729dee92c | 44 | This function should be used if the user wants to send a binary data to the debug channel. |
Gofs | 0:57b729dee92c | 45 | Saying more precisely - to send data which can contain NULL character. |
Gofs | 0:57b729dee92c | 46 | This function is not parsing anything and is fastest than mdebug_printf version. |
Gofs | 0:57b729dee92c | 47 | This is an unbuffered version of mdebug_write funtion which means that there is no circular buffer underneath it. |
Gofs | 0:57b729dee92c | 48 | This function will be passing the data straight to the stream. |
Gofs | 0:57b729dee92c | 49 | |
Gofs | 0:57b729dee92c | 50 | @param[in] in_buffer Pointer to buffer which contains data to be send. |
Gofs | 0:57b729dee92c | 51 | @param[in] in_buffer_size Size of data in the passed buffer. |
Gofs | 0:57b729dee92c | 52 | @param[in] channel Channel number where the data has to be sent. |
Gofs | 0:57b729dee92c | 53 | */ |
Gofs | 0:57b729dee92c | 54 | void mdebug_write_unbuffered(unsigned char *in_buffer, uint32_t in_buffer_size, uint32_t channel); |
Gofs | 0:57b729dee92c | 55 | |
Gofs | 0:57b729dee92c | 56 | /* |
Gofs | 0:57b729dee92c | 57 | @brief Function which parses the formatting string and after that writes it to the output buffer of the MDebugger library. |
Gofs | 0:57b729dee92c | 58 | |
Gofs | 0:57b729dee92c | 59 | This function should be used if the user wants to send a string message to the debug channel. |
Gofs | 0:57b729dee92c | 60 | This function parses the formatting string together with passed arguments fimilary to printf function. |
Gofs | 0:57b729dee92c | 61 | Because of parsing the string function is slower than the mdebug_write. |
Gofs | 0:57b729dee92c | 62 | Underneath this function there is a circular buffer which is used in the first place to store the data. |
Gofs | 0:57b729dee92c | 63 | If the buffer will fill to the maximum during copying data the mdebug_flush function will be called to write the data to the stream. |
Gofs | 0:57b729dee92c | 64 | |
Gofs | 0:57b729dee92c | 65 | @param[in] channel Channel number where the data has to be sent. |
Gofs | 0:57b729dee92c | 66 | @param[in] formatting_string Formatting string which will be used to construct the message together with passed arguments after it. |
Gofs | 0:57b729dee92c | 67 | */ |
Gofs | 0:57b729dee92c | 68 | void mdebug_printf(uint32_t channel, const char *formatting_string, ...); |
Gofs | 0:57b729dee92c | 69 | |
Gofs | 0:57b729dee92c | 70 | /* |
Gofs | 0:57b729dee92c | 71 | @brief Function which parses the formatting string and after that writes data straight to the output stream of the MDebugger library. |
Gofs | 0:57b729dee92c | 72 | |
Gofs | 0:57b729dee92c | 73 | This function should be used if the user wants to send a string message to the debug channel. |
Gofs | 0:57b729dee92c | 74 | This function parses the formatting string together with passed arguments fimilary to printf function. |
Gofs | 0:57b729dee92c | 75 | Because of parsing the string function is slower than the mdebug_write. |
Gofs | 0:57b729dee92c | 76 | This is an unbuffered version of mdebug_printf funtion which means that there is no circular buffer underneath it. |
Gofs | 0:57b729dee92c | 77 | This function will be passing the data straight to the stream. |
Gofs | 0:57b729dee92c | 78 | |
Gofs | 0:57b729dee92c | 79 | @param[in] channel Channel number where the data has to be sent. |
Gofs | 0:57b729dee92c | 80 | @param[in] formatting_string Formatting string which will be used to construct the message together with passed arguments after it. |
Gofs | 0:57b729dee92c | 81 | */ |
Gofs | 0:57b729dee92c | 82 | void mdebug_printf_unbuffered(uint32_t channel, const char *formatting_string, ...); |
Gofs | 0:57b729dee92c | 83 | |
Gofs | 0:57b729dee92c | 84 | /* |
Gofs | 0:57b729dee92c | 85 | @brief Function which flushes the circular buffer assigned to given channel (sends the data to the stream). |
Gofs | 0:57b729dee92c | 86 | |
Gofs | 0:57b729dee92c | 87 | @param[in] channel Channel number which circular buffer will be flushed. |
Gofs | 0:57b729dee92c | 88 | */ |
Gofs | 0:57b729dee92c | 89 | void mdebug_flush(uint32_t channel); |
Gofs | 0:57b729dee92c | 90 | |
Gofs | 0:57b729dee92c | 91 | /* |
Gofs | 0:57b729dee92c | 92 | @brief Function which showes how much space is used within the circular buffer on a given channel. |
Gofs | 0:57b729dee92c | 93 | |
Gofs | 0:57b729dee92c | 94 | @param[in] channel Channel number to calculate used space of circular buffer. |
Gofs | 0:57b729dee92c | 95 | @returns Used space in circular buffer assigned to given channel in bytes. |
Gofs | 0:57b729dee92c | 96 | */ |
Gofs | 0:57b729dee92c | 97 | uint32_t mdebug_output_bufer_used_space(uint32_t channel); |
Gofs | 0:57b729dee92c | 98 | |
Gofs | 0:57b729dee92c | 99 | /* |
Gofs | 0:57b729dee92c | 100 | @brief Function which showes how much space is free within the circular buffer on a given channel. |
Gofs | 0:57b729dee92c | 101 | |
Gofs | 0:57b729dee92c | 102 | @param[in] channel Channel number to calculate free space of circular buffer. |
Gofs | 0:57b729dee92c | 103 | @returns Free space in circular buffer assigned to given channel in bytes. |
Gofs | 0:57b729dee92c | 104 | */ |
Gofs | 0:57b729dee92c | 105 | uint32_t mdebug_output_buffer_free_space(uint32_t channel); |
Gofs | 0:57b729dee92c | 106 | |
Gofs | 0:57b729dee92c | 107 | |
Gofs | 0:57b729dee92c | 108 | /* |
Gofs | 0:57b729dee92c | 109 | @brief Function which checks is the circular buffer of a given channel empty. |
Gofs | 0:57b729dee92c | 110 | |
Gofs | 0:57b729dee92c | 111 | @param[in] channel Channel number to check is it empty. |
Gofs | 0:57b729dee92c | 112 | @return 0 Circular buffer assigned to given channel is not empty. |
Gofs | 0:57b729dee92c | 113 | @return 1 Circular buffer assigned to given channel is empty. |
Gofs | 0:57b729dee92c | 114 | */ |
Gofs | 0:57b729dee92c | 115 | uint32_t mdebug_output_buffer_is_empty(uint32_t channel); |
Gofs | 0:57b729dee92c | 116 | |
Gofs | 0:57b729dee92c | 117 | /* |
Gofs | 0:57b729dee92c | 118 | @brief Function which prints information about the Cortex core. |
Gofs | 0:57b729dee92c | 119 | |
Gofs | 0:57b729dee92c | 120 | This function prints to default channel 0 all information about the core at the stage of calling this function. |
Gofs | 0:57b729dee92c | 121 | */ |
Gofs | 0:57b729dee92c | 122 | void mdebug_print_system_info(void); |
Gofs | 0:57b729dee92c | 123 | |
Gofs | 0:57b729dee92c | 124 | #ifdef __cplusplus |
Gofs | 0:57b729dee92c | 125 | } |
Gofs | 0:57b729dee92c | 126 | #endif |
Gofs | 0:57b729dee92c | 127 | |
Gofs | 0:57b729dee92c | 128 | #endif // MDEBUGGER_H |