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

SPI Programming Examples
SPI Programming Manual427506-006
E-78
Example E-16: Common Routines for C Examples
err = 0;
while (! l_done)
{
err = SPI_BUFFER_FORMATNEXT_ (l_format_id,
l_spi_buf,
(char *) &l_format_buf,
max_lines * max_line_len,
max_lines,
l_lengths,
&l_status1,
&l_status2);
if (err == 0
|| err == ZSPI_ERR_CONTINUE)
{
for (l_idx = 0; l_idx < max_lines; ++l_idx)
{
if (l_lengths [l_idx] > -1)
{
memcpy (&l_line, &l_format_buf [l_idx * max_line_len / 2],
l_lengths [l_idx]); /* Copy the output line */
l_line [l_lengths [l_idx]] = 0; /* terminate the string */
printf("%s\n", l_line);
} /* of if */
} /* of for */
} else /* if */
{
/* an error found, done printing */
l_done = true;
display_spi_error (err, ZSPI_VAL_BUFFER_FORMATNEXT, 0L, true);
} /* of if */
/* we are done printing if all found (err = 0) */
if (! err) l_done = true;
} /* of while */
/* release the format area */
SPI_BUFFER_FORMATFINISH_ (&l_format_id, &l_status1, &l_status2);
/* Write a blank line for output clarity */
printf(" \n");
} /* End of dump_buf */
#pragma PAGE "get_file_error"
/*
===========================================================================
== Proc : get_file_error =
== Function : This procedure will get the file error from the file =
== number that is passed and store it in "last_file_err". =
===========================================================================
*/
void get_file_error (short p_file_num)
{
FILEINFO (p_file_num, &last_file_err);
DEBUG ();
} /* of get_file_error */
Example E-16. C File: SECCUTLC Supporting Code (page 5 of 5)