mirror of https://github.com/ARMmbed/mbed-os.git
Q/SPIF: Abstracts SFDP table reading functionality from device
parent
829a3cded3
commit
fe49c9ce16
|
|
@ -252,7 +252,8 @@ int QSPIFBlockDevice::init()
|
|||
}
|
||||
|
||||
/**************************** Parse Basic Parameters Table ***********************************/
|
||||
if (0 != _sfdp_parse_basic_param_table(_sfdp_info.bptbl.addr, _sfdp_info.bptbl.size)) {
|
||||
if (_sfdp_parse_basic_param_table(callback(this, &QSPIFBlockDevice::_qspi_send_read_sfdp_command),
|
||||
_sfdp_info.bptbl.addr, _sfdp_info.bptbl.size) < 0) {
|
||||
tr_error("Init - Parse Basic Param Table Failed");
|
||||
status = QSPIF_BD_ERROR_PARSING_FAILED;
|
||||
goto exit_point;
|
||||
|
|
@ -626,11 +627,12 @@ int QSPIFBlockDevice::remove_csel_instance(PinName csel)
|
|||
/*********************************************************/
|
||||
/********** SFDP Parsing and Detection Functions *********/
|
||||
/*********************************************************/
|
||||
int QSPIFBlockDevice::_sfdp_parse_basic_param_table(uint32_t basic_table_addr, size_t basic_table_size)
|
||||
int QSPIFBlockDevice::_sfdp_parse_basic_param_table(Callback<int(bd_addr_t, void *, bd_size_t)> sfdp_reader,
|
||||
uint32_t basic_table_addr, size_t basic_table_size)
|
||||
{
|
||||
uint8_t param_table[SFDP_BASIC_PARAMS_TBL_SIZE]; /* Up To 16 DWORDS = 64 Bytes */
|
||||
uint8_t param_table[SFDP_BASIC_PARAMS_TBL_SIZE]; /* Up To 20 DWORDS = 80 Bytes */
|
||||
|
||||
int status = _qspi_send_read_sfdp_command(basic_table_addr, (char *)param_table, basic_table_size);
|
||||
int status = sfdp_reader(basic_table_addr, param_table, basic_table_size);
|
||||
if (status != QSPI_STATUS_OK) {
|
||||
tr_error("Init - Read SFDP First Table Failed");
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -317,7 +317,8 @@ private:
|
|||
/* SFDP Detection and Parsing Functions */
|
||||
/****************************************/
|
||||
// Parse and Detect required Basic Parameters from Table
|
||||
int _sfdp_parse_basic_param_table(uint32_t basic_table_addr, size_t basic_table_size);
|
||||
int _sfdp_parse_basic_param_table(mbed::Callback<int(mbed::bd_addr_t, void *, mbed::bd_size_t)> sfdp_reader,
|
||||
uint32_t basic_table_addr, size_t basic_table_size);
|
||||
|
||||
// Detect the soft reset protocol and reset - returns error if soft reset is not supported
|
||||
int _sfdp_detect_reset_protocol_and_reset(uint8_t *basic_param_table_ptr);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ using namespace mbed;
|
|||
|
||||
/* Basic Parameters Table Parsing */
|
||||
/**********************************/
|
||||
#define SFDP_DEFAULT_BASIC_PARAMS_TABLE_SIZE_BYTES 64 /* 16 DWORDS */
|
||||
//READ Instruction support according to BUS Configuration
|
||||
#define SPIF_BASIC_PARAM_TABLE_FAST_READ_SUPPORT_BYTE 2
|
||||
#define SPIF_BASIC_PARAM_TABLE_QPI_READ_SUPPORT_BYTE 16
|
||||
|
|
@ -183,7 +182,7 @@ int SPIFBlockDevice::init()
|
|||
|
||||
|
||||
/**************************** Parse Basic Parameters Table ***********************************/
|
||||
if (0 != _sfdp_parse_basic_param_table(hdr_info.bptbl.addr, hdr_info.bptbl.size)) {
|
||||
if (0 != _sfdp_parse_basic_param_table(callback(this, &SPIFBlockDevice::_spi_send_read_sfdp_command), hdr_info.bptbl.addr, hdr_info.bptbl.size)) {
|
||||
tr_error("init - Parse Basic Param Table Failed");
|
||||
status = SPIF_BD_ERROR_PARSING_FAILED;
|
||||
goto exit_point;
|
||||
|
|
@ -620,13 +619,12 @@ spif_bd_error SPIFBlockDevice::_spi_send_general_command(int instruction, bd_add
|
|||
/*********************************************************/
|
||||
/********** SFDP Parsing and Detection Functions *********/
|
||||
/*********************************************************/
|
||||
int SPIFBlockDevice::_sfdp_parse_basic_param_table(uint32_t basic_table_addr, size_t basic_table_size)
|
||||
int SPIFBlockDevice::_sfdp_parse_basic_param_table(Callback<int(bd_addr_t, void *, bd_size_t)> sfdp_reader,
|
||||
uint32_t basic_table_addr, size_t basic_table_size)
|
||||
{
|
||||
uint8_t param_table[SFDP_DEFAULT_BASIC_PARAMS_TABLE_SIZE_BYTES]; /* Up To 16 DWORDS = 64 Bytes */
|
||||
//memset(param_table, 0, SFDP_DEFAULT_BASIC_PARAMS_TABLE_SIZE_BYTES);
|
||||
uint8_t param_table[SFDP_BASIC_PARAMS_TBL_SIZE]; /* Up To 20 DWORDS = 80 Bytes */
|
||||
|
||||
spif_bd_error status = _spi_send_read_command(SPIF_SFDP, param_table, basic_table_addr /*address*/,
|
||||
basic_table_size);
|
||||
int status = sfdp_reader(basic_table_addr, param_table, basic_table_size);
|
||||
if (status != SPIF_BD_ERROR_OK) {
|
||||
tr_error("init - Read SFDP First Table Failed");
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -230,7 +230,8 @@ private:
|
|||
int _spi_send_read_sfdp_command(mbed::bd_addr_t addr, void *rx_buffer, mbed::bd_size_t rx_length);
|
||||
|
||||
// Parse and Detect required Basic Parameters from Table
|
||||
int _sfdp_parse_basic_param_table(uint32_t basic_table_addr, size_t basic_table_size);
|
||||
int _sfdp_parse_basic_param_table(mbed::Callback<int(mbed::bd_addr_t, void *, mbed::bd_size_t)> sfdp_reader,
|
||||
uint32_t basic_table_addr, size_t basic_table_size);
|
||||
|
||||
// Detect fastest read Bus mode supported by device
|
||||
int _sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table_ptr, int basic_param_table_size, int &read_inst);
|
||||
|
|
|
|||
Loading…
Reference in New Issue