Embedded System Design 2 - Project
|
Homebrew println/printf replacement "DeBugPrint". More...
#include <stdint.h>
#include <stdbool.h>
#include "em_usart.h"
Go to the source code of this file.
Macros | |
#define | DBPRINT_BUFFER_SIZE 80 |
Typedefs | |
typedef enum dbprint_colors | dbprint_color_t |
Enumerations | |
enum | dbprint_colors { RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, DEFAULT_COLOR } |
Functions | |
void | dbprint_INIT (USART_TypeDef *pointer, uint8_t location, bool vcom, bool interrupts) |
Initialize USARTx. More... | |
void | dbAlert (void) |
Sound an alert in the terminal. More... | |
void | dbClear (void) |
Clear the terminal. More... | |
void | dbprint (char *message) |
Print a string (char array) to USARTx. More... | |
void | dbprintln (char *message) |
Print a string (char array) to USARTx and go to the next line. More... | |
void | dbprintInt (int32_t value) |
Print a number in decimal notation to USARTx. More... | |
void | dbprintlnInt (int32_t value) |
Print a number in decimal notation to USARTx and go to the next line. More... | |
void | dbprintInt_hex (int32_t value) |
Print a number in hexadecimal notation to USARTx. More... | |
void | dbprintlnInt_hex (int32_t value) |
Print a number in hexadecimal notation to USARTx and go to the next line. More... | |
void | dbprint_color (char *message, dbprint_color_t color) |
Print a string (char array) to USARTx in a given color. More... | |
void | dbprintln_color (char *message, dbprint_color_t color) |
Print a string (char array) to USARTx in a given color and go to the next line. More... | |
void | dbinfo (char *message) |
Print an info string (char array) to USARTx and go to the next line. More... | |
void | dbwarn (char *message) |
Print a warning string (char array) in yellow to USARTx and go to the next line. More... | |
void | dbcrit (char *message) |
Print a critical error string (char array) in red to USARTx and go to the next line. More... | |
void | dbinfoInt (char *message1, int32_t value, char *message2) |
Print an info value surrounded by two strings (char array) to USARTx. More... | |
void | dbwarnInt (char *message1, int32_t value, char *message2) |
Print a warning value surrounded by two strings (char array) to USARTx. More... | |
void | dbcritInt (char *message1, int32_t value, char *message2) |
Print a critical value surrounded by two strings (char array) to USARTx. More... | |
void | dbinfoInt_hex (char *message1, int32_t value, char *message2) |
Print an info value surrounded by two strings (char array) to USARTx. More... | |
void | dbwarnInt_hex (char *message1, int32_t value, char *message2) |
Print a warning value surrounded by two strings (char array) to USARTx. More... | |
void | dbcritInt_hex (char *message1, int32_t value, char *message2) |
Print a critical value surrounded by two strings (char array) to USARTx. More... | |
char | dbReadChar (void) |
Read a character from USARTx. More... | |
uint8_t | dbReadInt (void) |
Read a decimal character from USARTx and convert it to a uint8_t value. More... | |
void | dbReadLine (char *buf) |
Read a string (char array) from USARTx. More... | |
bool | dbGet_RXstatus (void) |
Check if data was received using interrupts in the RX buffer. More... | |
void | dbGet_RXbuffer (char *buf) |
Get the value of the RX buffer and clear the dataReceived flag. More... | |
Homebrew println/printf replacement "DeBugPrint".
Copyright (C) 2019 - Brecht Van Eeckhoudt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License can be found in the LICENSE
file along with this source code.
Some methods also use code obtained from examples from Silicon Labs' GitHub. These sections are licensed under the Silabs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.
Definition in file dbprint.h.
#define DBPRINT_BUFFER_SIZE 80 |
typedef enum dbprint_colors dbprint_color_t |
Enum type for the color selection.
enum dbprint_colors |
Enum type for the color selection.
Enumerator | |
---|---|
RED | |
GREEN | |
BLUE | |
CYAN | |
MAGENTA | |
YELLOW | |
DEFAULT_COLOR |
Definition at line 52 of file dbprint.h.
void dbAlert | ( | void | ) |
void dbClear | ( | void | ) |
void dbcrit | ( | char * | message | ) |
Print a critical error string (char array) in red to USARTx and go to the next line.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message | The string to print to USARTx. |
Definition at line 539 of file dbprint.c.
void dbcritInt | ( | char * | message1, |
int32_t | value, | ||
char * | message2 | ||
) |
Print a critical value surrounded by two strings (char array) to USARTx.
"CRIT: " gets added in front, the decimal notation is used and the function advances to the next line. The value is in the color white, the rest is red.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message1 | The first part of the string to print to USARTx. |
[in] | value | The value to print between the two string parts. |
[in] | message2 | The second part of the string to print to USARTx. |
Definition at line 629 of file dbprint.c.
void dbcritInt_hex | ( | char * | message1, |
int32_t | value, | ||
char * | message2 | ||
) |
Print a critical value surrounded by two strings (char array) to USARTx.
"CRIT: " gets added in front, the hexadecimal notation is used and the function advances to the next line. The value is in the color white, the rest is red.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message1 | The first part of the string to print to USARTx. |
[in] | value | The value to print between the two string parts. |
[in] | message2 | The second part of the string to print to USARTx. |
Definition at line 721 of file dbprint.c.
void dbGet_RXbuffer | ( | char * | buf | ) |
Get the value of the RX buffer and clear the dataReceived
flag.
[in] | buf | The buffer to put the resulting string in. This needs to have a length of DBPRINT_BUFFER_SIZE for the function to work properly: char buf[DBPRINT_BUFFER_SIZE]; ! |
Definition at line 1017 of file dbprint.c.
bool dbGet_RXstatus | ( | void | ) |
Check if data was received using interrupts in the RX buffer.
true
- Data is received in the RX buffer. false
- No data is received. Definition at line 909 of file dbprint.c.
void dbinfo | ( | char * | message | ) |
Print an info string (char array) to USARTx and go to the next line.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message | The string to print to USARTx. |
Definition at line 503 of file dbprint.c.
void dbinfoInt | ( | char * | message1, |
int32_t | value, | ||
char * | message2 | ||
) |
Print an info value surrounded by two strings (char array) to USARTx.
"INFO: " gets added in front, the decimal notation is used and the function advances to the next line.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message1 | The first part of the string to print to USARTx. |
[in] | value | The value to print between the two string parts. |
[in] | message2 | The second part of the string to print to USARTx. |
Definition at line 567 of file dbprint.c.
void dbinfoInt_hex | ( | char * | message1, |
int32_t | value, | ||
char * | message2 | ||
) |
Print an info value surrounded by two strings (char array) to USARTx.
"INFO: " gets added in front, the hexadecimal notation is used and the function advances to the next line.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message1 | The first part of the string to print to USARTx. |
[in] | value | The value to print between the two string parts. |
[in] | message2 | The second part of the string to print to USARTx. |
Definition at line 659 of file dbprint.c.
void dbprint | ( | char * | message | ) |
void dbprint_color | ( | char * | message, |
dbprint_color_t | color | ||
) |
Print a string (char array) to USARTx in a given color.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message | The string to print to USARTx. |
[in] | color | The color to print the text in. |
Definition at line 421 of file dbprint.c.
void dbprint_INIT | ( | USART_TypeDef * | pointer, |
uint8_t | location, | ||
bool | vcom, | ||
bool | interrupts | ||
) |
Initialize USARTx.
[in] | pointer | Pointer to USARTx. |
[in] | location | Location for pin routing. |
[in] | vcom |
|
[in] | interrupts |
|
Definition at line 148 of file dbprint.c.
void dbprintInt | ( | int32_t | value | ) |
Print a number in decimal notation to USARTx.
[in] | value | The number to print to USARTx. This can be of type uint32_t or int32_t . |
Definition at line 738 of file dbprint.c.
void dbprintInt_hex | ( | int32_t | value | ) |
Print a number in hexadecimal notation to USARTx.
[in] | value | The number to print to USARTx. This can be of type uint32_t or int32_t . |
Definition at line 794 of file dbprint.c.
void dbprintln | ( | char * | message | ) |
void dbprintln_color | ( | char * | message, |
dbprint_color_t | color | ||
) |
Print a string (char array) to USARTx in a given color and go to the next line.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message | The string to print to USARTx. |
[in] | color | The color to print the text in. |
Definition at line 480 of file dbprint.c.
void dbprintlnInt | ( | int32_t | value | ) |
Print a number in decimal notation to USARTx and go to the next line.
[in] | value | The number to print to USARTx. This can be of type uint32_t or int32_t . |
Definition at line 774 of file dbprint.c.
void dbprintlnInt_hex | ( | int32_t | value | ) |
Print a number in hexadecimal notation to USARTx and go to the next line.
[in] | value | The number to print to USARTx. This can be of type uint32_t or int32_t . |
Definition at line 811 of file dbprint.c.
char dbReadChar | ( | void | ) |
uint8_t dbReadInt | ( | void | ) |
Read a decimal character from USARTx and convert it to a uint8_t
value.
uint16_t
and uint32_t
values:uint16_t USART_RxDouble(USART_TypeDef *usart);
uint32_t USART_RxDoubleExt(USART_TypeDef *usart);
uint8_t
value. Definition at line 848 of file dbprint.c.
void dbReadLine | ( | char * | buf | ) |
Read a string (char array) from USARTx.
"CR"
(Carriage Return, ENTER) character is received or the maximum length (DBPRINT_BUFFER_SIZE
) is reached.[in] | buf | The buffer to put the resulting string in. This needs to have a length of DBPRINT_BUFFER_SIZE for the function to work properly: char buf[DBPRINT_BUFFER_SIZE]; ! |
Definition at line 872 of file dbprint.c.
void dbwarn | ( | char * | message | ) |
Print a warning string (char array) in yellow to USARTx and go to the next line.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message | The string to print to USARTx. |
Definition at line 521 of file dbprint.c.
void dbwarnInt | ( | char * | message1, |
int32_t | value, | ||
char * | message2 | ||
) |
Print a warning value surrounded by two strings (char array) to USARTx.
"WARN: " gets added in front, the decimal notation is used and the function advances to the next line. The value is in the color white, the rest is yellow.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message1 | The first part of the string to print to USARTx. |
[in] | value | The value to print between the two string parts. |
[in] | message2 | The second part of the string to print to USARTx. |
Definition at line 598 of file dbprint.c.
void dbwarnInt_hex | ( | char * | message1, |
int32_t | value, | ||
char * | message2 | ||
) |
Print a warning value surrounded by two strings (char array) to USARTx.
"WARN: " gets added in front, the hexadecimal notation is used and the function advances to the next line. The value is in the color white, the rest is yellow.
"Hello world!"
) but a char array, the input message (array) needs to end with NULL ("\0"
)![in] | message1 | The first part of the string to print to USARTx. |
[in] | value | The value to print between the two string parts. |
[in] | message2 | The second part of the string to print to USARTx. |
Definition at line 690 of file dbprint.c.