From e6864865cc672b314ee987f1bf4fd3e793ffd0f6 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Wed, 11 May 2016 11:29:20 +0000 Subject: Flash demo updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9465 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32/STM32F3xx/SPI-N25Q128/main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'testhal/STM32/STM32F3xx/SPI-N25Q128') diff --git a/testhal/STM32/STM32F3xx/SPI-N25Q128/main.c b/testhal/STM32/STM32F3xx/SPI-N25Q128/main.c index 021939419..ef9a06a41 100644 --- a/testhal/STM32/STM32F3xx/SPI-N25Q128/main.c +++ b/testhal/STM32/STM32F3xx/SPI-N25Q128/main.c @@ -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"); -- cgit v1.2.3