
typedef unsigned char          BYTE;
typedef unsigned short         WORD;
typedef unsigned long          LONG;

typedef struct
{
    BYTE   ssel;                       // slave select port pin description:
                                       // ss[7:4] = port number (ie. 1 means P1)
                                       // ss[3:0] = pin number (ie. 5 means Px.5)
    BYTE   len;                        // lenght of message
    WORD   *rxbuf;                     // pointer to SPI rx message buffer
    WORD   *txbuf;                     // pointer to SPI tx message buffer
} SSP_MSG;

#define SSP_OK                 0       // transfer ended No Errors
#define SSP_BUSY               1       // transfer busy
#define SSP_ROVR               2       // err: receiver overrun
#define SSP_ERR                3       // err: general error
#define SSP_TIME_OUT           4       // err: time out
#define SSP_SSEL               5       // err: ssel port error

extern BYTE SSP0_Transfer(SSP_MSG *p);
extern void SSP0_Init(void);
