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.
pull/4892/head
Damien George 2019-07-03 01:00:40 +10:00
rodzic 2034c0a2e3
commit caabdd99c0
1 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -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();