@@ -105,43 +105,30 @@ PinName *QSPIFBlockDevice::_active_qspif_flash_csel_arr = generate_initialized_a
105
105
/* ***************************************/
106
106
QSPIFBlockDevice::QSPIFBlockDevice (PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName csel,
107
107
qspif_polarity_mode clock_mode, int freq)
108
- : _qspi(io0, io1, io2, io3, sclk, csel, clock_mode), _csel(csel), _device_size_bytes(0 ), _init_ref_count(0 ),
108
+ : _qspi(io0, io1, io2, io3, sclk, csel, clock_mode), _csel(csel), _freq(freq), _device_size_bytes(0 ),
109
+ _init_ref_count(0 ),
109
110
_is_initialized(false )
110
111
{
111
-
112
112
_unique_device_status = add_new_csel_instance (csel);
113
113
if (_unique_device_status == 0 ) {
114
- _min_common_erase_size = 0 ;
115
- _regions_count = 1 ;
116
- _region_erase_types_bitfield[0 ] = ERASE_BITMASK_NONE;
117
-
118
- // Default Bus Setup 1_1_1 with 0 dummy and mode cycles
119
- _inst_width = QSPI_CFG_BUS_SINGLE;
120
- _address_width = QSPI_CFG_BUS_SINGLE;
121
- _address_size = QSPI_CFG_ADDR_SIZE_24;
122
- _data_width = QSPI_CFG_BUS_SINGLE;
123
- _dummy_and_mode_cycles = 0 ;
124
-
125
- if (QSPI_STATUS_OK != _qspi_set_frequency (freq)) {
126
- tr_error (" ERROR: QSPI Set Frequency Failed" );
127
- }
114
+ tr_info (" INFO: Adding a new QSPIFBlockDevice csel: %d" , (int )csel);
128
115
} else if (_unique_device_status == -1 ) {
129
116
tr_error (" ERROR: QSPIFBlockDevice with the same csel(%d) already exists" , (int )csel);
130
117
} else {
131
118
tr_error (" ERROR: Too many different QSPIFBlockDevice devices - max allowed: %d" , QSPIF_MAX_ACTIVE_FLASH_DEVICES);
132
119
}
133
-
134
120
}
135
121
136
122
int QSPIFBlockDevice::init ()
137
123
{
138
-
139
- if (_unique_device_status == -1 ) {
124
+ if (_unique_device_status == 0 ) {
125
+ tr_debug (" DEBUG: QSPIFBlockDevice csel: %d" , (int )_csel);
126
+ } else if (_unique_device_status == -1 ) {
140
127
tr_error (" ERROR: QSPIFBlockDevice with the same csel(%d) already exists" , (int )_csel);
141
128
return QSPIF_BD_ERROR_DEVICE_NOT_UNIQE;
142
- } else if (_unique_device_status == - 2 ) {
129
+ } else {
143
130
tr_error (" ERROR: Too many different QSPIFBlockDevice devices - max allowed: %d" , QSPIF_MAX_ACTIVE_FLASH_DEVICES);
144
- return QSPIF_BD_ERROR_DEVICE_NOT_UNIQE ;
131
+ return QSPIF_BD_ERROR_DEVICE_MAX_EXCEED ;
145
132
}
146
133
147
134
uint8_t vendor_device_ids[4 ];
@@ -165,6 +152,24 @@ int QSPIFBlockDevice::init()
165
152
goto exit_point;
166
153
}
167
154
155
+ // Initialize parameters
156
+ _min_common_erase_size = 0 ;
157
+ _regions_count = 1 ;
158
+ _region_erase_types_bitfield[0 ] = ERASE_BITMASK_NONE;
159
+
160
+ // Default Bus Setup 1_1_1 with 0 dummy and mode cycles
161
+ _inst_width = QSPI_CFG_BUS_SINGLE;
162
+ _address_width = QSPI_CFG_BUS_SINGLE;
163
+ _address_size = QSPI_CFG_ADDR_SIZE_24;
164
+ _data_width = QSPI_CFG_BUS_SINGLE;
165
+ _dummy_and_mode_cycles = 0 ;
166
+
167
+ if (QSPI_STATUS_OK != _qspi_set_frequency (_freq)) {
168
+ tr_error (" ERROR: QSPI Set Frequency Failed" );
169
+ status = QSPIF_BD_ERROR_DEVICE_ERROR;
170
+ goto exit_point;
171
+ }
172
+
168
173
// Soft Reset
169
174
if ( -1 == _reset_flash_mem ()) {
170
175
tr_error (" ERROR: init - Unable to initialize flash memory, tests failed\n " );
0 commit comments