Skip to content

Commit 3a64383

Browse files
fix qspi address sending for nrf52
fix address sending in qspi_command_transfer now address is send MSB first
1 parent c836b79 commit 3a64383

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

TESTS/mbed_hal/qspi/flash_configs/NORDIC/NRF52840_DK/flash_config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@
2929
#undef QSPI_CMD_READ_1IO
3030
#define QSPI_CMD_READ_1IO QSPI_CMD_READ_1IO_FAST
3131

32-
3332
#endif // MBED_QSPI_FLASH_CONFIG_H

targets/TARGET_NORDIC/TARGET_NRF5x/qspi_api.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ qspi_status_t qspi_command_transfer(qspi_t *obj, const qspi_command_t *command,
281281
ret_code_t ret_code;
282282
uint8_t data[8];
283283
uint32_t data_size = tx_size + rx_size;
284-
284+
285285
nrf_qspi_cinstr_conf_t qspi_cinstr_config;
286286
qspi_cinstr_config.opcode = command->instruction.value;
287287
qspi_cinstr_config.io2_level = true;
@@ -298,8 +298,10 @@ qspi_status_t qspi_command_transfer(qspi_t *obj, const qspi_command_t *command,
298298
} else {
299299
return QSPI_STATUS_INVALID_PARAMETER;
300300
}
301-
for (uint32_t i = 0; i < (uint32_t)qspi_cinstr_config.length - 1; ++i) {
302-
data[i] = ((uint8_t *)&command->address.value)[i];
301+
uint32_t address_size = (uint32_t)qspi_cinstr_config.length - 1;
302+
uint8_t *address_bytes = (uint8_t *)&command->address.value;
303+
for (uint32_t i = 0; i < address_size; ++i) {
304+
data[i] = address_bytes[address_size - 1 - i];
303305
}
304306
} else if (data_size < 9) {
305307
qspi_cinstr_config.length = (nrf_qspi_cinstr_len_t)(NRF_QSPI_CINSTR_LEN_1B + data_size);
@@ -321,7 +323,7 @@ qspi_status_t qspi_command_transfer(qspi_t *obj, const qspi_command_t *command,
321323
// Data is sending as a normal SPI transmission so there is one buffer to send and receive data.
322324
((uint8_t *)rx_data)[i] = data[i];
323325
}
324-
326+
325327
return QSPI_STATUS_OK;
326328
}
327329

0 commit comments

Comments
 (0)