spinnaker_tools 3.4.0
SpiNNaker API, sark, sc&mp, bmp firmware and build tools
|
Simple character I/O library for Spinnaker. More...
Data Structures | |
struct | iobuf_t |
Functions | |
static sdp_msg_t * | io_std_init (void) |
Initialises the IO_STD implementation. | |
static iobuf_t * | io_buf_init (void) |
Initialises a memory chunk for the IO_BUF implementation. | |
void | sark_io_buf_reset (void) |
Routine to reset the IOBUF for the core. | |
void | io_put_char (char *stream, uint c) |
Routine to put a character to an output stream. | |
void | io_printf (char *stream, char *f,...) |
A simple "printf" routine. | |
Format implementations | |
Routines to deal with the various printf formats. All end up calling io_put_char() to do the write of individual characters. | |
static void | io_put_str (char *stream, char *s, int d) |
Put a string possibly left-padding with spaces. | |
static void | io_put_int (char *stream, int n, uint d, uint pad) |
Put an integer (signed) in given field width, left-padding with spaces. Entire field is assumed to fit in 16 chars!. | |
static void | io_put_uint (char *stream, uint n, uint d, uint pad) |
Put an integer (unsigned) in given field width, left-padding with spaces. Entire field is assumed to fit in 16 chars!. | |
static void | io_put_zhex (char *stream, uint n, uint d) |
Put a hex number in exactly the number of characters specified. Truncates high digits if need be. | |
static void | io_put_hex (char *stream, uint n, uint d, uint pad) |
Put an integer in hex in given field width, left-padding with spaces. Entire field is assumed to fit in 16 chars! | |
static void | io_put_fixed (char *stream, uint n, uint d, uint a, uint pad, int neg) |
Format for 16.16 fixed point. | |
static void | io_put_sfixed (char *stream, int n, uint d, uint a, uint pad) |
Format for s16.15 fixed point. | |
static void | io_put_ufixed (char *stream, uint n, uint d, uint a, uint pad) |
Format for u16.16 fixed point. | |
Variables | |
static uint | sp_ptr |
Buffer pointer for 'sprintf'. | |
static uint | buf_ptr |
Buffer pointer for IO_BUF. | |
static sdp_msg_t * | io_msg |
Points to SDP buffer. | |
static iobuf_t * | io_buf |
Points to SDRAM buffer. | |
static const char | hex [] = "0123456789abcdef" |
Hexadecimal characters. | |
Simple character I/O library for Spinnaker.
struct iobuf_t |
|
static |
Initialises the IO_STD implementation.
|
static |
Initialises a memory chunk for the IO_BUF implementation.
void sark_io_buf_reset | ( | void | ) |
Routine to reset the IOBUF for the core.
Frees additional allocated IOBUF blocks in the system heap.
void io_put_char | ( | char * | stream, |
uint | c | ||
) |
Routine to put a character to an output stream.
Has different behaviour for four possible streams:
tubotron
instance via SDP.For IO_STD and IO_BUF the character is placed in a holding buffer which is flushed on buffer-full or newline or NULL.
stream | constant (IO_BUF, IO_STD, IO_NULL) or pointer to char array |
c | a character |
|
static |
Put a string possibly left-padding with spaces.
[in] | stream | Where to write to |
[in] | s | The string to write |
[in] | d | The number of characters to write |
Put an integer (signed) in given field width, left-padding with spaces. Entire field is assumed to fit in 16 chars!.
[in] | stream | Where to write to |
[in] | n | The word to write |
[in] | d | The number of digits to write |
[in] | pad | The padding character to use |
Put an integer (unsigned) in given field width, left-padding with spaces. Entire field is assumed to fit in 16 chars!.
[in] | stream | Where to write to |
[in] | n | The word to write |
[in] | d | The number of digits to write |
[in] | pad | The padding character to use |
Put a hex number in exactly the number of characters specified. Truncates high digits if need be.
[in] | stream | Where to write to |
[in] | n | The word to write |
[in] | d | The number of digits to write |
Put an integer in hex in given field width, left-padding with spaces. Entire field is assumed to fit in 16 chars!
[in] | stream | Where to write to |
[in] | n | The word to write |
[in] | d | The number of digits to write |
[in] | pad | The padding character to use |
Format for 16.16 fixed point.
[in] | stream | Where to write to |
[in] | n | unsigned accum, as unsigned integer |
[in] | d | Field width |
[in] | a | Precision |
[in] | pad | Padding character |
[in] | neg | True if a minus sign needs to be written |
Format for s16.15 fixed point.
Delegates to io_put_fixed()
[in] | stream | Where to write to |
[in] | n | signed accum, as signed integer |
[in] | d | Field width |
[in] | a | Precision |
[in] | pad | Padding character |
Format for u16.16 fixed point.
Delegates to io_put_fixed()
[in] | stream | Where to write to |
[in] | n | unsigned accum, as unsigned integer |
[in] | d | Field width |
[in] | a | Precision |
[in] | pad | Padding character |
void io_printf | ( | char * | stream, |
char * | format, | ||
... | |||
) |
A simple "printf" routine.
The first argument is a 'stream' which is either a constant (IO_BUF, IO_STD, IO_DBG, IO_NULL) or a pointer to a character array which will be filled in as in "sprintf". No checks for buffer overflow are made for this latter case! The range of formats is very limited to minimise code size. The maximum width for integer fields is 16.The maximum width for the 16.16 fixed point format is 25. Don't exceed these maxima!
The four constants provide 4 possible output streams for the output string. IO_STD will send the string as an SDP packet back to the host. IO_BUF will place the string in a buffer in SDRAM while IO_NULL will ignore the string. IO_DBG is not currently implemented.
Formats are:
%c
- character%s
- string - can be eg %8s
for right justification%d
- signed integer (also %8d
, %06d
, etc)%u
- signed integer (also %4u
, %06u
, etc)%x
- integer in hex (also %4x
, %08x
, etc)%z
- integer in hex, exactly N digits%n.mf
- 16.16 fixed point with width n, precision m