| Example |
/* SPI Device Driver Control Block */
SPI_DRV spi0_drv = {
Init,
UnInit,
Send,
SendBuf,
RecBuf,
BusSpeed,
SetSS,
CheckMedia
};
/* Set an SPI clock to required baud rate. */
static BOOL BusSpeed (U32 kbaud) {
U32 div;
div = (__PCLK/1000 + kbaud - 1) / kbaud;
if (div == 0) {
div = 0x02;
}
if (div & 1) {
div++;
}
if (div > 0xFE) {
div = 0xFE;
}
SSPCPSR = div;
return (__TRUE);
}
|