Kinetis SDK v.2.0 API Reference Manual
Rev. 0
NXP Semiconductors
|
This section describes the programming interface of the debug console driver.
The debug console enables debug log messages to be output via the specified peripheral with frequency of the peripheral source clock and base address at the specified baud rate. Additionally, it provides input and output functions to scan and print formatted data.
To initialize the debug console, call the DbgConsole_Init() function with these parameters. This function automatically enables the module and the clock.
Selects the supported debug console hardware device type, such as
After the initialization is successful, stdout and stdin are connected to the selected peripheral. The debug console state is stored in the debug_console_state_t structure, such as shown here:
This example shows how to call the DbgConsole_Init() given the user configuration structure:
The debug console provides input and output functions to scan and print formatted data.
flags | Description |
---|---|
- | Left-justified within the given field width. Right-justified is the default. |
+ | Forces to precede the result with a plus or minus sign (+ or -) even for positive numbers. By default, only negative numbers are preceded with a - sign. |
(space) | If no sign is going to be written, a blank space is inserted before the value. |
# | Used with o, x, or X specifiers the value is preceded with 0, 0x, or 0X respectively for values other than zero. Used with e, E and f, it forces the written output to contain a decimal point even if no digits would follow. By default, if no digits follow, no decimal point is written. Used with g or G the result is the same as with e or E but trailing zeros are not removed. |
0 | Left-pads the number with zeroes (0) instead of spaces, where padding is specified (see width sub-specifier). |
Width | Description |
---|---|
(number) | A minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated even if the result is larger. |
* | The width is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted. |
.precision | Description |
---|---|
.number | For integer specifiers (d, i, o, u, x, X) − precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated even if the result is longer. A precision of 0 means that no character is written for the value 0. For e, E, and f specifiers − this is the number of digits to be printed after the decimal point. For g and G specifiers − This is the maximum number of significant digits to be printed. For s − this is the maximum number of characters to be printed. By default, all characters are printed until the ending null character is encountered. For c type − it has no effect. When no precision is specified, the default is 1. If the period is specified without an explicit value for precision, 0 is assumed. |
.* | The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted. |
length | Description |
---|---|
Do not support |
specifier | Description |
---|---|
d or i | Signed decimal integer |
f | Decimal floating point |
F | Decimal floating point capital letters |
x | Unsigned hexadecimal integer |
X | Unsigned hexadecimal integer capital letters |
o | Signed octal |
b | Binary value |
p | Pointer address |
u | Unsigned decimal integer |
c | Character |
s | String of characters |
n | Nothing printed |
* | Description |
---|---|
An optional starting asterisk indicates that the data is to be read from the stream but ignored, i.e., it is not stored in the corresponding argument. |
width | Description |
---|---|
This specifies the maximum number of characters to be read in the current reading operation. |
length | Description |
---|---|
hh | The argument is interpreted as a signed character or unsigned character (only applies to integer specifiers: i, d, o, u, x, and X). |
h | The argument is interpreted as a short integer or unsigned short integer (only applies to integer specifiers: i, d, o, u, x, and X). |
l | The argument is interpreted as a long integer or unsigned long integer for integer specifiers (i, d, o, u, x, and X), and as a wide character or wide character string for specifiers c and s. |
ll | The argument is interpreted as a long long integer or unsigned long long integer for integer specifiers (i, d, o, u, x, and X), and as a wide character or wide character string for specifiers c and s. |
L | The argument is interpreted as a long double (only applies to floating point specifiers: e, E, f, g, and G). |
j or z or t | Not supported |
specifier | Qualifying Input | Type of argument |
---|---|---|
c | Single character: Reads the next character. If a width different from 1 is specified, the function reads width characters and stores them in the successive locations of the array passed as argument. No null character is appended at the end. | char * |
i | Integer: : Number optionally preceded with a + or - sign | int * |
d | Decimal integer: Number optionally preceded with a + or - sign | int * |
a, A, e, E, f, F, g, G | Floating point: Decimal number containing a decimal point, optionally preceded by a + or - sign and optionally followed by the e or E character and a decimal number. Two examples of valid entries are -732.103 and 7.12e4 | float * |
o | Octal Integer: | int * |
s | String of characters. This reads subsequent characters until a white space is found (white space characters are considered to be blank, newline, and tab). | char * |
u | Unsigned decimal integer. | unsigned int * |
The debug console has its own printf/scanf/putchar/getchar functions which are defined in the header file:
This utility supports selecting toolchain's printf/scanf or the KSDK printf/scanf:
Statement prints the string format.
Statement prints the hexadecimal format/
Statement prints the decimal floating point and unsigned decimal.
If you want to use 'printf' and 'scanf' for GNUC Base, you should add file 'fsl_sbrk.c' in path: ..\{package}\devices\{subset}\utilities\fsl_sbrk.c to your project.
Modules | |
Semihosting | |