| Example |
/* SPI Device Driver Control Block */
SPI_DRV spi0_drv = {
Init,
UnInit,
Send,
SendBuf,
RecBuf,
BusSpeed,
SetSS,
CheckMedia
};
/* Initialize and enable the SSP Interface module. */
static BOOL Init (void) {
/* SSEL is GPIO, output set to high. */
IODIR0 |= 1<<20;
IOSET0 = 1<<20;
PINSEL1 = (PINSEL1 & ~0x000003FC) | 0x000000A8;
/* Enable SPI in Master Mode, CPOL=0, CPHA=0. */
SSPCR0 = 0x0007;
SSPCR1 = 0x0002;
SSPCPSR = 0xFE;
return (__TRUE);
}
|