Content-Length: 346325 | pFad | http://github.com/micropython/micropython/commit/ac1cbef36661625dabc47bc4aa0aa7a0d076dec1

7E stm32/qspi: Add qspi_memory_map_exit and restart. · micropython/micropython@ac1cbef · GitHub
Skip to content

Commit ac1cbef

Browse files
committed
stm32/qspi: Add qspi_memory_map_exit and restart.
Signed-off-by: Damien George <damien@micropython.org>
1 parent c18e925 commit ac1cbef

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

ports/stm32/qspi.c

+20-7
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,25 @@ void qspi_memory_map(void) {
170170
qspi_mpu_enable_mapped();
171171
}
172172

173+
void qspi_memory_map_exit(void) {
174+
// Prevent access to QSPI memory-mapped region.
175+
qspi_mpu_disable_all();
176+
177+
// Abort any ongoing transfer if peripheral is busy
178+
if (QUADSPI->SR & QUADSPI_SR_BUSY) {
179+
QUADSPI->CR |= QUADSPI_CR_ABORT;
180+
while (QUADSPI->CR & QUADSPI_CR_ABORT) {
181+
}
182+
}
183+
}
184+
185+
// Needed on F7 due to errata 2.4.3: "Memory-mapped read operations may fail when timeout counter is enabled".
186+
// Call this function to disable then re-enable memory-mapped mode, which resets the CS pin to inactive.
187+
void qspi_memory_map_restart(void) {
188+
qspi_memory_map_exit();
189+
qspi_memory_map();
190+
}
191+
173192
static int qspi_ioctl(void *self_in, uint32_t cmd, uintptr_t arg) {
174193
(void)self_in;
175194
switch (cmd) {
@@ -178,13 +197,7 @@ static int qspi_ioctl(void *self_in, uint32_t cmd, uintptr_t arg) {
178197
break;
179198
case MP_QSPI_IOCTL_BUS_ACQUIRE:
180199
// Disable memory-mapped region during bus access
181-
qspi_mpu_disable_all();
182-
// Abort any ongoing transfer if peripheral is busy
183-
if (QUADSPI->SR & QUADSPI_SR_BUSY) {
184-
QUADSPI->CR |= QUADSPI_CR_ABORT;
185-
while (QUADSPI->CR & QUADSPI_CR_ABORT) {
186-
}
187-
}
200+
qspi_memory_map_exit();
188201
break;
189202
case MP_QSPI_IOCTL_BUS_RELEASE:
190203
// Switch to memory-map mode when bus is idle

ports/stm32/qspi.h

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ extern const mp_qspi_proto_t qspi_proto;
3535

3636
void qspi_init(void);
3737
void qspi_memory_map(void);
38+
void qspi_memory_map_exit(void);
39+
void qspi_memory_map_restart(void);
3840

3941
static inline bool qspi_is_valid_addr(uint32_t addr) {
4042
return QSPI_MAP_ADDR <= addr && addr < QSPI_MAP_ADDR_MAX;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/micropython/micropython/commit/ac1cbef36661625dabc47bc4aa0aa7a0d076dec1

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy