SPI Programming Manual (G06.24+, H06.03+, J06.03+)

SPI Programming Examples
SPI Programming Manual427506-006
E-77
Example E-16: Common Routines for C Examples
#pragma PAGE "dump_buf"
void dump_buf (short* p_spi_buf)
/*
===========================================================================
== Proc : dump_buf =
== Function : This procedure will perform a labeled dump of the passed =
== SPI buffer and display it on the home term. =
===========================================================================
*/
{
#define numeric_format 10 /* Decimal */
#define string_format 0 /* Char codes 32 - 126 */
#define type_override 0 /* No TYPE overrides */
#define show_redef 0 /* Don’t show redefines */
#define show_hidden 1 /* Show hidden fields */
#define no_header 0 /* Show header and data fields */
#define name_or_label 1 /* Use DDL names */
#define ems_or_ss 1
#define tkn_label_len 30
#define field_label_len 0
#define max_lines 10
#define max_line_len 80
/*
** Note that the SPI_formatnext procedure can modify the spi buffer.
** Thus I will move it to l_spi_buf and display it from here.
*/
short l_spi_buf [max_bufsize]; /* buffer to display */
short l_format_buf [max_lines * max_line_len / 2];
char l_line [max_line_len + 1]; /* Add 1 for terminator */
short l_lengths [max_lines];
short l_idx,
l_done = 0,
l_format_id, /* used by formatting routines to keep track of
info.*/
l_status1,
l_status2;
memcpy (&l_spi_buf, p_spi_buf, (max_bufsize * 2)); /* Copy the buffer */
/* get a format area reserved */
err = SPI_BUFFER_FORMATSTART_ (&l_format_id,
numeric_format,
string_format,
type_override,
show_redef,
show_hidden,
no_header,
name_or_label,
ems_or_ss,
tkn_label_len,
field_label_len,
&l_status1,
&l_status2);
if (err)
display_spi_error (err, ZSPI_VAL_BUFFER_FORMATSTART, 0L, true);
Example E-16. C File: SECCUTLC Supporting Code (page 4 of 5)