Pond Electronics - Home of the µFlash876 & µFlash876B embedded controllers, µStack & µConnect Bus.

xprintf Module

Provide a common base for the printf style functions implemented on the uCore.(see sprintf, c_printf & ut_printf). xprintf implements a subset of the standard C printf functions. Note that unlike the C standard printf, xprintf is not buffered internally, ie each character is sent as it is encountered, \n is not required to flush the buffer.

xprintf

void xprintf(void (*xpc)(BYTE x),char *s,...);

Formatted string output to character output function. xpc is a pointer to a function which takes as a parameter a single character to send to the target. The format of the string is specified by s, this can be followed by an optional list of further parameters as identified in the format string.

xprintf accepts the following format specifiers as part of the format string:

%c character
%s string
%d signed decimal
%u unsigned decimal
%x unsigned hex
%f float/double
%ld long signed decimal
%lu long unsigned decimal
%lx long unsigned hex
%nc char padded with spaces to n characters
%ns string padded with spaces to n characters
%nd signed decimal padded with spaces to n characters
%nu unsigned decimal padded with spaces to n characters
%nx unsigned hex padded with spaces to n characters
%nf float/double padded with spaces to n characters
%nld long signed decimal padded with spaces to n characters
%nlu long unsigned decimal padded with spaces to n characters
%nlx long unsigned hex padded with spaces to n characters
%0nd signed decimal padded with zeros to n characters
%0nu unsigned decimal padded with zeros to n characters
%0nx unsigned hex padded with zeros to n characters
%0nf float/double padded with zeros to n characters
%0nld long signed decimal padded with zeros to n characters
%0nlu long unsigned decimal padded with zeros to n characters
%0nlx long unsigned hex padded with zeros to n characters
%n.ps string, precision p, padded with spaces to n
%n.pf float/double, precision p, padded with spaces to n
%0n.pf float/double, precision p, padded with zeros to n
%% the % char

The default precision for float/double is 2.
The maximum precision for float/double is 6.
The maximum specified precision for strings is 255.
The maximum specified field width (n) is 255.
All other character sequences sent directly to the output.

Example, formatted output over the uConnect bus:

uc_wstart(0x04);	// start I2C output to a uTerm @ 0x04   
xprintf(uc_write,"ADC[0] =%d\n",adc(0));
uc_stop();


Home | Products | Technical Info | How to Order | Contact Us | Links