@@ -170,6 +170,25 @@ void qspi_memory_map(void) {
170
170
qspi_mpu_enable_mapped ();
171
171
}
172
172
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
+
173
192
static int qspi_ioctl (void * self_in , uint32_t cmd , uintptr_t arg ) {
174
193
(void )self_in ;
175
194
switch (cmd ) {
@@ -178,13 +197,7 @@ static int qspi_ioctl(void *self_in, uint32_t cmd, uintptr_t arg) {
178
197
break ;
179
198
case MP_QSPI_IOCTL_BUS_ACQUIRE :
180
199
// 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 ();
188
201
break ;
189
202
case MP_QSPI_IOCTL_BUS_RELEASE :
190
203
// Switch to memory-map mode when bus is idle
0 commit comments