Skip to content

Commit 7266070

Browse files
committed
Modify the astyle
1 parent be13afb commit 7266070

File tree

5 files changed

+41
-45
lines changed

5 files changed

+41
-45
lines changed

TESTS/mbed_hal/ospi/ospi_test_utils.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,14 @@ void OspiCommand::build(int instruction, int address, int alt)
8383
_cmd.address.disabled = 0;
8484
_cmd.address.value = 0;
8585
_cmd.dummy_count = 4;
86-
}
87-
else if (instruction == OSPI_CMD_RDCR2) {
86+
} else if (instruction == OSPI_CMD_RDCR2) {
8887
_cmd.dummy_count = 4;
89-
}
90-
else if ((instruction == OSPI_CMD_READ_OPI) || (instruction == OSPI_CMD_READ_DOPI)) {
91-
_cmd.dummy_count = 20;
92-
}
93-
else
88+
} else if ((instruction == OSPI_CMD_READ_OPI) || (instruction == OSPI_CMD_READ_DOPI)) {
89+
_cmd.dummy_count = 20;
90+
}
91+
else {
9492
_cmd.dummy_count = 0;
93+
}
9594
}
9695
}
9796

components/storage/blockdevice/COMPONENT_OSPIF/OSPIFBlockDevice.cpp

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ int OSPIFBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
394394
_mutex.lock();
395395

396396
if (size % 2 != 0) {
397-
size ++;
397+
size ++;
398398
}
399399

