aboutsummaryrefslogtreecommitdiffstats
path: root/testhal
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-05-26 07:57:56 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-05-26 07:57:56 +0000
commit249d014e0bc24c1341a09c9af4cf65b12161993e (patch)
tree745db1d8ad400beead9a684a8e6afa1a5abf96a2 /testhal
parent063a18e3442e32ca64f22c2a3b45a05251566654 (diff)
downloadChibiOS-249d014e0bc24c1341a09c9af4cf65b12161993e.tar.gz
ChibiOS-249d014e0bc24c1341a09c9af4cf65b12161993e.tar.bz2
ChibiOS-249d014e0bc24c1341a09c9af4cf65b12161993e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9523 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal')
-rw-r--r--testhal/STM32/STM32L4xx/QSPI-N25Q128/main.c27
1 files changed, 26 insertions, 1 deletions
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)