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:
parent
c3d1d75f50
commit
e6864865cc
|
@ -119,22 +119,28 @@ int main(void) {
|
||||||
*/
|
*/
|
||||||
n25q128ReadId(&flash, buffer, 17);
|
n25q128ReadId(&flash, buffer, 17);
|
||||||
|
|
||||||
/*
|
/* Programming a pattern.*/
|
||||||
* Writing then reading a pattern on a single page with final erase and
|
|
||||||
* verify.
|
|
||||||
*/
|
|
||||||
err = flashProgram(&flash, 0, pattern, 128);
|
err = flashProgram(&flash, 0, pattern, 128);
|
||||||
if (err != FLASH_NO_ERROR)
|
if (err != FLASH_NO_ERROR)
|
||||||
chSysHalt("program error");
|
chSysHalt("program error");
|
||||||
|
|
||||||
|
/* Reading it back.*/
|
||||||
err = flashRead(&flash, 0, buffer, 128);
|
err = flashRead(&flash, 0, buffer, 128);
|
||||||
if (err != FLASH_NO_ERROR)
|
if (err != FLASH_NO_ERROR)
|
||||||
chSysHalt("read 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)
|
if (err != FLASH_NO_ERROR)
|
||||||
chSysHalt("erase error");
|
chSysHalt("erase error");
|
||||||
|
|
||||||
|
/* Verifying the erase operation.*/
|
||||||
err = flashVerifyErase(&flash, 0);
|
err = flashVerifyErase(&flash, 0);
|
||||||
if (err != FLASH_NO_ERROR)
|
if (err != FLASH_NO_ERROR)
|
||||||
chSysHalt("verify erase error");
|
chSysHalt("verify erase error");
|
||||||
|
|
||||||
|
/* Reading back for confirmation.*/
|
||||||
err = flashRead(&flash, 0, buffer, 128);
|
err = flashRead(&flash, 0, buffer, 128);
|
||||||
if (err != FLASH_NO_ERROR)
|
if (err != FLASH_NO_ERROR)
|
||||||
chSysHalt("read error");
|
chSysHalt("read error");
|
||||||
|
|
Loading…
Reference in New Issue