@@ -163,8 +163,8 @@ qspi_status_t qspi_write(qspi_t *obj, const qspi_command_t *command, const void
163
163
QSPI_WriteConfig_TypeDef cfg = QSPI_WRITECONFIG_DEFAULT ;
164
164
uint32_t to_write = * length ;
165
165
166
- // Enforce word-aligned and word- sized access
167
- if ((to_write & 0x3 ) != 0 || (( uint32_t ) data & 0x3 ) != 0 ) {
166
+ // Enforce word-sized access
167
+ if ((to_write & 0x3 ) != 0 ) {
168
168
return QSPI_STATUS_INVALID_PARAMETER ;
169
169
}
170
170
@@ -216,6 +216,8 @@ qspi_status_t qspi_write(qspi_t *obj, const qspi_command_t *command, const void
216
216
// Wait for the QSPI in case we're writing too fast
217
217
while (((obj -> instance -> SRAMFILL & _QSPI_SRAMFILL_SRAMFILLINDACWRITE_MASK ) >> _QSPI_SRAMFILL_SRAMFILLINDACWRITE_SHIFT ) >= 126 );
218
218
219
+ // Unaligned access is fine on CM3/CM4 provided we stick to LDR/STR
220
+ // With the line below, the compiler can't really do anything else anyways
219
221
* ((uint32_t * )QSPI0_MEM_BASE ) = ((uint32_t * )data )[i /4 ];
220
222
}
221
223
@@ -284,8 +286,8 @@ qspi_status_t qspi_read(qspi_t *obj, const qspi_command_t *command, void *data,
284
286
QSPI_ReadConfig_TypeDef cfg = QSPI_READCONFIG_DEFAULT ;
285
287
uint32_t to_read = * length ;
286
288
287
- // Enforce word-aligned and word- sized access
288
- if ((to_read & 0x3 ) != 0 || (( uint32_t ) data & 0x3 ) != 0 ) {
289
+ // Enforce word-sized access
290
+ if ((to_read & 0x3 ) != 0 ) {
289
291
return QSPI_STATUS_INVALID_PARAMETER ;
290
292
}
291
293
@@ -353,6 +355,8 @@ qspi_status_t qspi_read(qspi_t *obj, const qspi_command_t *command, void *data,
353
355
// Wait for the FIFO in case we're reading too fast
354
356
while ((obj -> instance -> SRAMFILL & _QSPI_SRAMFILL_SRAMFILLINDACREAD_MASK ) >> _QSPI_SRAMFILL_SRAMFILLINDACREAD_SHIFT == 0 );
355
357
358
+ // Unaligned access is fine on CM3/CM4 provided we stick to LDR/STR
359
+ // With the line below, the compiler can't really do anything else anyways
356
360
((uint32_t * )data )[i /4 ] = * ((uint32_t * )QSPI0_MEM_BASE );
357
361
}
358
362
0 commit comments