| Example |
/* SPI Device Driver Control Block */
SPI_DRV spi0_drv = {
Init,
UnInit,
Send,
SendBuf,
RecBuf,
BusSpeed,
SetSS,
CheckMedia
};
/* Receive SPI data to buffer. */
static BOOL RecBuf (U8 *buf, U32 sz) {
U32 i;
for (i = 0; i < sz; i++) {
SSPDR = 0xFF;
while (!(SSPSR & RNE)); /* Wait while Rx FIFO is empty. */
buf[i] = SSPDR;
}
return (__TRUE);
}
|