aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2019-07-03 01:00:40 +1000
committerDamien George2019-07-03 01:27:33 +1000
commitcaabdd99c0f8402f5a141123f02cdf4be0a10ecf (patch)
tree5f9576c653c805e13564db31e8243a4d959c0e89
parent2034c0a2e364404216c8cadeb661fbc72647d16a (diff)
stm32/qspi: Handle bus acquisition.
When going out of memory-mapped mode to do a control transfer to the QSPI flash, the MPU settings must be changed to forbid access to the memory mapped region. And any ongoing transfer (eg memory mapped continuous read) must be aborted.
-rw-r--r--ports/stm32/qspi.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ports/stm32/qspi.c b/ports/stm32/qspi.c
index 282759967..ec744bfb2 100644
--- a/ports/stm32/qspi.c
+++ b/ports/stm32/qspi.c
@@ -139,6 +139,16 @@ STATIC int qspi_ioctl(void *self_in, uint32_t cmd) {
case MP_QSPI_IOCTL_INIT:
qspi_init();
break;
+ case MP_QSPI_IOCTL_BUS_ACQUIRE:
+ // Disable memory-mapped region during bus access
+ qspi_mpu_disable_all();
+ // Abort any ongoing transfer if peripheral is busy
+ if (QUADSPI->SR & QUADSPI_SR_BUSY) {
+ QUADSPI->CR |= QUADSPI_CR_ABORT;
+ while (QUADSPI->CR & QUADSPI_CR_ABORT) {
+ }
+ }
+ break;
case MP_QSPI_IOCTL_BUS_RELEASE:
// Switch to memory-map mode when bus is idle
qspi_memory_map();