CuVoodoo STM32F1 firmware template
Macros | Functions | Variables
print.h File Reference

printing utilities to replace the large printf from the standard library (API) More...

Go to the source code of this file.

Macros

#define PRINT_ERROR_NONE   0
 no error occurred
 
#define PRINT_ERROR_MALFORMED   0x1
 input format string is malformed
 
#define PRINT_ERROR_UNSUPPORTED   0x2
 input format string is not supported
 
#define PRINT_ERROR_MAX   0x04
 maximum returned printed length reached but more has been printed
 
#define PRINT_ERROR_TRUNCATED   0x08
 output string size is not large enough to include complete printed string
 

Functions

size_t putc (char c)
 print a single character on user output More...
 
size_t printf (const char *format,...)
 print format string on user output More...
 
size_t snprintf (char *str, size_t size, const char *format,...)
 print format string on string or user output More...
 

Variables

uint8_t print_error
 flags to indicate which error(s) occurred within printf or snprintf
 

Detailed Description

printing utilities to replace the large printf from the standard library (API)

Note
use % as format specifier prefix, followed by + to enforce sign or 0x prefix, 0 followed by n for padding or forcing integer part of floating point number, . followed by n for number for fractional precision of floating point numbers, and format specifier format specifier supported are:
  • c for character
  • s for string
  • u for up to uint32_t unsigned integer
  • U for uint64_t unsigned integer
  • d for up to int32_t signed integer
  • D for int64_t signed integer
  • f for float and double floating point numbers
  • x for up to uint32_t lower case hexadecimal
  • X for uint64_t lower case hexadecimal
  • h for up to uint32_t upper case hexadecimal
  • H for uint64_t upper case hexadecimal
  • b for up to uint32_t bits
  • B for uint64_t bits
Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2017

Definition in file print.h.

Function Documentation

◆ printf()

size_t printf ( const char *  format,
  ... 
)

print format string on user output

Parameters
[in]formatformat string to be printed
[in]...arguments referenced by format string to be printed
Returns
number of characters printed

Definition at line 446 of file print.c.

◆ putc()

size_t putc ( char  c)

print a single character on user output

Warning
this must be implemented by the user (using the desired output interface)
Parameters
[in]ccharacter to be printed
Returns
number of characters printed

Definition at line 58 of file application.c.

◆ snprintf()

size_t snprintf ( char *  str,
size_t  size,
const char *  format,
  ... 
)

print format string on string or user output

Parameters
[out]strstring to print format string on, or user output if str is set to NULL (str will always be terminated with a null character '\0')
[in,out]sizesize of string (writes at most size characters on str, including the termination null character '\0')
[in]formatformat string to be printed
[in]...arguments referenced by format string to be printed
Returns
number of characters printed (a return value of size or more means that the output was truncated)

Definition at line 456 of file print.c.