Flash demo updated.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9465 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2016-05-11 11:29:20 +00:00
parent c3d1d75f50
commit e6864865cc
1 changed files with 11 additions and 5 deletions

View File

@ -119,22 +119,28 @@ int main(void) {
*/
n25q128ReadId(&flash, buffer, 17);
/*
* Writing then reading a pattern on a single page with final erase and
* verify.
*/
/* Programming a pattern.*/
err = flashProgram(&flash, 0, pattern, 128);
if (err != FLASH_NO_ERROR)
chSysHalt("program error");
/* Reading it back.*/
err = flashRead(&flash, 0, buffer, 128);
if (err != FLASH_NO_ERROR)
chSysHalt("read error");
err = flashStartEraseSector(&flash, 0);
/* Erasing the containing sector and waiting for completion.*/
(void) flashStartEraseSector(&flash, 0);
err = flashWaitErase((BaseFlash *)&flash);
if (err != FLASH_NO_ERROR)
chSysHalt("erase error");
/* Verifying the erase operation.*/
err = flashVerifyErase(&flash, 0);
if (err != FLASH_NO_ERROR)
chSysHalt("verify erase error");
/* Reading back for confirmation.*/
err = flashRead(&flash, 0, buffer, 128);
if (err != FLASH_NO_ERROR)
chSysHalt("read error");