fix qspi address sending for nrf52

fix address sending in qspi_command_transfer
now address is send MSB first
pull/7925/head
Maciej Bocianski 2018-08-30 14:45:45 +02:00
parent c836b79e37
commit 3a64383de5
2 changed files with 6 additions and 5 deletions

View File

@ -29,5 +29,4 @@
#undef QSPI_CMD_READ_1IO #undef QSPI_CMD_READ_1IO
#define QSPI_CMD_READ_1IO QSPI_CMD_READ_1IO_FAST #define QSPI_CMD_READ_1IO QSPI_CMD_READ_1IO_FAST
#endif // MBED_QSPI_FLASH_CONFIG_H #endif // MBED_QSPI_FLASH_CONFIG_H

View File

@ -281,7 +281,7 @@ qspi_status_t qspi_command_transfer(qspi_t *obj, const qspi_command_t *command,
ret_code_t ret_code; ret_code_t ret_code;
uint8_t data[8]; uint8_t data[8];
uint32_t data_size = tx_size + rx_size; uint32_t data_size = tx_size + rx_size;
nrf_qspi_cinstr_conf_t qspi_cinstr_config; nrf_qspi_cinstr_conf_t qspi_cinstr_config;
qspi_cinstr_config.opcode = command->instruction.value; qspi_cinstr_config.opcode = command->instruction.value;
qspi_cinstr_config.io2_level = true; qspi_cinstr_config.io2_level = true;
@ -298,8 +298,10 @@ qspi_status_t qspi_command_transfer(qspi_t *obj, const qspi_command_t *command,
} else { } else {
return QSPI_STATUS_INVALID_PARAMETER; return QSPI_STATUS_INVALID_PARAMETER;
} }
for (uint32_t i = 0; i < (uint32_t)qspi_cinstr_config.length - 1; ++i) { uint32_t address_size = (uint32_t)qspi_cinstr_config.length - 1;
data[i] = ((uint8_t *)&command->address.value)[i]; uint8_t *address_bytes = (uint8_t *)&command->address.value;
for (uint32_t i = 0; i < address_size; ++i) {
data[i] = address_bytes[address_size - 1 - i];
} }
} else if (data_size < 9) { } else if (data_size < 9) {
qspi_cinstr_config.length = (nrf_qspi_cinstr_len_t)(NRF_QSPI_CINSTR_LEN_1B + data_size); 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,
// Data is sending as a normal SPI transmission so there is one buffer to send and receive data. // Data is sending as a normal SPI transmission so there is one buffer to send and receive data.
((uint8_t *)rx_data)[i] = data[i]; ((uint8_t *)rx_data)[i] = data[i];
} }
return QSPI_STATUS_OK; return QSPI_STATUS_OK;
} }