Minor optimizations and code style fixes

pull/7783/head
Senthil Ramakrishnan 2017-12-04 13:06:39 -06:00 committed by Maciej Bocianski
parent cb4308ad64
commit 273cf05d92
2 changed files with 6 additions and 10 deletions

View File

@ -52,8 +52,6 @@ qspi_status_t QSPI::configure_format(qspi_bus_width_t inst_width, qspi_bus_width
{ {
qspi_status_t ret_status = QSPI_STATUS_OK; qspi_status_t ret_status = QSPI_STATUS_OK;
if(dummy_cycles < 0)
return QSPI_STATUS_INVALID_PARAMETER;
if(mode != 0 && mode != 1) if(mode != 0 && mode != 1)
return QSPI_STATUS_INVALID_PARAMETER; return QSPI_STATUS_INVALID_PARAMETER;
@ -119,7 +117,7 @@ qspi_status_t QSPI::read(unsigned int address, char *rx_buffer, size_t *rx_lengt
} else { } else {
ret_status = QSPI_STATUS_INVALID_PARAMETER; ret_status = QSPI_STATUS_INVALID_PARAMETER;
} }
} //if(_initialized) }
return ret_status; return ret_status;
} }
@ -143,7 +141,7 @@ qspi_status_t QSPI::write(unsigned int address, const char *tx_buffer, size_t *t
} else { } else {
ret_status = QSPI_STATUS_INVALID_PARAMETER; ret_status = QSPI_STATUS_INVALID_PARAMETER;
} }
} //if(_initialized) }
return ret_status; return ret_status;
} }
@ -167,7 +165,7 @@ qspi_status_t QSPI::read(unsigned int instruction, unsigned int address, unsigne
} else { } else {
ret_status = QSPI_STATUS_INVALID_PARAMETER; ret_status = QSPI_STATUS_INVALID_PARAMETER;
} }
} //if(_initialized) }
return ret_status; return ret_status;
} }
@ -191,7 +189,7 @@ qspi_status_t QSPI::write(unsigned int instruction, unsigned int address, unsign
} else { } else {
ret_status = QSPI_STATUS_INVALID_PARAMETER; ret_status = QSPI_STATUS_INVALID_PARAMETER;
} }
} //if(_initialized) }
return ret_status; return ret_status;
} }
@ -205,12 +203,11 @@ qspi_status_t QSPI::command_transfer(unsigned int instruction, const char *tx_bu
if(true == _acquire()) { if(true == _acquire()) {
qspi_command_t *qspi_cmd = _build_qspi_command(instruction, -1, -1); //We just need the command qspi_command_t *qspi_cmd = _build_qspi_command(instruction, -1, -1); //We just need the command
if(QSPI_STATUS_OK == qspi_command_transfer(&_qspi, qspi_cmd, (const void *)tx_buffer, tx_length, (void *)rx_buffer, rx_length)) { if(QSPI_STATUS_OK == qspi_command_transfer(&_qspi, qspi_cmd, (const void *)tx_buffer, tx_length, (void *)rx_buffer, rx_length)) {
//We got error status, return 0
ret_status = QSPI_STATUS_OK; ret_status = QSPI_STATUS_OK;
} }
} }
unlock(); unlock();
} //if(_initialized) }
return ret_status; return ret_status;
} }
@ -280,7 +277,6 @@ qspi_command_t *QSPI::_build_qspi_command(int instruction, int address, int alt)
_qspi_command.alt.value = 0; _qspi_command.alt.value = 0;
} }
//Set up dummy cycle count
_qspi_command.dummy_count = _num_dummy_cycles; _qspi_command.dummy_count = _num_dummy_cycles;
//Set up bus width for data phase //Set up bus width for data phase

View File

@ -201,7 +201,7 @@ protected:
qspi_alt_size_t _alt_size; qspi_alt_size_t _alt_size;
qspi_bus_width_t _data_width; //Bus width for Data phase qspi_bus_width_t _data_width; //Bus width for Data phase
qspi_command_t _qspi_command; //QSPI Hal command struct qspi_command_t _qspi_command; //QSPI Hal command struct
int _num_dummy_cycles; //Number of dummy cycles to be used unsigned int _num_dummy_cycles; //Number of dummy cycles to be used
int _hz; //Bus Frequency int _hz; //Bus Frequency
int _mode; //SPI mode int _mode; //SPI mode
bool _initialized; bool _initialized;