Hi
SPI use on the SAM7 is quite straightforward. Below is a general configuration and then an example transmission and reception:
Code:
POWER_UP(SPI1 | PIOA); // enable clocks to SPI1 in PMC and Port A due to CS line
PIO_BSR_A = (SPI_MOSI_1B | SPI_MISO_1B | SPI_CLK_1B);
PIO_PDR_A = (SPI_MOSI_1B | SPI_MISO_1B | SPI_CLK_1B); // enable SPI pins
PIO_PER_A = (SPI_CS0_1B); // configure CS0 for SW control
PIO_SODR_A = (SPI_CS0_1B);
PIO_OER_A = (SPI_CS0_1B);
SPI_MR_1 = (SPI_MSTR | MODFDIS | SPI_CS_0); // set SPI mode
SPI_CSR0_1 = (SPI_CPOL | SPI_8_BITS | (((MASTER_CLOCK + 6000000/2)/6000000) << 8)); // set speed 6MHz
SPI_CR_1 = SPIEN; // enable
PIO_CODR_A = SPI_CS0_1B; // assert CS line
SPI_TDR_1 = ucCommand; // send a byte
while (!(SPI_SR_1 & SPI_RDRF)) {}; // wait until tx byte has been sent and rx byte has been completely received
ucRxData = SPI_RDR_1; // read the returned byte
PIO_SODR_A = SPI_CS0_1B; // negate CS line
This is from the uTasker project. This may help you to use the SPI and the chip generally. (SPI use in the project includes SD card, SPI FLASH devices and LCD - eg. Nokia LCD on the Olimex boards) Full support at
http://www.utasker.com/forum/index.phpRegards
Mark
www.uTasker.com