SPI Programming Manual (G06.24+, H06.03+, J06.03+)
SPI Programming Examples
SPI Programming Manual—427506-006
E-58
Example E-12: A Simple SPI Server in C
/*
*=======================================================================
* Proc : initialization =
* Function : This procedure will open $RECEIVE. It also sets the =
* server_banner. =
*=======================================================================
*/
void initialization(void)
{
char l_filename [24];
short l_err;
short l_status;
memset (&server_banner.u_z_c.z_b, ' ', sizeof (server_banner));
memcpy (server_banner.u_z_c.z_b, "C SERVER Version 1.01 (27MAR95)", 31);
/* Assign values to ssid definitions */
memcpy (l_filename, "$RECEIVE ", 24);
bufsize = max_bufsize;
rcv_file_num = -1;
/* open $RECEIVE */
do /* retry opening $RECEIVE until ok */
{
l_status = OPEN ((short *) &l_filename[0], &rcv_file_num,
040000, 5); /* Recv depth = 5 */
}
while (rcv_file_num == -1);
if (l_status != CCE) /* error handling */
{
if (l_status == CCG)
{
FILEINFO (rcv_file_num, &l_err);
if (l_err > 0)
{
DEBUG();
continue_flag = false;
}
} else
{
DEBUG();
continue_flag = false;
}
}
} /* initialization */
#pragma PAGE "PROC process_spi_buffer"
void process_spi_buffer(void)
/*
*=======================================================================
* Proc : process_spi_buffer =
* Function : This procedure will format responses for successful =
* processing of spi_command. =
*=======================================================================
*/
{
short
l_err,
l_idx,
l_len,
l_start_idx;
Example E-12. C File: A Simple SPI Server (page 4 of 12)