embedded-software
reusable software modules for embedded systems
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
printf Functionality for Buffer Module
Collaboration diagram for printf Functionality for Buffer Module:

Macros

#define Buffer_Hex(buf, x)   Buffer_HexN(buf, x, 4)
 

Functions

void Buffer_printf (buffer_t *buf, char *str,...)
 printf implementation to char buffer More...
 
void Buffer_vprintf (buffer_t *buf, char *str, va_list vars)
 vprintf implementation to char buffer More...
 
void Buffer_Binary16 (buffer_t *buf, uint16_t x)
 Push 16 bit binary number to char buffer. More...
 
void Buffer_uint16 (buffer_t *buf, uint16_t x)
 Push unsigned integer to char buffer. More...
 
void Buffer_int16 (buffer_t *buf, int16_t x)
 Push integer to char buffer. More...
 
void Buffer_uint32 (buffer_t *buf, uint32_t x)
 Push unsigned long integer to char buffer. More...
 
void Buffer_int32 (buffer_t *buf, int32_t x)
 Push long to char buffer. More...
 
void Buffer_Str (buffer_t *buf, char *str)
 Push char array (string) to char buffer. More...
 
void Buffer_HexN (buffer_t *buf, uint32_t x, uint8_t n)
 Push 32 bit value to char buffer in hex format. More...
 
void Buffer_Float (buffer_t *buf, float x)
 Cheap implementation of float to char buffer. More...
 

Detailed Description

buffer_printf.h

Created on: Mar 11, 2014 Author: Michael

Version
1.1 changed naming to match stdint and removed 2Buf from function names
1.2 added l for int32 and b for 16-bit binary

Macro Definition Documentation

#define Buffer_Hex (   buf,
 
)    Buffer_HexN(buf, x, 4)

Function Documentation

void Buffer_Binary16 ( buffer_t buf,
uint16_t  x 
)

Push 16 bit binary number to char buffer.

Parameters
[in]bufPointer to char buffer to print to
[in]xUnsigned 16-bit integer to convert to text in binary format

Here is the call graph for this function:

void Buffer_Float ( buffer_t buf,
float  x 
)

Cheap implementation of float to char buffer.

Current implementation will format float as 0.000 by first printing out the integer portion of the float then multiplying the float by 1000 and subtracting the integer portion x 1000 and printing that after the .

Parameters
[in]bufPointer to char buffer to print float to
[in]xFloat value to convert to text

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffer_HexN ( buffer_t buf,
uint32_t  x,
uint8_t  n 
)

Push 32 bit value to char buffer in hex format.

Will push four char's to the buffer, for example: A0F3

Parameters
[in]bufPointer to char buffer to print hex formatted int to
[in]xInteger to convert to hex
[in]nnumber of hex characters to print (1-8)

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffer_int16 ( buffer_t buf,
int16_t  x 
)

Push integer to char buffer.

Note this function is dependent on Push_uint16()

Parameters
[in]bufPointer to char buffer to print int to
[in]xInteger to convert to text

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffer_int32 ( buffer_t buf,
int32_t  x 
)

Push long to char buffer.

Note this function is dependent on Push_uint32()

Parameters
[in]bufPointer to char buffer to print int to
[in]xLong to convert to text

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffer_printf ( buffer_t buf,
char *  str,
  ... 
)

printf implementation to char buffer

Currently supports the following replacement flags:

  • c char, replaces flag with specified ASCII char
  • b binary, replaces flag with Binary representation See PushBinary16()
  • l long, replaces flag with Binary Representation See Push_int32()
  • d signed 16 bit integer, replaces flag with specified int. See Push_int16()
  • e f or g float, replaces flag with specified float See PushFloat()
  • s string, replaces flag with specified null terminated string See PushString()
  • u unsigned 16 bit integer, replaces flag with specified unsigned int See Push_uint16()
  • x 16 bit hex formated integer, replaces flag with 4 digit hex value. Can accept length format input: %0Lx where L is between 1 and 8. The printf functions expect a 32 bit value only when L is between 5 and 8. For example %08x can be used to print a 32-bit number in hex format. See PushHex()

Example:

...
int16_t x = -1;
char name[] = "Muhlbaier";
Push_printf(&tx, "x = %d, hex - 0x%x, unsigned %u, name = %s);

Would push to the buffer: "x = -1, hex - 0xFFFF, unsigned 65535, name = Muhlbaier"

Parameters
[in]bufPointer to char buffer to print formatted string to
[in]strPointer to null terminated string with replacement flags
[in]...Variable argument list corresponding with replacement flags

Here is the call graph for this function:

void Buffer_Str ( buffer_t buf,
char *  str 
)

Push char array (string) to char buffer.

Parameters
[in]bufPointer to char buffer to print string to
[in]strPointer to null terminated char array (e.g. string)

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffer_uint16 ( buffer_t buf,
uint16_t  x 
)

Push unsigned integer to char buffer.

Parameters
[in]bufPointer to char buffer to print unsigned int to
[in]xUnsigned integer to convert to text

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffer_uint32 ( buffer_t buf,
uint32_t  x 
)

Push unsigned long integer to char buffer.

Parameters
[in]bufPointer to char buffer to print unsigned long to
[in]xUnsigned integer to convert to text

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffer_vprintf ( buffer_t buf,
char *  str,
va_list  vars 
)

vprintf implementation to char buffer

Same as Push_printf() except with a va_list pointer instead of an actual variable argument list. This allows other functions similar to Push_printf to be implemented.

For example:

void LogStr(char * str, ...) {
va_list vars;
va_start(vars, str);
// use Push_vprintf to log to SUBSYS_UART
Push_vprintf(SUBSYS_UART, str, vars);
va_end(vars);
}

See Push_printf()

Parameters
[in]bufPointer to char buffer to print formatted string to
[in]strPointer to null terminated string with replacement flags
[in]varsVariable argument list corresponding with replacement flags

Here is the call graph for this function:

Here is the caller graph for this function: