@@ -995,18 +995,35 @@ int QSPIFBlockDevice::_sfdp_detect_and_enable_4byte_addressing(uint8_t *basic_pa
995995 return status;
996996}
997997
998+ #if MBED_CONF_QSPIF_ENABLE_AND_RESET && MBED_CONF_QSPIF_DIRECT_RESET
999+ #error "qspif.enable-and-reset and qspif.direct-reset cannot be both true!"
1000+ #endif
1001+
1002+ #define RESET_SEQUENCE_FROM_SFDP ( !MBED_CONF_QSPIF_ENABLE_AND_RESET && !MBED_CONF_QSPIF_DIRECT_RESET )
1003+
9981004int QSPIFBlockDevice::_sfdp_detect_reset_protocol_and_reset (uint8_t *basic_param_table_ptr)
9991005{
10001006 int status = QSPIF_BD_ERROR_OK;
1007+
1008+ #if RESET_SEQUENCE_FROM_SFDP
10011009 uint8_t examined_byte = basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_SOFT_RESET_BYTE];
10021010
10031011 // Ignore bit indicating need to exit 0-4-4 mode - should not enter 0-4-4 mode from QSPIFBlockDevice
10041012 if (examined_byte & SOFT_RESET_RESET_INST_BITMASK) {
1013+ #endif
1014+
1015+ #if !MBED_CONF_QSPIF_ENABLE_AND_RESET // i.e. direct reset, or determined from SFDP
10051016 // Issue instruction 0xF0 to reset the device
10061017 qspi_status_t qspi_status = _qspi_send_general_command (0xF0 , QSPI_NO_ADDRESS_COMMAND, // Send reset instruction
10071018 NULL , 0 , NULL , 0 );
10081019 status = (qspi_status == QSPI_STATUS_OK) ? QSPIF_BD_ERROR_OK : QSPIF_BD_ERROR_PARSING_FAILED;
1020+ #endif
1021+
1022+ #if RESET_SEQUENCE_FROM_SFDP
10091023 } else if (examined_byte & SOFT_RESET_ENABLE_AND_RESET_INST_BITMASK) {
1024+ #endif
1025+
1026+ #if !MBED_CONF_QSPIF_DIRECT_RESET // i.e. enable and reset, or determined from SFDP
10101027 // Issue instruction 66h to enable resets on the device
10111028 // Then issue instruction 99h to reset the device
10121029 qspi_status_t qspi_status = _qspi_send_general_command (0x66 , QSPI_NO_ADDRESS_COMMAND, // Send reset enable instruction
@@ -1016,10 +1033,15 @@ int QSPIFBlockDevice::_sfdp_detect_reset_protocol_and_reset(uint8_t *basic_param
10161033 NULL , 0 , NULL , 0 );
10171034 }
10181035 status = (qspi_status == QSPI_STATUS_OK) ? QSPIF_BD_ERROR_OK : QSPIF_BD_ERROR_PARSING_FAILED;
1036+ #endif
1037+
1038+ #if RESET_SEQUENCE_FROM_SFDP
10191039 } else {
10201040 // Soft reset either is not supported or requires direct control over data lines
1041+ tr_error (" Failed to determine soft reset sequence. If your device has a legacy SFDP table, please manually set enable-and-reset or direct-reset." );
10211042 status = QSPIF_BD_ERROR_PARSING_FAILED;
10221043 }
1044+ #endif
10231045
10241046 if (status == QSPIF_BD_ERROR_OK) {
10251047 if (false == _is_mem_ready ()) {
0 commit comments