diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-11-04 16:54:51 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-11-04 16:54:51 +0000 |
commit | bb4728465f4545f755974f31b4d39023447d2e3f (patch) | |
tree | 968d509ea43606c109191e204282f6d65e205f42 /os/hal/lib | |
parent | a250f19c64ecddb2e2dce096436d4e2f7eefe28a (diff) | |
download | ChibiOS-bb4728465f4545f755974f31b4d39023447d2e3f.tar.gz ChibiOS-bb4728465f4545f755974f31b4d39023447d2e3f.tar.bz2 ChibiOS-bb4728465f4545f755974f31b4d39023447d2e3f.zip |
Fixed a race condition.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12408 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/hal/lib')
-rw-r--r-- | os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.c | 14 | ||||
-rw-r--r-- | os/hal/lib/complex/serial_nor/devices/macronix_mx25/hal_flash_device.h | 11 |
2 files changed, 22 insertions, 3 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 c587712c4..44b1018cb 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 @@ -381,9 +381,17 @@ void snor_device_init(SNORDriver *devp) { #else /* SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_WSPI */
- /* Attempting a reset of the device, it could be in an unexpected state
- because a CPU reset does not reset the memory too.*/
- mx25_reset(devp);
+#if MX25_RESET_ON_INIT == TRUE
+ {
+ /* Attempting a reset of the device, it could be in an unexpected state
+ because a CPU reset does not reset the memory too.*/
+ mx25_reset(devp);
+
+ /* The device requires at least 10uS to recover after a reset, it could
+ need up to 100mS in cause a reset occurred during a chip erase.*/
+ osalThreadSleepMicroseconds(40);
+ }
+#endif
/* Reading device ID and unique ID.*/
wspiReceive(devp->config->busp, &mx25_cmd_read_id, 3U, devp->device_id);
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 f70f73985..f2a7ceb06 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 @@ -175,6 +175,17 @@ /*===========================================================================*/
/**
+ * @brief SW reset on initialization.
+ * @details Enforces a reset on initialization, this could be required if
+ * the device is not reset in HW or during debugging.
+ * @note It is only effective if the WSPI driver is in use, it does
+ * nothing when SPI driver is used.
+ */
+#if !defined(MX25_RESET_ON_INIT) || defined(__DOXYGEN__)
+#define MX25_RESET_ON_INIT TRUE
+#endif
+
+/**
* @brief Switch WSPI bus width on initialization.
* @details A bus width initialization is performed by writing the
* Enhanced Volatile Configuration Register. If the flash
|