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

SPI Programming Examples
SPI Programming Manual427506-006
E-40
Example E-10: A Simple SPI Requester in C
#pragma PAGE "open_server"
/*
*===================================================================
* Proc : open_server =
* Function : This procedure will open the server. =
*===================================================================
*/
void open_server(void)
{
short l_status;
char l_process_id_zspi [24];
open_flags = 0;
/* Open the server to send the STARTUP msg */
memset (l_process_id_zspi, ' ', 24);
memcpy (l_process_id_zspi, (char *) &process_id[0], 6);
/* Open the server */
l_status = OPEN ((short *) &l_process_id_zspi[0],
&srvr_file_num, open_flags);
if (l_status != CCE)
{
FILEINFO (-1, &file_error);
printf ("File system error (%d) on OPEN of the SERVER\n", file_error);
return;
}
/* Now write the STARTUP msg to the server */
/* **********************************************************/
/* But first, I will blank out the INFILE and OUTFILE so a */
/* server written in C (which uses the CRE) will not use */
/* the standard files, but accept open requests. */
/* **********************************************************/
memset(&startup_msg.infile, ' ', sizeof(startup_msg.infile));
memset(&startup_msg.outfile, ' ', sizeof(startup_msg.outfile));
l_status = WRITEX (srvr_file_num, (char *) &startup_msg,
sizeof(startup_msg));
if (l_status != CCE)
{
FILEINFO (srvr_file_num, &file_error);
/* Ignore error 70 (continue operation) */
if (file_error != 70)
{
printf ("File system error (%d) on WRITE to the SERVER\n", file_error);
return;
}
}
Example E-10. C File: A Simple SPI Requester (page 4 of 8)