Skip to content

Commit 8a076d4

Browse files
author
Veijo Pesonen
committed
SPIFBlockDevice: refactoring usage of SFDP data
1 parent 6d77d0d commit 8a076d4

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ int SPIFBlockDevice::init()
184184

185185

186186
/**************************** Parse Basic Parameters Table ***********************************/
187-
if (_sfdp_parse_basic_param_table(callback(this, &SPIFBlockDevice::_spi_send_read_sfdp_command),
188-
_sfdp_info.bptbl.addr,
189-
_sfdp_info.bptbl.size) < 0) {
187+
if (_sfdp_parse_basic_param_table(callback(this, &SPIFBlockDevice::_spi_send_read_sfdp_command), _sfdp_info) < 0) {
190188
tr_error("init - Parse Basic Param Table Failed");
191189
status = SPIF_BD_ERROR_PARSING_FAILED;
192190
goto exit_point;
@@ -624,11 +622,11 @@ spif_bd_error SPIFBlockDevice::_spi_send_general_command(int instruction, bd_add
624622
/********** SFDP Parsing and Detection Functions *********/
625623
/*********************************************************/
626624
int SPIFBlockDevice::_sfdp_parse_basic_param_table(Callback<int(bd_addr_t, void *, bd_size_t)> sfdp_reader,
627-
uint32_t basic_table_addr, size_t basic_table_size)
625+
mbed::sfdp_hdr_info &sfdp_info)
628626
{
629627
uint8_t param_table[SFDP_BASIC_PARAMS_TBL_SIZE]; /* Up To 20 DWORDS = 80 Bytes */
630628

631-
int status = sfdp_reader(basic_table_addr, param_table, basic_table_size);
629+
int status = sfdp_reader(sfdp_info.bptbl.addr, param_table, sfdp_info.bptbl.size);
632630
if (status != SPIF_BD_ERROR_OK) {
633631
tr_error("init - Read SFDP First Table Failed");
634632
return -1;
@@ -655,14 +653,14 @@ int SPIFBlockDevice::_sfdp_parse_basic_param_table(Callback<int(bd_addr_t, void
655653
_erase_instruction = SPIF_SE;
656654

657655
// Set Page Size (SPI write must be done on Page limits)
658-
_page_size_bytes = _sfdp_detect_page_size(param_table, basic_table_size);
656+
_page_size_bytes = _sfdp_detect_page_size(param_table, sfdp_info.bptbl.size);
659657

660658
// Detect and Set Erase Types
661-
_sfdp_detect_erase_types_inst_and_size(param_table, basic_table_size, _erase4k_inst, _sfdp_info.smptbl);
659+
_sfdp_detect_erase_types_inst_and_size(param_table, sfdp_info.bptbl.size, _erase4k_inst, sfdp_info.smptbl);
662660
_erase_instruction = _erase4k_inst;
663661

664662
// Detect and Set fastest Bus mode (default 1-1-1)
665-
_sfdp_detect_best_bus_read_mode(param_table, basic_table_size, _read_instruction);
663+
_sfdp_detect_best_bus_read_mode(param_table, sfdp_info.bptbl.size, _read_instruction);
666664

667665
return 0;
668666
}

components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class SPIFBlockDevice : public mbed::BlockDevice {
231231

232232
// Parse and Detect required Basic Parameters from Table
233233
int _sfdp_parse_basic_param_table(mbed::Callback<int(mbed::bd_addr_t, void *, mbed::bd_size_t)> sfdp_reader,
234-
uint32_t basic_table_addr, size_t basic_table_size);
234+
mbed::sfdp_hdr_info &hdr_info);
235235

236236
// Detect fastest read Bus mode supported by device
237237
int _sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table_ptr, int basic_param_table_size, int &read_inst);

0 commit comments

Comments
 (0)