Replace power function with bit shift

pull/11894/head
Matthew Macovsky 2019-08-30 03:12:59 -07:00 committed by adbridge
parent c0ea38c079
commit 4886cc2cbe
1 changed files with 1 additions and 18 deletions

View File

@ -113,9 +113,6 @@ enum qspif_default_instructions {
QSPIF_ULBPR = 0x98, // Clears all write-protection bits in the Block-Protection register QSPIF_ULBPR = 0x98, // Clears all write-protection bits in the Block-Protection register
}; };
// Local Function
static int local_math_power(int base, int exp);
// General QSPI instructions // General QSPI instructions
#define QSPIF_INST_WSR1 0x01 // Write status register 1 #define QSPIF_INST_WSR1 0x01 // Write status register 1
#define QSPIF_INST_RSR1 0x05 // Read status register 1 #define QSPIF_INST_RSR1 0x05 // Read status register 1
@ -882,7 +879,7 @@ int QSPIFBlockDevice::_sfdp_detect_page_size(uint8_t *basic_param_table_ptr, int
if (basic_param_table_size > QSPIF_BASIC_PARAM_TABLE_PAGE_SIZE_BYTE) { if (basic_param_table_size > QSPIF_BASIC_PARAM_TABLE_PAGE_SIZE_BYTE) {
// Page Size is specified by 4 Bits (N), calculated by 2^N // Page Size is specified by 4 Bits (N), calculated by 2^N
int page_to_power_size = ((int)basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_PAGE_SIZE_BYTE]) >> 4; int page_to_power_size = ((int)basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_PAGE_SIZE_BYTE]) >> 4;
page_size = local_math_power(2, page_to_power_size); page_size = 1 << page_to_power_size;
tr_debug("Detected Page Size: %d", page_size); tr_debug("Detected Page Size: %d", page_size);
} else { } else {
tr_debug("Using Default Page Size: %d", page_size); tr_debug("Using Default Page Size: %d", page_size);
@ -1610,17 +1607,3 @@ qspi_status_t QSPIFBlockDevice::_qspi_write_status_registers(uint8_t *reg_buffer
return QSPI_STATUS_OK; return QSPI_STATUS_OK;
} }
/*********************************************/
/************** Local Functions **************/
/*********************************************/
static int local_math_power(int base, int exp)
{
// Integer X^Y function, used to calculate size fields given in 2^N format
int result = 1;
while (exp) {
result *= base;
exp--;
}
return result;
}