English
Language : 

AT91RM9200_06 Datasheet, PDF (112/689 Pages) ATMEL Corporation – ARM920T-based Microcontroller
14.3.5.3
Using the Service
The first step is to find the address of the open service method AT91F_OpenSvcDataFlash using
the ROM Entry Service.
1. Allocate one instance of AT91S_SvcDataFlash and AT91S_Dataflash in the application
memory space:
// Allocate the service and a device structure.
AT91S_SvcDataFlash svcDataFlash;
AT91S_Dataflash Device; // member of AT91S_SvcDataFlash service
Then initialize the AT91S_SvcDataFlash instance by calling the AT91F_OpenSvcDataFlash
function:
// Initialize service
pAT91->OpenSvcDataFlash (AT91C_BASE_PMC, &svcDataFlash);
2. Initialize the SPI Interrupt:
// Initialize the SPI Interrupt
at91_irq_open ( AT91C_BASE_AIC,AT91C_ID_SPI,3,
AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE
,AT91F_spi_asm_handler);
3. Configure the DataFlash structure with its correct features and link it to the device
structure in the AT91S_SvcDataFlash service structure:
// Example with an ATMEL AT45DB321B DataFlash
Device.pages_number = 8192;
Device.pages_size = 528;
Device.page_offset = 10;
Device.byte_mask = 0x300;
// Link to the service structure
svcDataFlash.pDevice = &Device;
4. Now the different methods can be used. Following is an example of a Page Read of 528
bytes on page 50:
// Result of the read operation in RxBufferDataFlash
unsigned char RxBufferDataFlash[528];
svcDataFlash.PageRead(&svcDataFlash,
(50*528),RxBufferDataFlash,528);
112 AT91RM9200
1768G–ATARM–29-Sep-06