8000 stm32/qspi: Handle bus acquisition. · micropython/micropython@caabdd9 · GitHub
[go: up one dir, main page]

Skip to content

Commit caabdd9

Browse files
committed
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.
1 parent 2034c0a commit caabdd9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ports/stm32/qspi.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ STATIC int qspi_ioctl(void *self_in, uint32_t cmd) {
139139
case MP_QSPI_IOCTL_INIT:
140140
qspi_init();
141141
break;
142+
case MP_QSPI_IOCTL_BUS_ACQUIRE:
143+
// Disable memory-mapped region during bus access
144+
qspi_mpu_disable_all();
145+
// Abort any ongoing transfer if peripheral is busy
146+
if (QUADSPI->SR & QUADSPI_SR_BUSY) {
147+
QUADSPI->CR |= QUADSPI_CR_ABORT;
148+
while (QUADSPI->CR & QUADSPI_CR_ABORT) {
149+
}
150+
}
151+
break;
142152
case MP_QSPI_IOCTL_BUS_RELEASE:
143153
// Switch to memory-map mode when bus is idle
144154
qspi_memory_map();

0 commit comments

Comments
 (0)
0