From 249d014e0bc24c1341a09c9af4cf65b12161993e Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 26 May 2016 07:57:56 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9523 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32/STM32L4xx/QSPI-N25Q128/main.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'testhal') diff --git a/testhal/STM32/STM32L4xx/QSPI-N25Q128/main.c b/testhal/STM32/STM32L4xx/QSPI-N25Q128/main.c index 2b4807139..2f85ec5d2 100644 --- a/testhal/STM32/STM32L4xx/QSPI-N25Q128/main.c +++ b/testhal/STM32/STM32L4xx/QSPI-N25Q128/main.c @@ -35,7 +35,21 @@ qspi_command_t cmd_read_id = { 0 }; -uint8_t buffer[512]; +/* + * Generic buffer. + */ +uint8_t buffer[2048]; + +const uint8_t pattern[128] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 +}; M25QDriver m25q; @@ -92,6 +106,17 @@ int main(void) { m25qObjectInit(&m25q); m25qStart(&m25q, &m25qcfg1); + /* Erasing the first sector and waiting for completion.*/ + (void) flashStartEraseSector(&m25q, 0); + err = flashWaitErase((BaseFlash *)&m25q); + if (err != FLASH_NO_ERROR) + chSysHalt("erase error"); + + /* Programming a pattern.*/ + err = flashProgram(&m25q, 0, pattern, 128); + if (err != FLASH_NO_ERROR) + chSysHalt("program error"); + /* Reading it back.*/ err = flashRead(&m25q, 0, buffer, 128); if (err != FLASH_NO_ERROR) -- cgit v1.2.3