@@ -921,12 +921,19 @@ int OSPIFBlockDevice::remove_csel_instance(PinName csel)
921
921
/* ********************************************************/
922
922
/* ********* SFDP Parsing and Detection Functions *********/
923
923
/* ********************************************************/
924
- int OSPIFBlockDevice::_sfdp_parse_basic_param_table (Callback<int (bd_addr_t , void *, bd_size_t )> sfdp_reader,
924
+ int OSPIFBlockDevice::_sfdp_parse_basic_param_table (Callback<int (bd_addr_t , mbed:: sfdp_cmd_addr_size_t , uint8_t , uint8_t , void *, bd_size_t )> sfdp_reader,
925
925
sfdp_hdr_info &sfdp_info)
926
926
{
927
927
uint8_t param_table[SFDP_BASIC_PARAMS_TBL_SIZE]; /* Up To 20 DWORDS = 80 Bytes */
928
928
929
- int status = sfdp_reader (sfdp_info.bptbl .addr , param_table, sfdp_info.bptbl .size );
929
+ int status = sfdp_reader (
930
+ sfdp_info.bptbl .addr ,
931
+ SFDP_READ_CMD_ADDR_TYPE,
932
+ SFDP_READ_CMD_INST,
933
+ SFDP_READ_CMD_DUMMY_CYCLES,
934
+ param_table,
935
+ sfdp_info.bptbl .size
936
+ );
930
937
if (status != OSPI_STATUS_OK) {
931
938
tr_error (" Init - Read SFDP First Table Failed" );
932
939
return -1 ;
@@ -1383,12 +1390,19 @@ int OSPIFBlockDevice::_sfdp_detect_reset_protocol_and_reset(uint8_t *basic_param
1383
1390
return status;
1384
1391
}
1385
1392
1386
- int OSPIFBlockDevice::_sfdp_parse_4_byte_inst_table (Callback<int (bd_addr_t , void *, bd_size_t )> sfdp_reader,
1393
+ int OSPIFBlockDevice::_sfdp_parse_4_byte_inst_table (Callback<int (mbed:: bd_addr_t , mbed:: sfdp_cmd_addr_size_t , uint8_t , uint8_t , void *, mbed:: bd_size_t )> sfdp_reader,
1387
1394
sfdp_hdr_info &sfdp_info)
1388
1395
{
1389
1396
uint8_t four_byte_inst_table[SFDP_DEFAULT_4_BYTE_INST_TABLE_SIZE_BYTES]; /* Up To 2 DWORDS = 8 Bytes */
1390
1397
1391
- int status = sfdp_reader (sfdp_info.fbatbl .addr , four_byte_inst_table, sfdp_info.fbatbl .size );
1398
+ int status = sfdp_reader (
1399
+ sfdp_info.fbatbl .addr ,
1400
+ SFDP_READ_CMD_ADDR_TYPE,
1401
+ SFDP_READ_CMD_INST,
1402
+ SFDP_READ_CMD_DUMMY_CYCLES,
1403
+ four_byte_inst_table,
1404
+ sfdp_info.fbatbl .size
1405
+ );
1392
1406
if (status != OSPI_STATUS_OK) {
1393
1407
tr_error (" Init - Read SFDP Four Byte Inst Table Failed" );
1394
1408
return -1 ;
@@ -1823,21 +1837,48 @@ ospi_status_t OSPIFBlockDevice::_ospi_send_general_command(ospi_inst_t instructi
1823
1837
return OSPI_STATUS_OK;
1824
1838
}
1825
1839
1826
- int OSPIFBlockDevice::_ospi_send_read_sfdp_command (bd_addr_t addr, void *rx_buffer, bd_size_t rx_length)
1840
+ int OSPIFBlockDevice::_ospi_send_read_sfdp_command (mbed::bd_addr_t addr, mbed::sfdp_cmd_addr_size_t addr_size,
1841
+ uint8_t inst, uint8_t dummy_cycles,
1842
+ void *rx_buffer, mbed::bd_size_t rx_length)
1827
1843
{
1828
- size_t rx_len = rx_length;
1829
1844
uint8_t *rx_buffer_tmp = (uint8_t *)rx_buffer;
1830
1845
1846
+ // Set default here to avoid uninitialized variable warning
1847
+ ospi_address_size_t address_size = _address_size;
1848
+ int address = addr;
1849
+ switch (addr_size) {
1850
+ case SFDP_CMD_ADDR_3_BYTE:
1851
+ address_size = OSPI_CFG_ADDR_SIZE_24;
1852
+ break ;
1853
+ case SFDP_CMD_ADDR_4_BYTE:
1854
+ address_size = OSPI_CFG_ADDR_SIZE_32;
1855
+ break ;
1856
+ case SFDP_CMD_ADDR_SIZE_VARIABLE: // use current setting
1857
+ break ;
1858
+ case SFDP_CMD_ADDR_NONE: // no address in command
1859
+ address = static_cast <int >(OSPI_NO_ADDRESS_COMMAND);
1860
+ break ;
1861
+ default :
1862
+ tr_error (" Invalid SFDP command address size: 0x%02X" , addr_size);
1863
+ return -1 ;
1864
+ }
1865
+
1866
+ if (dummy_cycles == SFDP_CMD_DUMMY_CYCLES_VARIABLE) {
1867
+ // use current setting
1868
+ dummy_cycles = _dummy_cycles;
1869
+ }
1870
+
1831
1871
// SFDP read instruction requires 1-1-1 bus mode with 8 dummy cycles and a 3-byte address
1832
- ospi_status_t status = _ospi.configure_format (OSPI_CFG_BUS_SINGLE, OSPI_CFG_INST_SIZE_8, OSPI_CFG_BUS_SINGLE, OSPI_CFG_ADDR_SIZE_24 , OSPI_CFG_BUS_SINGLE, 0 , OSPI_CFG_BUS_SINGLE, OSPIF_RSFDP_DUMMY_CYCLES );
1872
+ ospi_status_t status = _ospi.configure_format (OSPI_CFG_BUS_SINGLE, OSPI_CFG_INST_SIZE_8, OSPI_CFG_BUS_SINGLE, address_size , OSPI_CFG_BUS_SINGLE, 0 , OSPI_CFG_BUS_SINGLE, dummy_cycles );
1833
1873
if (OSPI_STATUS_OK != status) {
1834
1874
tr_error (" _ospi_configure_format failed" );
1835
1875
return status;
1836
1876
}
1837
1877
1838
1878
// Don't check the read status until after we've configured the format back to 1-1-1, to avoid leaving the interface in an
1839
1879
// incorrect state if the read fails.
1840
- status = _ospi.read (OSPIF_INST_RSFDP, -1 , (unsigned int ) addr, (char *) rx_buffer, &rx_len);
1880
+ size_t rx_len = rx_length;
1881
+ status = _ospi.read (inst, -1 , address, static_cast <char *>(rx_buffer), &rx_len);
1841
1882
1842
1883
ospi_status_t format_status = _ospi.configure_format (OSPI_CFG_BUS_SINGLE, OSPI_CFG_INST_SIZE_8, OSPI_CFG_BUS_SINGLE, _address_size, OSPI_CFG_BUS_SINGLE, 0 , OSPI_CFG_BUS_SINGLE, 0 );
1843
1884
// All commands other than Read and RSFDP use default 1-1-1 bus mode (Program/Erase are constrained by flash memory performance more than bus performance)
0 commit comments