CuVoodoo STM32F1 firmware template
Functions | Variables
print.c File Reference

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

Go to the source code of this file.

Functions

static void print_printed (size_t *length, size_t printed)
 add printed length to total printed length, and sets error if maximum size is exceeded More...
 
static size_t print_char (char **str, size_t *size, char c)
 print character More...
 
static size_t print_string (char **str, size_t *size, const char *s)
 print string More...
 
static size_t print_unsigned (char **str, size_t *size, uint64_t u, uint32_t padding, bool sign)
 print unsigned integer More...
 
static size_t print_signed (char **str, size_t *size, int64_t d, uint32_t padding, bool sign)
 print signed integer More...
 
static size_t print_float (char **str, size_t *size, double f, uint32_t padding, uint32_t fractional, bool sign)
 print floating number More...
 
static size_t print_nibble (char **str, size_t *size, uint8_t nibble, bool upcase)
 print nibble (half-byte) More...
 
static size_t print_hex (char **str, size_t *size, uint64_t hex, uint32_t padding, bool prefix, bool upcase)
 print hex value More...
 
static size_t print_bits (char **str, size_t *size, uint64_t u, uint32_t padding, bool prefix)
 print bits More...
 
static size_t vsnprintf (char **str, size_t *size, const char *format, va_list va)
 print format string on string or 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 (code)

Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2017

Definition in file print.c.

Function Documentation

◆ print_bits()

static size_t print_bits ( char **  str,
size_t *  size,
uint64_t  u,
uint32_t  padding,
bool  prefix 
)
static

print bits

Parameters
[out]strstring to print bits on (use NULL to print on user output)
[in,out]sizesize of string
[in]ubits to be printed
[in]paddingnumber of 0's to pad
[in]prefixif 0b prefix should be printed
Returns
number of characters printed

Definition at line 285 of file print.c.

◆ print_char()

static size_t print_char ( char **  str,
size_t *  size,
char  c 
)
static

print character

Parameters
[out]strstring to print character on (use NULL to print on user output)
[in,out]sizesize of string
[in]ccharacter to be printed
Returns
number of characters printed

Definition at line 55 of file print.c.

◆ print_float()

static size_t print_float ( char **  str,
size_t *  size,
double  f,
uint32_t  padding,
uint32_t  fractional,
bool  sign 
)
static

print floating number

Parameters
[out]strstring to print floating number on (use NULL to print on user output)
[in,out]sizesize of string
[in]ffloating number to be printed
[in]paddingnumber of 0's to pad
[in]fractionalnumbers of digits after the decimal point
[in]signif sign should be printed
Returns
number of characters printed

Definition at line 143 of file print.c.

◆ print_hex()

static size_t print_hex ( char **  str,
size_t *  size,
uint64_t  hex,
uint32_t  padding,
bool  prefix,
bool  upcase 
)
static

print hex value

Parameters
[out]strstring to print hex on (use NULL to print on user output)
[in,out]sizesize of string
[in]hexhex value to be printed
[in]paddingnumber of 0's to pad
[in]prefixif 0x prefix should be printed
[in]upcaseuse upcase digits (A-F)
Returns
number of characters printed

Definition at line 243 of file print.c.

◆ print_nibble()

static size_t print_nibble ( char **  str,
size_t *  size,
uint8_t  nibble,
bool  upcase 
)
static

print nibble (half-byte)

Parameters
[out]strstring to print nibble on (use NULL to print on user output)
[in,out]sizesize of string
[in]nibblenibble to be printed
[in]upcaseuse upcase digits (A-F)
Returns
number of characters printed

Definition at line 221 of file print.c.

◆ print_printed()

static void print_printed ( size_t *  length,
size_t  printed 
)
static

add printed length to total printed length, and sets error if maximum size is exceeded

Parameters
[in,out]lengthtotal printed length
[in]printedprinted length

Definition at line 36 of file print.c.

◆ print_signed()

static size_t print_signed ( char **  str,
size_t *  size,
int64_t  d,
uint32_t  padding,
bool  sign 
)
static

print signed integer

Parameters
[out]strstring to print signed integer on (use NULL to print on user output)
[in,out]sizesize of string
[in]dsigned integer to be printed
[in]paddingnumber of 0's to pad
[in]signif sign should be printed
Returns
number of characters printed

Definition at line 123 of file print.c.

◆ print_string()

static size_t print_string ( char **  str,
size_t *  size,
const char *  s 
)
static

print string

Parameters
[out]strstring to print string on (use NULL to print on user output)
[in,out]sizesize of string
[in]sstring to be printed
Returns
number of characters printed

Definition at line 78 of file print.c.

◆ print_unsigned()

static size_t print_unsigned ( char **  str,
size_t *  size,
uint64_t  u,
uint32_t  padding,
bool  sign 
)
static

print unsigned integer

Parameters
[out]strstring to print unsigned integer on (use NULL to print on user output)
[in,out]sizesize of string
[in]uunsigned integer to be printed
[in]paddingnumber of 0's to pad
[in]signif sign should be printed
Returns
number of characters printed

Definition at line 95 of file print.c.

◆ 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 448 of file print.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 458 of file print.c.

◆ vsnprintf()

static size_t vsnprintf ( char **  str,
size_t *  size,
const char *  format,
va_list  va 
)
static

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]vaarguments 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 316 of file print.c.