Bsp_printf_full
Bsp_printf_full is based on open-source Tiny Printf implementation. This printf function supports most of the specifiers. Bsp_print_full is disabled by default. Bsp_printf_full can be enabled by setting the ENABLE_BSP_PRINTF_FULL to 1 in the bsp.h file. An example of calling bsp_printf_full to print out hex value of 0 x 10 is as follows:
bsp_printf_full(“Printing 0x10: %x”, 0x10)
The bsp_printf_full follows the following prototype:
%[flags][width][.precision][length]type
Note: By enabling ENABLE_BRIDGE_FULL_TO_LITE in
the bsp.h file and the bsp_printf is disabled, bsp_printf_full can
be called with bsp_printf instead. This would be beneficial if your program is already
using the bsp_printf but requires additional specifiers support that is supported only
in bsp_printf_full function.
| Type | Description |
|---|---|
| d or i | Signed decimal integer |
| u | Unsigned decimal integer |
| b | Unsigned binary |
| o | Unsigned octal |
| x | Unsigned hexadecimal integer (lowercase) |
| X | Unsigned hexadecimal integer (uppercase) |
| f or F | Decimal floating point |
| e or E | Scientific-notation (exponential) floating point |
| g or G | Scientific or decimal floating point |
| c | Single character |
| s | String of characters |
| P | Pointer address |
| % | A % followed by another % character output a single % |
| Flag | Description |
|---|---|
| - | Left-justify within the given field width; Right justification 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, b, x or X specifiers; the value is preceeded by 0, 0b, 0x or 0X respectively for values other than zero. |
| 0 | Left-pad fills the number with zeros (0) instead of space when padding is specified (see width sub-specifier). |
| Width | Description |
|---|---|
| (number) | Minimum number of characters to be printed. If the value to be printed is shorter than this number, then 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 string format, but as an additional integer value argument preceding the argument that has to be formatted. |
| Pecision | 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 zero (0)
means that no character is written for the value zero
(0). For f and F specifiers: This is
the number of digits to be printed after the decimal point.
By default, the minimum is 6 (six) and the maximum is 9
(nine). |
| .* | 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 | %d, %i | %u, %o, %x, %X |
|---|---|---|
| (none) | int | unsigned int |
| hh | char | unsigned char |
| h | short int | unsigned short int |
| l | long int | unsigned long int |
| ll | long long int | unsigned long long int (if Printf_Support_Long_Long is defined) |
| j | intmax_t | uintmax_t |
| z | size_t | size_t |
| t | ptrdiff_t | ptrdiff_t (if Printf_Support_Ptrdiff_T is defined) |