Skip to content

Commit d0af08c

Browse files
kalkyljamesmunns
authored andcommitted
Return Spis and buffer(s) in transfer & transfer_split Err
1 parent 3ce300c commit d0af08c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

nrf-hal-common/src/spis.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,14 @@ where
323323
/// Buffer must be located in RAM.
324324
/// Returns a value that represents the in-progress DMA transfer.
325325
#[allow(unused_mut)]
326-
pub fn transfer<W, B>(mut self, mut buffer: B) -> Result<Transfer<T, B>, Error>
326+
pub fn transfer<W, B>(mut self, mut buffer: B) -> Result<Transfer<T, B>, (Error, Spis<T>, B)>
327327
where
328328
B: WriteBuffer<Word = W>,
329329
{
330330
let (ptr, len) = unsafe { buffer.write_buffer() };
331331
let maxcnt = len * core::mem::size_of::<W>();
332332
if maxcnt > EASY_DMA_SIZE {
333-
return Err(Error::BufferTooLong);
333+
return Err((Error::BufferTooLong, self, buffer));
334334
}
335335
compiler_fence(Ordering::SeqCst);
336336
self.spis
@@ -366,7 +366,7 @@ where
366366
mut self,
367367
tx_buffer: TxB,
368368
mut rx_buffer: RxB,
369-
) -> Result<TransferSplit<T, TxB, RxB>, Error>
369+
) -> Result<TransferSplit<T, TxB, RxB>, (Error, Spis<T>, TxB, RxB)>
370370
where
371371
TxB: ReadBuffer<Word = TxW>,
372372
RxB: WriteBuffer<Word = RxW>,
@@ -376,10 +376,10 @@ where
376376
let rx_maxcnt = rx_len * core::mem::size_of::<RxW>();
377377
let tx_maxcnt = tx_len * core::mem::size_of::<TxW>();
378378
if rx_maxcnt.max(tx_maxcnt) > EASY_DMA_SIZE {
379-
return Err(Error::BufferTooLong);
379+
return Err((Error::BufferTooLong, self, tx_buffer, rx_buffer));
380380
}
381381
if (tx_ptr as usize) < SRAM_LOWER || (tx_ptr as usize) > SRAM_UPPER {
382-
return Err(Error::DMABufferNotInDataMemory);
382+
return Err((Error::DMABufferNotInDataMemory, self, tx_buffer, rx_buffer));
383383
}
384384
compiler_fence(Ordering::SeqCst);
385385
self.spis

0 commit comments

Comments
 (0)