|
15 | 15 | */
|
16 | 16 |
|
17 | 17 | #include "drivers/internal/SFDP.h"
|
| 18 | +#include "platform/Callback.h" |
18 | 19 | #include "QSPIFBlockDevice.h"
|
19 | 20 | #include <string.h>
|
20 | 21 | #include "rtos/ThisThread.h"
|
@@ -628,59 +629,14 @@ int QSPIFBlockDevice::remove_csel_instance(PinName csel)
|
628 | 629 | /*********************************************************/
|
629 | 630 | int QSPIFBlockDevice::_sfdp_parse_sfdp_headers(mbed::sfdp_hdr_info &hdr_info)
|
630 | 631 | {
|
631 |
| - bd_addr_t addr = 0x0; |
632 |
| - int number_of_param_headers = 0; |
633 |
| - size_t data_length; |
634 |
| - |
635 |
| - { |
636 |
| - data_length = SFDP_HEADER_SIZE; |
637 |
| - uint8_t sfdp_header[SFDP_HEADER_SIZE]; |
638 |
| - |
639 |
| - qspi_status_t status = _qspi_send_read_sfdp_command(addr, (char *)sfdp_header, data_length); |
640 |
| - if (status != QSPI_STATUS_OK) { |
641 |
| - tr_error("init - Retrieving SFDP Header failed"); |
642 |
| - return -1; |
643 |
| - } |
644 |
| - |
645 |
| - number_of_param_headers = sfdp_parse_sfdp_header((sfdp_hdr *)sfdp_header); |
646 |
| - if (number_of_param_headers < 0) { |
647 |
| - return number_of_param_headers; |
648 |
| - } |
649 |
| - } |
650 |
| - |
651 |
| - addr += SFDP_HEADER_SIZE; |
652 |
| - |
653 |
| - { |
654 |
| - data_length = SFDP_HEADER_SIZE; |
655 |
| - uint8_t param_header[SFDP_HEADER_SIZE]; |
656 |
| - qspi_status_t status; |
657 |
| - int hdr_status; |
658 |
| - |
659 |
| - // Loop over Param Headers and parse them (currently supports Basic Param Table and Sector Region Map Table) |
660 |
| - for (int i_ind = 0; i_ind < number_of_param_headers; i_ind++) { |
661 |
| - status = _qspi_send_read_sfdp_command(addr, (char *)param_header, data_length); |
662 |
| - if (status != QSPI_STATUS_OK) { |
663 |
| - tr_error("init - Retrieving Parameter Header %d failed", i_ind + 1); |
664 |
| - return -1; |
665 |
| - } |
666 |
| - |
667 |
| - hdr_status = sfdp_parse_single_param_header((sfdp_prm_hdr *)param_header, hdr_info); |
668 |
| - if (hdr_status < 0) { |
669 |
| - return hdr_status; |
670 |
| - } |
671 |
| - |
672 |
| - addr += SFDP_HEADER_SIZE; |
673 |
| - } |
674 |
| - } |
675 |
| - |
676 |
| - return 0; |
| 632 | + return sfdp_parse_headers(callback(this, &QSPIFBlockDevice::_qspi_send_read_sfdp_command), hdr_info); |
677 | 633 | }
|
678 | 634 |
|
679 | 635 | int QSPIFBlockDevice::_sfdp_parse_basic_param_table(uint32_t basic_table_addr, size_t basic_table_size)
|
680 | 636 | {
|
681 | 637 | uint8_t param_table[SFDP_DEFAULT_BASIC_PARAMS_TABLE_SIZE_BYTES]; /* Up To 16 DWORDS = 64 Bytes */
|
682 | 638 |
|
683 |
| - qspi_status_t status = _qspi_send_read_sfdp_command(basic_table_addr, (char *) param_table, basic_table_size); |
| 639 | + int status = _qspi_send_read_sfdp_command(basic_table_addr, (char *)param_table, basic_table_size); |
684 | 640 | if (status != QSPI_STATUS_OK) {
|
685 | 641 | tr_error("Init - Read SFDP First Table Failed");
|
686 | 642 | return -1;
|
@@ -1161,7 +1117,7 @@ int QSPIFBlockDevice::_sfdp_parse_sector_map_table(uint32_t sector_map_table_add
|
1161 | 1117 | // Default set to all type bits 1-4 are common
|
1162 | 1118 | int min_common_erase_type_bits = ERASE_BITMASK_ALL;
|
1163 | 1119 |
|
1164 |
| - qspi_status_t status = _qspi_send_read_sfdp_command(sector_map_table_addr, (char *) sector_map_table, sector_map_table_size); |
| 1120 | + int status = _qspi_send_read_sfdp_command(sector_map_table_addr, (char *)sector_map_table, sector_map_table_size); |
1165 | 1121 | if (status != QSPI_STATUS_OK) {
|
1166 | 1122 | tr_error("Init - Read SFDP First Table Failed");
|
1167 | 1123 | return -1;
|
@@ -1604,7 +1560,7 @@ qspi_status_t QSPIFBlockDevice::_qspi_send_general_command(qspi_inst_t instructi
|
1604 | 1560 | return QSPI_STATUS_OK;
|
1605 | 1561 | }
|
1606 | 1562 |
|
1607 |
| -qspi_status_t QSPIFBlockDevice::_qspi_send_read_sfdp_command(bd_addr_t addr, void *rx_buffer, bd_size_t rx_length) |
| 1563 | +int QSPIFBlockDevice::_qspi_send_read_sfdp_command(bd_addr_t addr, void *rx_buffer, bd_size_t rx_length) |
1608 | 1564 | {
|
1609 | 1565 | size_t rx_len = rx_length;
|
1610 | 1566 |
|
|
0 commit comments