Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

adds/app/flash

Explain how to use flash driver.

 #include <dev/spi.h>
 #incluse <dev/flash.h>
 
 //init SPI driver requried for FLASH
 //register driver in system
 if (NutRegisterDevice(&devSpi0, 0, 0)) {
 NutPrintFormat(0, "Registering spi device failed\r\n");
 } else {
 NutPrintFormat(0, "Registering spi device sucess.\r\n");
 }
 //open SPI
 devSpi = NutDeviceOpen("spi0");
 //init SPI
 (*devSpi->dev_init)(devSpi);

 //register FLASH driver
 if (NutRegisterDevice(&devFlashSpi, 0, 0)) {
 NutPrintFormat(0, "Registering flash device failed\r\n");
 } else {
 NutPrintFormat(0, "Registering flash device sucess.\r\n");
 }

 //open FLASH
 devFlash = NutDeviceOpen("flashSpi");
 //init FLASH
 (*devFlash->dev_init)(devFlash);

 char* tmp0 = NutHeapAlloc(PAGE_SIZE); 
 char* buff0 = NutHeapAlloc(PAGE_SIZE); 
 
 //prepare buffor
 for (k=0 ; k<30 ;k++) {
 buff0[k]=k;
 }

 //write page to FLASH
 flashWritePage(devFlash, id, buff0);

 //read page from FLASH
 flashReadPage(devFlash, id, tmp0);


Generated on Thu Jan 30 22:30:43 2003 for EduNet by doxygen1.2.18