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

SPI Programming Examples
SPI Programming Manual427506-006
E-44
Example E-11: A Simple SPI Server in TAL
Example E-11: A Simple SPI Server in TAL
Example E-11 on page E-45 is a simple SPI server that performs simple string
manipulations on strings provided by the requester shown in Example E-9
on
page E-28. The server is started automatically when you run the requester,
SETREQRO.
Source File
SETSERV
Object File
SETSERVO
memcpy (req_buffer, sav_buffer, max_bufsize);
/* Now delete the context token from the saved buffer. */
tkn_code = ZSPI_TKN_CONTEXT;
if (err = SSPUTTKN (sav_buffer, ZSPI_TKN_DELETE,
(char *) &tkn_code))
display_spi_error (err, ZSPI_VAL_SSPUTTKN,
tkn_code, true);
goto SEND_IT;
}
/* No context. Get the string from the COMMENT token */
if (err = SSGETTKN (req_buffer, ZSPI_TKN_COMMENT,
(char *) &in_string, 1))
{
display_spi_error (err, ZSPI_VAL_SSGETTKN,
ZSPI_TKN_COMMENT, false);
printf ("Bad SPI buffer returned! Missing TKN_COMMENT.\n");
} else
{
in_string.data [in_string.len] = 0; /* terminate the string */
printf ("%s", in_string.data);
}
} /* of if (! err) */
}
while (true);
} /* OF PROC requester */
Example E-10. C File: A Simple SPI Requester (page 8 of 8)