Merge pull request #2245 from peter9477/nrf52-qspi-zerolen-fix
nrf52/qspi: avoid infinite busy-wait read/write with zero-len buf
This commit is contained in:
commit
521cdef8a1
20
embassy-nrf/src/qspi.rs
Normal file → Executable file
20
embassy-nrf/src/qspi.rs
Normal file → Executable file
@ -393,6 +393,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 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