27 Sizeof_unsigned_int_not_supported_for_printf);
74 const uint8_t numberOfNibbles =
sizeof(value) * 2;
77 for (i = 0; i < numberOfNibbles; ++i) {
105 const uint8_t numberOfGroups = 6;
108 for (i = 0; i < numberOfGroups; ++i) {
109 buffer[i] = (char)((value & 07U) +
'0');
135 const bool isNegative)
139 if (padLength > size) {
142 if (isNegative && padLength > 0) {
148 while (padLength-- > 0) {
167 for (i = 0; i < size; ++i) {
195 const char *c = format;
197 if (
NULL == format) {
201 va_start(args, format);
203 for (;
'\0' != *c; ++c) {
206 bool firstDigitPassed =
false;
207 bool isNegative =
false;
208 bool rightPadded =
false;
212 const char * s = buffer;
214 for (++c;
'\0' != *c; ++c) {
222 if (
'0' == *c && !firstDigitPassed) {
224 firstDigitPassed =
true;
227 }
else if (*c >=
'0' && *c <=
'9') {
228 padLength = padLength * 10 + *c -
'0';
229 firstDigitPassed =
true;
232 }
else if (
'-' == *c) {
236 }
else if (
'%' == *c) {
246 }
else if (
'd' == *c ||
'i' == *c ||
'u' == *c) {
247 unsigned int absolute;
250 absolute = va_arg(args,
unsigned int);
252 const int value = va_arg(args,
int);
253 isNegative = value < 0;
254 absolute =
ABS(value);
257 if (2 ==
sizeof(
unsigned int)) {
267 }
else if (
'x' == *c ||
'X' == *c) {
271 }
else if (
'o' == *c) {
273 }
else if (
'c' == *c) {
274 buffer[0] = (char)va_arg(args,
int);
276 }
else if (
's' == *c) {
278 s = va_arg(args,
char*);
326 if (isNegative &&
'0' == padChar) {
331 total +=
OutputPadding(padLength, size, padChar, isNegative);
333 if (isNegative &&
' ' == padChar) {
#define STATIC_ASSERT(C, M)
Perform an assertion at compile time.
Internal functions needed for printf().
int putchar(int c)
Transmit a single character on the serial line.
#define ABS(A)
Obtain the absolute value of an integer.
static char GetHexDigit(const uint8_t i, const bool isUpper)
Convert a base 16 unit value to its hexadecimal digit representation.
Include appropriate config file.
static void OutputReverseBuffer(const char *const buffer, uint8_t size)
Output the content of the buffer in reverse order.
size_t strlen(const char *s)
Get the length of the string pointed by s.
unsigned int uint16_t
Represents a unsigned integer type with width of exactly 16 bits.
unsigned char uint8_t
Represents a unsigned integer type with width of exactly 8 bits.
static uint8_t ConvertU16ToHexadecimal(uint16_t value, char *const buffer, const bool isUpper)
Convert an unsigned 16-bit integer to its ASCII hexadecimal representation.
#define NULL
NULL pointer.
AVR type and macros definitions for variadic functions.
int printf(const char *format,...)
Produce unbuffered formatted output to the serial line.
uint8_t Printf_ConvertU16ToDecimal(uint16_t i, char buffer[])
Convert an unsigned 16-bit integer to its ASCII decimal representation.
stdio standard header file.
static void OutputBuffer(const char *const buffer, const uint8_t size)
Output the content of the buffer.
Basic type definitions and useful macros.
static uint8_t ConvertU16ToOctal(uint16_t value, char *const buffer)
Convert an unsigned 16-bit integer to its ASCII octal representation.
static int OutputPadding(uint8_t padLength, const uint8_t size, const char padChar, const bool isNegative)
Output the padding, according to the selected options.