diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-05-26 07:57:56 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-05-26 07:57:56 +0000 |
commit | 249d014e0bc24c1341a09c9af4cf65b12161993e (patch) | |
tree | 745db1d8ad400beead9a684a8e6afa1a5abf96a2 | |
parent | 063a18e3442e32ca64f22c2a3b45a05251566654 (diff) | |
download | ChibiOS-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
-rw-r--r-- | os/ex/Micron/m25q.c | 6 | ||||
-rw-r--r-- | testhal/STM32/STM32L4xx/QSPI-N25Q128/main.c | 27 |
2 files changed, 26 insertions, 7 deletions
diff --git a/os/ex/Micron/m25q.c b/os/ex/Micron/m25q.c index a94e1730b..9ae5958d8 100644 --- a/os/ex/Micron/m25q.c +++ b/os/ex/Micron/m25q.c @@ -660,9 +660,6 @@ static flash_error_t start_erase_all(void *instance) { /* Bulk erase command.*/ flash_cmd(devp, M25Q_CMD_BULK_ERASE); - /* Ready state again.*/ - devp->state = FLASH_READY; - /* Bus released.*/ flash_bus_release(devp); @@ -694,9 +691,6 @@ static flash_error_t start_erase_sector(void *instance, flash_sector_t sector) { /* Sector erase command.*/ flash_cmd_addr(devp, M25Q_CMD_SECTOR_ERASE, addr); - /* Ready state again.*/ - devp->state = FLASH_READY; - /* Bus released.*/ flash_bus_release(devp); 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)
|