Skip to content

Commit

Permalink
fix ambiguous global enum definition for SPI in OSPIFBlockDevice driv…
Browse files Browse the repository at this point in the history
…er (#291)

* fix ambiguous SPI enum definition in OSPIFBlockDevice driver

* remove ' ' after * in comment

* remove comment link from SPI reference

* change to class specific doxygen link for SPI dma hint comment

* Fix submodule hash
  • Loading branch information
timIdeaTech authored Jun 24, 2024
1 parent 02623ff commit b5e52f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ enum ospif_bd_error {
OSPIF_BD_ERROR_DEVICE_MAX_EXCEED = -4007 /* Max active OSPIF devices exceeded */
};

enum _mode {
SPI,
SOPI,
DOPI
/** Enum ospif opi modes
*
* @enum ospif_opi_mode
*/
enum ospif_opi_mode {
OSPIF_OPI_MODE_SPI = 0, /* SPI mode (OPI modes disabled)*/
OSPIF_OPI_MODE_SOPI, /* STR-OPI mode */
OSPIF_OPI_MODE_DOPI /* DTR-OPI mode */
};

/** Enum ospif polarity mode
Expand Down
16 changes: 8 additions & 8 deletions storage/blockdevice/COMPONENT_OSPIF/source/OSPIFBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ int OSPIFBlockDevice::deinit()
_wait_flag = NOT_STARTED;
#endif

change_mode(SPI);
change_mode(OSPIF_OPI_MODE_SPI);

// Disable Device for Writing
ospi_status_t status = _ospi_send_general_command(OSPIF_INST_WRDI, OSPI_NO_ADDRESS_COMMAND, NULL, 0, NULL, 0);
Expand Down Expand Up @@ -723,13 +723,13 @@ int OSPIFBlockDevice::change_mode(int mode)
int status = OSPIF_BD_ERROR_OK;
char config_reg2 = 0;

if (((mode == SPI) && (_read_instruction == OSPIF_INST_READ_4B)) ||
((mode == SOPI) && (_read_instruction == DTROSPIF_INST_READ_OCTA_STR)) ||
((mode == DOPI) && (_read_instruction == DTROSPIF_INST_READ_OCTA_DTR))) {
if (((mode == OSPIF_OPI_MODE_SPI) && (_read_instruction == OSPIF_INST_READ_4B)) ||
((mode == OSPIF_OPI_MODE_SOPI) && (_read_instruction == DTROSPIF_INST_READ_OCTA_STR)) ||
((mode == OSPIF_OPI_MODE_DOPI) && (_read_instruction == DTROSPIF_INST_READ_OCTA_DTR))) {
tr_debug("Flash does not need change mode");
}

if (mode == SOPI) {
if (mode == OSPIF_OPI_MODE_SOPI) {
if ((_read_instruction != OSPIF_INST_READ_4B) && (_read_instruction != OSPIF_INST_READ_DEFAULT)) { //change mode from DOPI to SPI
// Write new Status Register Setup
if (_set_write_enable() != 0) {
Expand Down Expand Up @@ -781,7 +781,7 @@ int OSPIFBlockDevice::change_mode(int mode)

_ospi.configure_format(_inst_width, _inst_size, _address_width, _address_size, OSPI_CFG_BUS_SINGLE,
0, _data_width, 0);
} else if (mode == DOPI) {
} else if (mode == OSPIF_OPI_MODE_DOPI) {
if ((_read_instruction != OSPIF_INST_READ_4B) && (_read_instruction != OSPIF_INST_READ_DEFAULT)) {//chang mode from SOPI to SPI
// Write new Status Register Setup
if (_set_write_enable() != 0) {
Expand Down Expand Up @@ -833,7 +833,7 @@ int OSPIFBlockDevice::change_mode(int mode)

_ospi.configure_format(_inst_width, _inst_size, _address_width, _address_size, OSPI_CFG_BUS_SINGLE,
0, _data_width, 0);
} else if (mode == SPI) {
} else if (mode == OSPIF_OPI_MODE_SPI) {
// Write new Status Register Setup
if (_set_write_enable() != 0) {
tr_error("Write Enabe failed");
Expand Down Expand Up @@ -996,7 +996,7 @@ int OSPIFBlockDevice::_sfdp_parse_basic_param_table(Callback<int(bd_addr_t, mbed
// Detect and Set fastest Bus mode (default 1-1-1)
_sfdp_detect_best_bus_read_mode(param_table, sfdp_info.bptbl.size, shouldSetQuadEnable, is_qpi_mode, is_opi_mode);
if (true == is_opi_mode) {
change_mode(DOPI);
change_mode(OSPIF_OPI_MODE_DOPI);
tr_debug("Init - Setting DOPI mode");
}
if (true == shouldSetQuadEnable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class SDBlockDevice : public mbed::BlockDevice {
* in the background while data is going to and from the card.
*
* @param enabled Whether usage of async %SPI is enabled.
* @param dma_usage_hint DMA usage hint to pass to the underlying #SPI instance.
* @param dma_usage_hint DMA usage hint to pass to the underlying #mbed::SPI instance.
*/
void set_async_spi_mode(bool enabled, DMAUsage dma_usage_hint = DMAUsage::DMA_USAGE_NEVER);
#endif
Expand Down

0 comments on commit b5e52f0

Please sign in to comment.