void xmit_spi(BYTE dat)
{
char temp;
while(!(SPI0SR_SPTEF)); /* wait until write is permissible */
SPI0DRL = dat; /* output the byte to the SPI */
while(!(SPI0SR_SPIF)); /* wait until write operation is complete */
temp=SPI0SR;
temp=SPI0DRL; // clear the spif flag.
}
static
BYTE rcvr_spi(void)
{
unsigned char te;
while(!(SPI0SR_SPTEF)); /* wait until write is permissible */
SPI0DRL = 0xFF; /* trigger 8 SCK pulses to shift in data */
while(!(SPI0SR_SPIF)); /* wait until a byte has been shifted in */
te=SPI0SR;
te=SPI0DRL; // clear the spif flag.
return te; /* return the character */
}