@@ -158,9 +158,9 @@ impl Qspi {
158
158
} ) ;
159
159
}
160
160
161
- /// Checks for QSPI timeout and transfer bits, and resets the interrupts
162
- /// if all is fine .
163
- fn check_qspi_errors ( & self ) -> Result < ( ) , QspiError > {
161
+ /// Returns the number of valid bytes being held in the FIFO queue if a
162
+ /// QSPI timeout or transfer error hasn't occurred .
163
+ fn get_fifo_level ( & self ) -> Result < usize , QspiError > {
164
164
let sr = self . reg . sr . read ( ) ;
165
165
166
166
// Check timeout bit.
@@ -180,7 +180,7 @@ impl Qspi {
180
180
self . reg
181
181
. cr
182
182
. modify ( |_, w| w. teie ( ) . set_bit ( ) . toie ( ) . set_bit ( ) ) ;
183
- Ok ( ( ) )
183
+ Ok ( usize :: from ( sr . flevel ( ) . bits ( ) ) )
184
184
}
185
185
186
186
/// Wait for the Transfer Complete flag to get set.
@@ -260,10 +260,9 @@ impl Qspi {
260
260
let mut data = data;
261
261
while !data. is_empty ( ) {
262
262
// Check for any errors
263
- self . check_qspi_errors ( ) ?;
263
+ let fl = self . get_fifo_level ( ) ?;
264
264
265
265
// How much space is in the FIFO?
266
- let fl = usize:: from ( sr. flevel ( ) . bits ( ) ) ;
267
266
let ffree = FIFO_SIZE - fl;
268
267
if ffree >= FIFO_THRESH . min ( data. len ( ) ) {
269
268
// Calculate the write size. Note that this may be bigger than
@@ -366,11 +365,10 @@ impl Qspi {
366
365
// perform transfers.
367
366
let mut out = out;
368
367
while !out. is_empty ( ) {
369
- // Check for any errors
370
- self . check_qspi_errors ( ) ?;
368
+ // Get the FIFO level if no errors have occurred.
369
+ let fl = self . get_fifo_level ( ) ?;
371
370
372
371
// Is there enough to read that we want to bother with it?
373
- let fl = usize:: from ( sr. flevel ( ) . bits ( ) ) ;
374
372
if fl < FIFO_THRESH . min ( out. len ( ) ) {
375
373
// Nope! Let's wait for more bytes.
376
374
0 commit comments