400400
if (OSPI_STATUS_OK != _ospi_send_read_command(_read_instruction, buffer, addr, size)) {
@@ -501,7 +501,7 @@ int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
501501
region,
502502
_sfdp_info.smptbl);
503503
//cur_erase_inst should be 4-Byte erase instruction for Macronix octa flash OPI mode
504-
cur_erase_inst = (_address_size == OSPI_CFG_ADDR_SIZE_32 ) ? _sfdp_info.fbatbl.erase_type_4_byte_inst_arr[type] : _sfdp_info.smptbl.erase_type_inst_arr[type];
504+
cur_erase_inst = (_address_size == OSPI_CFG_ADDR_SIZE_32) ? _sfdp_info.fbatbl.erase_type_4_byte_inst_arr[type] : _sfdp_info.smptbl.erase_type_inst_arr[type];
505505
eu_size = _sfdp_info.smptbl.erase_type_size_arr[type];
506506
} else {
507507
// Must use legacy 4k erase instruction
@@ -634,9 +634,8 @@ int OSPIFBlockDevice::change_mode(int mode)
634634
char config_reg2 = 0;
635635

636636
if (((mode == SPI) && (_read_instruction == OSPIF_INST_READ_4B)) ||
637-
((mode == SOPI) && (_read_instruction == DTROSPIF_INST_READ_OCTA_STR)) ||
638-
((mode == DOPI) && (_read_instruction == DTROSPIF_INST_READ_OCTA_DTR))) {
639-
637+
((mode == SOPI) && (_read_instruction == DTROSPIF_INST_READ_OCTA_STR)) ||
638+
((mode == DOPI) && (_read_instruction == DTROSPIF_INST_READ_OCTA_DTR))) {
640639
tr_debug("Flash does not need change mode");
641640
}
642641

@@ -665,7 +664,7 @@ int OSPIFBlockDevice::change_mode(int mode)
665664

666665
_ospi.configure_format(OSPI_CFG_BUS_SINGLE, OSPI_CFG_INST_SIZE_8, OSPI_CFG_BUS_SINGLE, OSPI_CFG_ADDR_SIZE_32,
667666
OSPI_CFG_BUS_SINGLE, 0, OSPI_CFG_BUS_SINGLE, 0);
668-
// Write new Status Register Setup
667+
// Write new Status Register Setup
669668
if (_set_write_enable() != 0) {
670669
tr_error("Write Enabe failed");
671670
return -1;
@@ -692,10 +691,9 @@ int OSPIFBlockDevice::change_mode(int mode)
692691

693692
_ospi.configure_format(_inst_width, _inst_size, _address_width, _address_size, OSPI_CFG_BUS_SINGLE,
694693
0, _data_width, 0);
695-
}
696-
else if (mode == DOPI) {
694+
} else if (mode == DOPI) {
697695
if ((_read_instruction != OSPIF_INST_READ_4B) && (_read_instruction != OSPIF_INST_READ_DEFAULT)) {//chang mode from SOPI to SPI
698-
// Write new Status Register Setup
696+
// Write new Status Register Setup
699697
if (_set_write_enable() != 0) {
700698
tr_error("Write Enabe failed");
701699
return -1;
@@ -718,7 +716,7 @@ int OSPIFBlockDevice::change_mode(int mode)
718716

719717
_ospi.configure_format(OSPI_CFG_BUS_SINGLE, OSPI_CFG_INST_SIZE_8, OSPI_CFG_BUS_SINGLE, OSPI_CFG_ADDR_SIZE_32,
720718
OSPI_CFG_BUS_SINGLE, 0, OSPI_CFG_BUS_SINGLE, 0);
721-
// Write new Status Register Setup
719+
// Write new Status Register Setup
722720
if (_set_write_enable() != 0) {
723721
tr_error("Write Enabe failed");
724722
return -1;
@@ -745,9 +743,8 @@ int OSPIFBlockDevice::change_mode(int mode)
745743

746744
_ospi.configure_format(_inst_width, _inst_size, _address_width, _address_size, OSPI_CFG_BUS_SINGLE,
747745
0, _data_width, 0);
748-
}
749-
else if (mode == SPI) {
750-
// Write new Status Register Setup
746+
} else if (mode == SPI) {
747+
// Write new Status Register Setup
751748
if (_set_write_enable() != 0) {
752749
tr_error("Write Enabe failed");
753750
return -1;
@@ -1070,7 +1067,7 @@ int OSPIFBlockDevice::_sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table
10701067
// read_inst = basic_param_table_ptr[OSPIF_BASIC_PARAM_TABLE_888_READ_INST_BYTE];
10711068
is_opi_mode = true;
10721069
_dummy_cycles = (basic_param_table_ptr[OSPIF_BASIC_PARAM_TABLE_888_READ_INST_BYTE - 1] >> 5)
1073-
+ (basic_param_table_ptr[OSPIF_BASIC_PARAM_TABLE_888_READ_INST_BYTE - 1] & 0x1F);
1070+
+ (basic_param_table_ptr[OSPIF_BASIC_PARAM_TABLE_888_READ_INST_BYTE - 1] & 0x1F);
10741071
tr_debug("Read Bus Mode set to 8-8-8, Instruction: 0x%xh", _read_instruction);
10751072
// _inst_width = OSPI_CFG_BUS_OCTA;
10761073
// _inst_size = OSPI_CFG_INST_SIZE_16;
@@ -1239,7 +1236,7 @@ int OSPIFBlockDevice::_sfdp_detect_and_enable_4byte_addressing(uint8_t *basic_pa
12391236
switch (_read_instruction) {
12401237
case OSPIF_INST_READ_DEFAULT:
12411238
_read_instruction = OSPIF_INST_READ_4B;
1242-
break;
1239+
break;
12431240
case 0xc2:
12441241
break;
12451242
}
@@ -1321,7 +1318,7 @@ int OSPIFBlockDevice::_sfdp_parse_4_byte_inst_table(Callback<int(bd_addr_t, void
13211318
for (int i_ind = 0; i_ind < 4; i_ind++) {
13221319
sfdp_info.fbatbl.erase_type_4_byte_inst_arr[i_ind] = OSPI_NO_INST; // Default for unsupported type
13231320
if (four_byte_inst_table[OSPIF_4_BYTE_INST_TABLE_ERASE_SUPPORT_BYTE] & (FOURBYTE_INST_ERASE_TYPE_1_BITMASK << i_ind)) {
1324-
sfdp_info.fbatbl.erase_type_4_byte_inst_arr[i_ind] = four_byte_inst_table[OSPIF_4_BYTE_INST_TABLE_INST_ERASE_TYPE_1_BYTE + i_ind];
1321+
sfdp_info.fbatbl.erase_type_4_byte_inst_arr[i_ind] = four_byte_inst_table[OSPIF_4_BYTE_INST_TABLE_INST_ERASE_TYPE_1_BYTE + i_ind];
13251322
}
13261323
tr_debug("Erase Type %d - Inst: 0x%xh", (i_ind + 1), sfdp_info.fbatbl.erase_type_4_byte_inst_arr[i_ind]);
13271324
}
@@ -1739,14 +1736,13 @@ ospi_status_t OSPIFBlockDevice::_ospi_send_general_command(ospi_inst_t instructi
17391736
return status;
17401737
}
17411738

1742-
if ((_inst_width == OSPI_CFG_BUS_OCTA ) || (_inst_width == OSPI_CFG_BUS_OCTA_DTR )){
1739+
if ((_inst_width == OSPI_CFG_BUS_OCTA) || (_inst_width == OSPI_CFG_BUS_OCTA_DTR)){
17431740
if ((instruction == OSPIF_INST_RSR1) || (instruction == OSPIF_INST_RDID) ||
1744-
(instruction == OSPIF_INST_RDCR2) || (instruction == OSPIF_INST_RDCR)) {
1745-
_ospi.configure_format(_inst_width, _inst_size, _address_width, _address_size, OSPI_CFG_BUS_SINGLE,
1741+
(instruction == OSPIF_INST_RDCR2) || (instruction == OSPIF_INST_RDCR)) {
1742+
_ospi.configure_format(_inst_width, _inst_size, _address_width, _address_size, OSPI_CFG_BUS_SINGLE,
17461743
0, _data_width, 4);
17471744
addr = 0;
1748-
}
1749-
else if ((instruction == OSPIF_INST_WSR1) ) {
1745+
} else if ((instruction == OSPIF_INST_WSR1)) {
17501746
addr = 0;
17511747
}
17521748
}
@@ -1758,9 +1754,9 @@ ospi_status_t OSPIFBlockDevice::_ospi_send_general_command(ospi_inst_t instructi
17581754
return status;
17591755
}
17601756

1761-
if (((_inst_width == OSPI_CFG_BUS_OCTA) || (_inst_width == OSPI_CFG_BUS_OCTA_DTR )) &&
1762-
((instruction == OSPIF_INST_RSR1) || (instruction == OSPIF_INST_RDID) ||
1763-
(instruction == OSPIF_INST_RDCR2) || (instruction == OSPIF_INST_RDCR))) {
1757+
if (((_inst_width == OSPI_CFG_BUS_OCTA) || (_inst_width == OSPI_CFG_BUS_OCTA_DTR)) &&
1758+
((instruction == OSPIF_INST_RSR1) || (instruction == OSPIF_INST_RDID) ||
1759+
(instruction == OSPIF_INST_RDCR2) || (instruction == OSPIF_INST_RDCR))) {
17641760
_ospi.configure_format(_inst_width, _inst_size, _address_width, _address_size, OSPI_CFG_BUS_SINGLE,
17651761
0, _data_width, 0);
17661762
}
@@ -1775,16 +1771,17 @@ int OSPIFBlockDevice::_ospi_send_read_sfdp_command(bd_addr_t addr, void *rx_buff
17751771

17761772
if (_need_define_sfdp_para) {
17771773
if (addr < 30) {
1778-
for (uint8_t i_ind = 0; i_ind < rx_len; i_ind++)
1774+
for (uint8_t i_ind = 0; i_ind < rx_len; i_ind++) {
17791775
* (rx_buffer_tmp+ i_ind)= _sfdp_head_table[i_ind+addr];
1780-
}
1781-
else if (addr == 0x30) {
1782-
for (uint8_t i_ind = 0; i_ind < rx_len; i_ind++)
1776+
}
1777+
} else if (addr == 0x30) {
1778+
for (uint8_t i_ind = 0; i_ind < rx_len; i_ind++) {
17831779
*(rx_buffer_tmp+ i_ind) = _sfdp_basic_param_table[i_ind];
1784-
}
1785-
else if (addr == 0xc0) {
1786-
for (uint8_t i_ind = 0; i_ind < rx_len; i_ind++)
1780+
}
1781+
} else if (addr == 0xc0) {
1782+
for (uint8_t i_ind = 0; i_ind < rx_len; i_ind++) {
17871783
*(rx_buffer_tmp+ i_ind) = _sfdp_4_byte_inst_table[i_ind];
1784+
}
17881785
}
17891786
} else {
17901787
// SFDP read instruction requires 1-1-1 bus mode with 8 dummy cycles and a 3-byte address
@@ -1860,7 +1857,7 @@ ospi_status_t OSPIFBlockDevice::_ospi_write_status_registers(uint8_t *reg_buffer
18601857
status = _ospi_send_general_command(OSPIF_INST_WSR1, OSPI_NO_ADDRESS_COMMAND,
18611858
(char *) reg_buffer, 1,
18621859
NULL, 0);
1863-
//for octa flash DOPI mode, WRSR just write 1 byte, but the byte number need to even because of protocol
1860+
//for octa flash DOPI mode, WRSR just write 1 byte, but the byte number need to even because of protocol
18641861
} else if (_read_instruction == DTROSPIF_INST_READ_OCTA_DTR) {
18651862
status = _ospi_send_general_command(OSPIF_INST_WSR1, OSPI_NO_ADDRESS_COMMAND,
18661863
(char *) reg_buffer, 2,

drivers/OSPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ typedef int ospi_inst_t;
4747

4848
/** A OSPI Driver, used for communicating with OSPI slave devices
4949
*
50-
* The default format is set to Octo-SPI(1-1-1), and a clock frequency of 1MHz
50+
* The default format is set to OCTO-SPI(1-1-1), and a clock frequency of 1MHz
5151
* Most OSPI devices will also require Chip Select which is indicated by ssel.
5252
*
5353
* @note Synchronization level: Thread safe
@@ -139,7 +139,7 @@ class OSPI : private NonCopyable<OSPI> {
139139
*
140140
*/
141141
ospi_status_t configure_format(ospi_bus_width_t inst_width,
142-
ospi_inst_size_t inst_size,
142+
ospi_inst_size_t inst_size,
143143
ospi_bus_width_t address_width,
144144
ospi_address_size_t address_size,
145145
ospi_bus_width_t alt_width,

drivers/source/OSPI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ OSPI::OSPI(const ospi_pinmap_t &pinmap, int mode) : _ospi()
110110
}
111111

112112
ospi_status_t OSPI::configure_format(ospi_bus_width_t inst_width, ospi_inst_size_t inst_size,
113-
ospi_bus_width_t address_width, ospi_address_size_t address_size,
114-
ospi_bus_width_t alt_width, ospi_alt_size_t alt_size,
115-
ospi_bus_width_t data_width, int dummy_cycles)
113+
ospi_bus_width_t address_width, ospi_address_size_t address_size,
114+
ospi_bus_width_t alt_width, ospi_alt_size_t alt_size,
115+
ospi_bus_width_t data_width, int dummy_cycles)
116116
{
117117
// Check that alt_size/alt_width are a valid combination
118118
uint8_t alt_lines = convert_bus_width_to_line_count(alt_width);

hal/ospi_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ typedef enum ospi_status {
165165
OSPI_STATUS_ERROR otherwise
166166
*/
167167
ospi_status_t ospi_init(ospi_t *obj, PinName io0, PinName io1, PinName io2, PinName io3, PinName io4, PinName io5, PinName io6, PinName io7,
168-
PinName sclk, PinName ssel, PinName dqs, uint32_t hz, uint8_t mode);
168+
PinName sclk, PinName ssel, PinName dqs, uint32_t hz, uint8_t mode);
169169

170170
/** Initialize OSPI peripheral.
171171
*

0 commit comments

Comments
 (0)