Skip to content

Commit 973aceb

Browse files
adustmmaciejbocianski
authored andcommitted
Revert "Dummy cycles count is not an init parameter, but a command parameter."
This reverts commit f1ad089.
1 parent d7f3e70 commit 973aceb

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

drivers/QSPI.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ QSPI::QSPI(PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, Pin
3939
_alt_width = QSPI_CFG_BUS_SINGLE;
4040
_alt_size = QSPI_CFG_ALT_SIZE_8;
4141
_data_width = QSPI_CFG_BUS_SINGLE;
42+
_num_dummy_cycles = 0;
4243
_mode = mode;
4344
_hz = ONE_MHZ;
4445
_initialized = false;
@@ -58,6 +59,7 @@ qspi_status_t QSPI::configure_format(qspi_bus_width_t inst_width, qspi_bus_width
5859
_alt_width = alt_width;
5960
_alt_size = alt_size;
6061
_data_width = data_width;
62+
_num_dummy_cycles = dummy_cycles;
6163

6264
unlock();
6365

@@ -97,7 +99,7 @@ qspi_status_t QSPI::read(unsigned int address, char *rx_buffer, size_t *rx_lengt
9799
if (*rx_length != 0) {
98100
lock();
99101
if (true == _acquire()) {
100-
_build_qspi_command(-1, address, -1, 0);
102+
_build_qspi_command(-1, address, -1);
101103
if (QSPI_STATUS_OK == qspi_read(&_qspi, &_qspi_command, rx_buffer, rx_length)) {
102104
ret_status = QSPI_STATUS_OK;
103105
}
@@ -121,7 +123,7 @@ qspi_status_t QSPI::write(unsigned int address, const char *tx_buffer, size_t *t
121123
if (*tx_length != 0) {
122124
lock();
123125
if (true == _acquire()) {
124-
_build_qspi_command(-1, address, -1, 0);
126+
_build_qspi_command(-1, address, -1);
125127
if (QSPI_STATUS_OK == qspi_write(&_qspi, &_qspi_command, tx_buffer, tx_length)) {
126128
ret_status = QSPI_STATUS_OK;
127129
}
@@ -136,7 +138,7 @@ qspi_status_t QSPI::write(unsigned int address, const char *tx_buffer, size_t *t
136138
return ret_status;
137139
}
138140

139-
qspi_status_t QSPI::read(unsigned int instruction, unsigned int alt, unsigned int dummy_cnt, unsigned int address, char *rx_buffer, size_t *rx_length)
141+
qspi_status_t QSPI::read(unsigned int instruction, unsigned int alt, unsigned int address, char *rx_buffer, size_t *rx_length)
140142
{
141143
qspi_status_t ret_status = QSPI_STATUS_ERROR;
142144

@@ -145,7 +147,7 @@ qspi_status_t QSPI::read(unsigned int instruction, unsigned int alt, unsigned in
145147
if (*rx_length != 0) {
146148
lock();
147149
if ( true == _acquire()) {
148-
_build_qspi_command(instruction, address, alt, dummy_cnt);
150+
_build_qspi_command(instruction, address, alt);
149151
if (QSPI_STATUS_OK == qspi_read(&_qspi, &_qspi_command, rx_buffer, rx_length)) {
150152
ret_status = QSPI_STATUS_OK;
151153
}
@@ -160,7 +162,7 @@ qspi_status_t QSPI::read(unsigned int instruction, unsigned int alt, unsigned in
160162
return ret_status;
161163
}
162164

163-
qspi_status_t QSPI::write(unsigned int instruction, unsigned int alt, unsigned int dummy_cnt, unsigned int address, const char *tx_buffer, size_t *tx_length)
165+
qspi_status_t QSPI::write(unsigned int instruction, unsigned int alt, unsigned int address, const char *tx_buffer, size_t *tx_length)
164166
{
165167
qspi_status_t ret_status = QSPI_STATUS_ERROR;
166168

@@ -169,7 +171,7 @@ qspi_status_t QSPI::write(unsigned int instruction, unsigned int alt, unsigned i
169171
if (*tx_length != 0) {
170172
lock();
171173
if (true == _acquire()) {
172-
_build_qspi_command(instruction, address, alt, dummy_cnt);
174+
_build_qspi_command(instruction, address, alt);
173175
if (QSPI_STATUS_OK == qspi_write(&_qspi, &_qspi_command, tx_buffer, tx_length)) {
174176
ret_status = QSPI_STATUS_OK;
175177
}
@@ -191,7 +193,7 @@ qspi_status_t QSPI::command_transfer(unsigned int instruction, int address, cons
191193
if (_initialized) {
192194
lock();
193195
if (true == _acquire()) {
194-
_build_qspi_command(instruction, address, -1, 0); //We just need the command
196+
_build_qspi_command(instruction, address, -1); //We just need the command
195197
if (QSPI_STATUS_OK == qspi_command_transfer(&_qspi, &_qspi_command, (const void *)tx_buffer, tx_length, (void *)rx_buffer, rx_length)) {
196198
ret_status = QSPI_STATUS_OK;
197199
}
@@ -240,7 +242,7 @@ bool QSPI::_acquire()
240242
return _initialized;
241243
}
242244

243-
void QSPI::_build_qspi_command(int instruction, int address, int alt, int dummy_cnt)
245+
void QSPI::_build_qspi_command(int instruction, int address, int alt)
244246
{
245247
memset( &_qspi_command, 0, sizeof(qspi_command_t) );
246248
//Set up instruction phase parameters
@@ -272,7 +274,7 @@ void QSPI::_build_qspi_command(int instruction, int address, int alt, int dummy_
272274
_qspi_command.alt.disabled = true;
273275
}
274276

275-
_qspi_command.dummy_count = dummy_cnt;
277+
_qspi_command.dummy_count = _num_dummy_cycles;
276278

277279
//Set up bus width for data phase
278280
_qspi_command.data.bus_width = _data_width;

drivers/QSPI.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,29 +135,27 @@ class QSPI : private NonCopyable<QSPI> {
135135
*
136136
* @param instruction Instruction value to be used in instruction phase
137137
* @param alt Alt value to be used in instruction phase
138-
* @param dummy_cnt Amount of dummy cycles to be sent after instruction phase
139138
* @param address Address to be accessed in QSPI peripheral
140139
* @param rx_buffer Buffer for data to be read from the peripheral
141140
* @param rx_length Pointer to a variable containing the length of rx_buffer, and on return this variable will be updated with the actual number of bytes read
142141
*
143142
* @returns
144143
* Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads.
145144
*/
146-
qspi_status_t read(unsigned int instruction, unsigned int alt, unsigned int dummy_cnt, unsigned int address, char *rx_buffer, size_t *rx_length);
145+
qspi_status_t read(unsigned int instruction, unsigned int alt, unsigned int address, char *rx_buffer, size_t *rx_length);
147146

148147
/** Write to QSPI peripheral using custom write instruction, alt values
149148
*
150149
* @param instruction Instruction value to be used in instruction phase
151150
* @param alt Alt value to be used in instruction phase
152-
* @param dummy_cnt Amount of dummy cycles to be sent after instruction phase
153151
* @param address Address to be accessed in QSPI peripheral
154152
* @param tx_buffer Buffer containing data to be sent to peripheral
155153
* @param tx_length Pointer to a variable containing the length of data to be transmitted, and on return this variable will be updated with the actual number of bytes written
156154
*
157155
* @returns
158156
* Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads.
159157
*/
160-
qspi_status_t write(unsigned int instruction, unsigned int alt, unsigned int dummy_cnt, unsigned int address, const char *tx_buffer, size_t *tx_length);
158+
qspi_status_t write(unsigned int instruction, unsigned int alt, unsigned int address, const char *tx_buffer, size_t *tx_length);
161159

162160
/** Perform a transaction to write to an address(a control register) and get the status results
163161
*
@@ -198,6 +196,7 @@ class QSPI : private NonCopyable<QSPI> {
198196
qspi_alt_size_t _alt_size;
199197
qspi_bus_width_t _data_width; //Bus width for Data phase
200198
qspi_command_t _qspi_command; //QSPI Hal command struct
199+
unsigned int _num_dummy_cycles; //Number of dummy cycles to be used
201200
int _hz; //Bus Frequency
202201
int _mode; //SPI mode
203202
bool _initialized;
@@ -213,7 +212,7 @@ class QSPI : private NonCopyable<QSPI> {
213212
/*
214213
* This function builds the qspi command struct to be send to Hal
215214
*/
216-
inline void _build_qspi_command(int instruction, int address, int alt, int dummy_cnt);
215+
inline void _build_qspi_command(int instruction, int address, int alt);
217216
};
218217

219218
} // namespace mbed

0 commit comments

Comments
 (0)