|
Hi,
I'm using a AT91SAM7S256's usart in order to program a communication via LIN bus, but here it's not my problem. I need to store those data which come from the LIN transceiver into an external flash memory (AT25FS010N).
I think doing this with the SPI, but i wish i have advice. My hardware configuration are : PA12 -> SO PA13 -> SI PA14 -> SCK PA29 -> CS
I'm new in AT91SAM7 world so forgive me if i do huge mistake :)
Here is my spi initialisation function:
static void spi_initialiser(){ pPMC->PMC_PCER=(1<<AT91C_ID_SPI); *AT91C_PIOA_ASR=AT91C_PA12_MISO|AT91C_PA13_MOSI|AT91C_PA14_SPCK; // assign pins to SPI interface *AT91C_PIOA_PDR=AT91C_PA12_MISO|AT91C_PA13_MOSI|AT91C_PA14_SPCK; *AT91C_PIOA_PPUER=AT91C_PA12_MISO|AT91C_PA13_MOSI|AT91C_PA14_SPCK; // set pullups
//CHIP SELECT SETTINGS pPIO->PIO_ASR=AT91C_PA29_NPCS0; pPIO->PIO_PDR=AT91C_PA29_NPCS0; pPIO->PIO_OER=AT91C_PA29_NPCS0;
pSPI->SPI_CR = (AT91C_SPI_SPIEN | AT91C_SPI_SWRST); pSPI->SPI_CR = AT91C_SPI_SPIEN; pSPI->SPI_MR = (AT91C_SPI_MSTR | AT91C_SPI_MODFDIS | AT91C_SPI_PS_FIXED | ((0x0)<<16)); pSPI->SPI_CSR[0] = (AT91C_SPI_CPOL | AT91C_SPI_NCPHA | AT91C_SPI_CSAAT | AT91C_SPI_BITS_8 | AT91C_SPI_SCBR | AT91C_SPI_SCBR | AT91C_SPI_DLYBCT); }
So my question is, how can i do to write and read data into my external flash memory? There is lot of things i don"t understand like the differnt block, pages ... I see that i souhld write a spi_write function and certainly a spi_read function but how i do it ?
Thanks in advance, and sorry for my English :p Regards,
|