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

SPI Programming Examples
SPI Programming Manual427506-006
E-74
Example E-16: Common Routines for C Examples
Example E-16. C File: SECCUTLC Supporting Code (page 1 of 5)
/* File name: seccutlc
** SPI EXAMPLE C Common Utility procedures.
*/
#pragma PAGE "FORWARD declarations"
void display_spi_error (short p_spi_err,
short p_spi_proc,
long p_tkn_code,
short p__debug);
void display_token (long p_tkn_code);
void dump_buf (short* p_spi_buf);
void get_file_error (short p_file_num);
/*=======================================================================*
#pragma PAGE "display_spi_error"
/*
==========================================================================
== Proc : display_spi_error =
== Function : This procedure will format the SPI error that is passed =
== into a text message and display it on the home term. It =
== will call DEBUG if the "p__debug" parameter is true. =
==========================================================================
*/
void display_spi_error (short p_spi_err,
short p_spi_proc,
long p_tkn_code,
short p__debug)
{
printf ("Error from ");
switch (p_spi_proc)
{
case ZSPI_VAL_SSINIT : printf("SSINIT"); break;
case ZSPI_VAL_SSGET : printf("SSGET"); break;
case ZSPI_VAL_SSGETTKN : printf("SSGETTKN"); break;
case ZSPI_VAL_SSMOVE : printf("SSMOVE"); break;
case ZSPI_VAL_SSMOVETKN : printf("SSMOVETKN"); break;
case ZSPI_VAL_SSNULL : printf("SSNULL"); break;
case ZSPI_VAL_SSPUT : printf("SSPUT"); break;
case ZSPI_VAL_SSPUTTKN : printf("SSPUTTKN"); break;
case ZSPI_VAL_BUFFER_FORMATSTART : printf("FORMATSTART"); break;
case ZSPI_VAL_BUFFER_FORMATNEXT : printf("FORMATNEXT"); break;
case ZSPI_VAL_BUFFER_FORMATFINISH : printf("FORMATFINISH"); break;
case ZSPI_VAL_FORMAT_CLOSE : printf("FORMATCLOSE"); break;
default : printf("???Unknown???"); break;
} /* of switch (p_spi_proc) */
if (p_tkn_code != 0L)
display_token (p_tkn_code);
printf(" (%d, ", p_spi_err);
switch (p_spi_err)
{
case ZSPI_ERR_INVBUF : printf("Invalid Buffer"); break;
case ZSPI_ERR_ILLPARM : printf("Illegal Param"); break;
case ZSPI_ERR_MISPARM : printf("Missing Param"); break;
case ZSPI_ERR_BADADDR : printf("Illegal Address"); break;
case ZSPI_ERR_NOSPACE : printf("Buffer full"); break;