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

SPI Programming Examples
SPI Programming Manual427506-006
E-56
Example E-12: A Simple SPI Server in C
void process_spi_buffer(void);
void process_requests(void);
short validate_tokens(void);
short verify_msg (short p_count);
#include "seccutlc"
#pragma PAGE "PROC build_hdr_response"
void build_hdr_response(void)
/*
*========================================================================
* Proc : build_hdr_response =
* Function : This procedure will build the header for responses. =
*========================================================================
*/
{
object_type = ZSPI_VAL_NULL_OBJECT_TYPE;
/* Initialize response buffer */
if (err = SSINIT (res_buffer, max_bufsize, (short *) &my_ssid,
ZSPI_VAL_CMDHDR, spi_command, object_type))
display_spi_error (err, ZSPI_VAL_SSINIT, 0L, true);
/* Put in server version token */
if (err = SSPUTTKN (req_buffer, ZSPI_TKN_SERVER_VERSION,
(char *) &my_version))
display_spi_error (err, ZSPI_VAL_SSPUTTKN,
ZSPI_TKN_SERVER_VERSION, true);
} /* End of build_hdr_response procedure */
#pragma PAGE "PROC error_response"
void error_response (short p_err_num)
/*
*========================================================================
* Proc : error_response =
* Function : This procedure will format responses for unsuccessful =
* processing of spi_command. =
*========================================================================
*/
/* max_resp token from SPI buffer must be previously set. */
/* tkn_code of the token which caused error must be previously set. */
{
zspi_ddl_error_def l_err_def;
build_hdr_response();
source_idx = 1;
dest_idx = 1;
tkn_count = 1;
}
Example E-12. C File: A Simple SPI Server (page 2 of 12)