From 6620e65927443454f881d706a69ea8c9af71e296 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 2 Nov 2018 21:14:35 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12403 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- .../devices/macronix_mx25/hal_flash_device.c | 22 +-- .../devices/macronix_mx25/hal_flash_device.h | 2 +- testhal/STM32/multi/WSPI-MFS/.cproject | 147 ++++++++++++++------- testhal/STM32/multi/WSPI-MFS/.project | 17 +-- testhal/STM32/multi/WSPI-MFS/Makefile | 10 +- .../WSPI-MFS/cfg/stm32l476_discovery/portab.c | 6 + .../WSPI-MFS/cfg/stm32l476_discovery/portab.h | 3 + .../WSPI-MFS/cfg/stm32l4r9_discovery/mcuconf.h | 2 +- .../WSPI-MFS/cfg/stm32l4r9_discovery/portab.c | 10 ++ .../WSPI-MFS/cfg/stm32l4r9_discovery/portab.h | 3 + ...MFS (Select ELF file)(OpenOCD, Just Run).launch | 104 +++++++-------- testhal/STM32/multi/WSPI-MFS/main.c | 21 +-- 12 files changed, 197 insertions(+), 150 deletions(-) diff --git a/os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.c b/os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.c index c775a57bc..7431ef69a 100644 --- a/os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.c +++ b/os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.c @@ -168,7 +168,8 @@ static flash_error_t n25q_poll_status(SNORDriver *devp) { #if MX25_BUS_MODE == MX25_BUS_MODE_SPI bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSR, 1, &sts); #else - bus_cmd_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSR, 1, &sts); + bus_cmd_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSR, + MX25_READ_DUMMY_CYCLES, 1U, &sts); #endif } while ((sts & 1U) != 0U); @@ -176,7 +177,8 @@ static flash_error_t n25q_poll_status(SNORDriver *devp) { #if MX25_BUS_MODE == MX25_BUS_MODE_SPI bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSCUR, 1, &sts); #else - bus_cmd_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSCUR, 1, &sts); + bus_cmd_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSCUR, + MX25_READ_DUMMY_CYCLES, 1U, &sts); #endif if ((sts & MX25_FLAGS_ALL_ERRORS) != 0U) { @@ -475,7 +477,7 @@ flash_error_t snor_device_program(SNORDriver *devp, flash_offset_t offset, bus_cmd(devp->config->busp, MX25_CMD_OPI_WREN); /* Page program command.*/ - bus_cmd_addr_send(devp->config->busp, MX25_CMD_OPI_PP4B, offset, + bus_cmd_addr_send(devp->config->busp, MX25_CMD_OPI_PP, offset, chunk, pp); #endif @@ -535,10 +537,10 @@ flash_error_t snor_device_start_erase_sector(SNORDriver *devp, #if MX25_USE_SUB_SECTORS == FALSE /* Block erase command.*/ - bus_cmd_addr(devp->config->busp, MX25_CMD_OPI_BE4B, offset); + bus_cmd_addr(devp->config->busp, MX25_CMD_OPI_BE, offset); #else /* Sector erase command.*/ - bus_cmd_addr(devp->config->busp, MX25_CMD_OPI_SE4B, offset); + bus_cmd_addr(devp->config->busp, MX25_CMD_OPI_SE, offset); #endif #endif @@ -599,16 +601,18 @@ flash_error_t snor_device_query_erase(SNORDriver *devp, uint32_t *msec) { /* Read status register.*/ #if MX25_BUS_MODE == MX25_BUS_MODE_SPI - bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSR, 1, &sts); + bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSR, 1U, &sts); #else - bus_cmd_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSR, 1, &sts); + bus_cmd_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSR, + MX25_READ_DUMMY_CYCLES, 1U, &sts); #endif /* Read security register.*/ #if MX25_BUS_MODE == MX25_BUS_MODE_SPI - bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSCUR, 1, &sec); + bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSCUR, 1U, &sec); #else - bus_cmd_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSCUR, 1, &sec); + bus_cmd_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSCUR, + MX25_READ_DUMMY_CYCLES, 1U, &sec); #endif /* If the WIP bit is one (busy) or the flash in a suspended state then diff --git a/os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.h b/os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.h index f4c8bece7..c86d5d304 100644 --- a/os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.h +++ b/os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.h @@ -195,7 +195,7 @@ * @note This option is only valid in WSPI bus mode. */ #if !defined(MX25_BUS_MODE) || defined(__DOXYGEN__) -#define MX25_BUS_MODE MX25_BUS_MODE_SPI +#define MX25_BUS_MODE MX25_BUS_MODE_OPI_STR #endif /** diff --git a/testhal/STM32/multi/WSPI-MFS/.cproject b/testhal/STM32/multi/WSPI-MFS/.cproject index 23334856f..ab58f5e52 100644 --- a/testhal/STM32/multi/WSPI-MFS/.cproject +++ b/testhal/STM32/multi/WSPI-MFS/.cproject @@ -1,8 +1,8 @@ - - + + @@ -14,20 +14,20 @@ - - - - - - - - + + + + + + + + - - + + - - + + @@ -35,8 +35,8 @@ - - + + @@ -48,20 +48,20 @@ - - - - - - - - + + + + + + + + - - + + - - + + @@ -69,8 +69,8 @@ - - + + @@ -82,20 +82,20 @@ - - - - - - - - + + + + + + + + - - + + - - + + @@ -105,24 +105,77 @@ - + - + + + + + + + + + + + + + + + + + + + + + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/testhal/STM32/multi/WSPI-MFS/.project b/testhal/STM32/multi/WSPI-MFS/.project index 9fe72fd37..332e10b0f 100644 --- a/testhal/STM32/multi/WSPI-MFS/.project +++ b/testhal/STM32/multi/WSPI-MFS/.project @@ -23,7 +23,7 @@ org.eclipse.cdt.make.core.buildArguments - -j1 + -j org.eclipse.cdt.make.core.buildCommand @@ -81,20 +81,5 @@ 2 CHIBIOS/os - - test - 2 - virtual:/virtual - - - test/lib - 2 - CHIBIOS/test/lib - - - test/mfs - 2 - CHIBIOS/test/mfs - diff --git a/testhal/STM32/multi/WSPI-MFS/Makefile b/testhal/STM32/multi/WSPI-MFS/Makefile index 0171204af..44b42fe0a 100644 --- a/testhal/STM32/multi/WSPI-MFS/Makefile +++ b/testhal/STM32/multi/WSPI-MFS/Makefile @@ -3,21 +3,21 @@ # all: - @echo - @echo === Building for STM32L476-Discovery =============================== - +@make --no-print-directory -f ./make/stm32l476_discovery.make all @echo @echo === Building for STM32L4R9-Discovery =============================== +@make --no-print-directory -f ./make/stm32l4r9_discovery.make all + @echo + @echo === Building for STM32L476-Discovery =============================== + +@make --no-print-directory -f ./make/stm32l476_discovery.make all @echo ==================================================================== @echo clean: - @echo - +@make --no-print-directory -f ./make/stm32l476_discovery.make clean @echo +@make --no-print-directory -f ./make/stm32l4r9_discovery.make clean @echo + +@make --no-print-directory -f ./make/stm32l476_discovery.make clean + @echo # ############################################################################## diff --git a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/portab.c b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/portab.c index 878e69c05..893711661 100644 --- a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/portab.c +++ b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/portab.c @@ -34,6 +34,12 @@ /* Module exported variables. */ /*===========================================================================*/ +const WSPIConfig WSPIcfg1 = { + .end_cb = NULL, + .dcr = STM32_DCR_FSIZE(24U) | /* 16MB device. */ + STM32_DCR_CSHT(1U) /* NCS 2 cycles delay. */ +}; + /*===========================================================================*/ /* Module local types. */ /*===========================================================================*/ diff --git a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/portab.h b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/portab.h index 25f3c4d4c..6985d659d 100644 --- a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/portab.h +++ b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/portab.h @@ -38,6 +38,7 @@ #define PORTAB_BUTTON_PRESSED PAL_HIGH #define PORTAB_SD1 SD2 +#define PORTAB_WSPI1 WSPID1 /*===========================================================================*/ /* Module pre-compile time settings. */ @@ -59,6 +60,8 @@ /* External declarations. */ /*===========================================================================*/ +extern const WSPIConfig WSPIcfg1; + #ifdef __cplusplus extern "C" { #endif diff --git a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/mcuconf.h b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/mcuconf.h index 99336e8ac..99136239d 100644 --- a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/mcuconf.h +++ b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/mcuconf.h @@ -323,7 +323,7 @@ /* * WSPI driver system settings. */ -#define STM32_WSPI_USE_OCTOSPI1 TRUE +#define STM32_WSPI_USE_OCTOSPI1 FALSE #define STM32_WSPI_USE_OCTOSPI2 TRUE #define STM32_WSPI_OCTOSPI1_PRESCALER_VALUE 1 #define STM32_WSPI_OCTOSPI2_PRESCALER_VALUE 1 diff --git a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/portab.c b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/portab.c index 652d32898..bf15f000d 100644 --- a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/portab.c +++ b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/portab.c @@ -34,6 +34,16 @@ /* Module exported variables. */ /*===========================================================================*/ +const WSPIConfig WSPIcfg1 = { + .end_cb = NULL, + .dcr1 = STM32_DCR1_MTYP(1U) | /* Macronix mode. */ + STM32_DCR1_DEVSIZE(26U) | /* 64MB device. */ + STM32_DCR1_CSHT(1U), /* NCS 2 cycles delay. */ + .dcr2 = STM32_DCR2_PRESCALER(1U), /* Clock is AHB / 2. */ + .dcr3 = 0U, + .dcr4 = 0U +}; + /*===========================================================================*/ /* Module local types. */ /*===========================================================================*/ diff --git a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/portab.h b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/portab.h index aed8b57b0..fc27619ce 100644 --- a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/portab.h +++ b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l4r9_discovery/portab.h @@ -38,6 +38,7 @@ #define PORTAB_BUTTON_PRESSED PAL_HIGH #define PORTAB_SD1 SD2 +#define PORTAB_WSPI1 WSPID2 /*===========================================================================*/ /* Module pre-compile time settings. */ @@ -59,6 +60,8 @@ /* External declarations. */ /*===========================================================================*/ +extern const WSPIConfig WSPIcfg1; + #ifdef __cplusplus extern "C" { #endif diff --git a/testhal/STM32/multi/WSPI-MFS/debug/STM32-WSPI-MFS (Select ELF file)(OpenOCD, Just Run).launch b/testhal/STM32/multi/WSPI-MFS/debug/STM32-WSPI-MFS (Select ELF file)(OpenOCD, Just Run).launch index 5085657ac..71447cb03 100644 --- a/testhal/STM32/multi/WSPI-MFS/debug/STM32-WSPI-MFS (Select ELF file)(OpenOCD, Just Run).launch +++ b/testhal/STM32/multi/WSPI-MFS/debug/STM32-WSPI-MFS (Select ELF file)(OpenOCD, Just Run).launch @@ -1,52 +1,52 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testhal/STM32/multi/WSPI-MFS/main.c b/testhal/STM32/multi/WSPI-MFS/main.c index 0bce0c7f3..18d4a22e2 100644 --- a/testhal/STM32/multi/WSPI-MFS/main.c +++ b/testhal/STM32/multi/WSPI-MFS/main.c @@ -26,25 +26,8 @@ #include "portab.h" -#if defined(STM32_WSPI_USE_OCTOSPI1) -/* 16MB device, 2 cycles delay after NCS.*/ -const WSPIConfig WSPIcfg1 = { - .end_cb = NULL, - .dcr1 = STM32_DCR1_DEVSIZE(24U) | STM32_DCR1_CSHT(1U), - .dcr2 = 0U, - .dcr3 = 0U, - .dcr4 = 0U -}; -#else /* It is a quad SPI.*/ -/* 16MB device, 2 cycles delay after NCS.*/ -const WSPIConfig WSPIcfg1 = { - .end_cb = NULL, - .dcr = STM32_DCR_FSIZE(24U) | STM32_DCR_CSHT(1U) -}; -#endif - const SNORConfig snorcfg1 = { - .busp = &WSPID1, + .busp = &PORTAB_WSPI1, .buscfg = &WSPIcfg1 }; @@ -107,7 +90,7 @@ int main(void) { /* Normal main() thread activity, in this demo it does nothing.*/ while (true) { if (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) { - test_execute((BaseSequentialStream *)&PORTAB_SD1, &mfs_test_suite); + test_execute((BaseSequentialStream *)&PORTAB_SD1, &mfs_test_suite); } chThdSleepMilliseconds(500); } -- cgit v1.2.3