nrf52/qspi: avoid infinite busy-wait on QSPI read/write with zero-len buffer, fixes #2115
This commit is contained in:
parent
9ba3aeada4
commit
9fb2eb7470
22
embassy-nrf/src/qspi.rs
Normal file → Executable file
22
embassy-nrf/src/qspi.rs
Normal file → Executable file
@ -391,8 +391,13 @@ impl<'d, T: Instance> Qspi<'d, T> {
|
|||||||
///
|
///
|
||||||
/// The difference with `read` is that this does not do bounds checks
|
/// The difference with `read` is that this does not do bounds checks
|
||||||
/// against the flash capacity. It is intended for use when QSPI is used as
|
/// against the flash capacity. It is intended for use when QSPI is used as
|
||||||
/// a raw bus, not with flash memory.
|
/// a raw bus, not with flash memory.
|
||||||
pub async fn read_raw(&mut self, address: u32, data: &mut [u8]) -> Result<(), Error> {
|
pub async fn read_raw(&mut self, address: u32, data: &mut [u8]) -> Result<(), Error> {
|
||||||
|
// Avoid blocking_wait_ready() blocking forever on zero-length buffers.
|
||||||
|
if data.len() == 0 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let ondrop = OnDrop::new(Self::blocking_wait_ready);
|
let ondrop = OnDrop::new(Self::blocking_wait_ready);
|
||||||
|
|
||||||
self.start_read(address, data)?;
|
self.start_read(address, data)?;
|
||||||
@ -409,6 +414,11 @@ impl<'d, T: Instance> Qspi<'d, T> {
|
|||||||
/// against the flash capacity. It is intended for use when QSPI is used as
|
/// against the flash capacity. It is intended for use when QSPI is used as
|
||||||
/// a raw bus, not with flash memory.
|
/// a raw bus, not with flash memory.
|
||||||
pub async fn write_raw(&mut self, address: u32, data: &[u8]) -> Result<(), Error> {
|
pub async fn write_raw(&mut self, address: u32, data: &[u8]) -> Result<(), Error> {
|
||||||
|
// Avoid blocking_wait_ready() blocking forever on zero-length buffers.
|
||||||
|
if data.len() == 0 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let ondrop = OnDrop::new(Self::blocking_wait_ready);
|
let ondrop = OnDrop::new(Self::blocking_wait_ready);
|
||||||
|
|
||||||
self.start_write(address, data)?;
|
self.start_write(address, data)?;
|
||||||
@ -425,6 +435,11 @@ impl<'d, T: Instance> Qspi<'d, T> {
|
|||||||
/// against the flash capacity. It is intended for use when QSPI is used as
|
/// against the flash capacity. It is intended for use when QSPI is used as
|
||||||
/// a raw bus, not with flash memory.
|
/// a raw bus, not with flash memory.
|
||||||
pub fn blocking_read_raw(&mut self, address: u32, data: &mut [u8]) -> Result<(), Error> {
|
pub fn blocking_read_raw(&mut self, address: u32, data: &mut [u8]) -> Result<(), Error> {
|
||||||
|
// Avoid blocking_wait_ready() blocking forever on zero-length buffers.
|
||||||
|
if data.len() == 0 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.start_read(address, data)?;
|
self.start_read(address, data)?;
|
||||||
Self::blocking_wait_ready();
|
Self::blocking_wait_ready();
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -436,6 +451,11 @@ impl<'d, T: Instance> Qspi<'d, T> {
|
|||||||
/// against the flash capacity. It is intended for use when QSPI is used as
|
/// against the flash capacity. It is intended for use when QSPI is used as
|
||||||
/// a raw bus, not with flash memory.
|
/// a raw bus, not with flash memory.
|
||||||
pub fn blocking_write_raw(&mut self, address: u32, data: &[u8]) -> Result<(), Error> {
|
pub fn blocking_write_raw(&mut self, address: u32, data: &[u8]) -> Result<(), Error> {
|
||||||
|
// Avoid blocking_wait_ready() blocking forever on zero-length buffers.
|
||||||
|
if data.len() == 0 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.start_write(address, data)?;
|
self.start_write(address, data)?;
|
||||||
Self::blocking_wait_ready();
|
Self::blocking_wait_ready();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user