sppInit()

PROTOTYPE

#include <spp.h>

int sppInit(void (*report)( ui32 event), void (*parse)(ui8 *data));

DESCRIPTION

sppInit() initializes TargetSPP. It must be called before other TargetSPP API routines are used. report points to an optional callback function. If report is not 0, report() is called to report events to upper layer software. The list of supported events is defined in “spp.h” and reproduced below:

/*
** Upper Layer Reports
*/
#define SPP_LINK_RESET      1   /* connect was reset */
#define SPP_CONNECT         2   /* SPP connect occurred */
#define SPP_ALL_ACKED       3   /* all I-frames have been acknowledged */
#define SPP_DATA_IND        4   /* I-frame data has been received */

parse points to a second optional callback function. If the SPP_DECODE configuration definition is TRUE, SppQuiet is FALSE, and parse is not 0, parse() is called during I-frame decoding with its parameter pointing to the first byte of user data. This allows TargetSPP protocol decoding to include user interpretations of the user data.

If successful, sppInit() returns 0. Otherwise, it sets errno and returns -1.

ERROR CODES

Other If unable to create the necessary semaphores, timer, or SPP daemon task, the relevant RTOS error code is returned.

EXAMPLE

  /*-------------------------------------------------------------------*/
  /* Initialize SPP protocol stack.                                    */
  /*-------------------------------------------------------------------*/
  rc = sppInit(report, NULL);
  if (rc) error("sppInit()", rc);
  printf("Serial Packet Protocol initialized...\n");