Merge pull request #34 from mattiasgronlund/wlan_read_fix

Fixed length for wlan_read.
This commit is contained in:
Dario Nieuwenhuis 2023-01-02 00:26:37 +01:00 committed by GitHub
commit 072b8ce035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -48,11 +48,12 @@ where
assert_eq!(val, TEST_PATTERN);
}
pub async fn wlan_read(&mut self, buf: &mut [u32]) {
let cmd = cmd_word(READ, INC_ADDR, FUNC_WLAN, 0, buf.len() as u32 * 4);
pub async fn wlan_read(&mut self, buf: &mut [u32], len_in_u8: u32) {
let cmd = cmd_word(READ, INC_ADDR, FUNC_WLAN, 0, len_in_u8);
let len_in_u32 = (len_in_u8 as usize + 3) / 4;
transaction!(&mut self.spi, |bus| async {
bus.write(&[cmd]).await?;
bus.read(buf).await?;
bus.read(&mut buf[..len_in_u32]).await?;
Ok(())
})
.await

View File

@ -685,7 +685,7 @@ where
if status & STATUS_F2_PKT_AVAILABLE != 0 {
let len = (status & STATUS_F2_PKT_LEN_MASK) >> STATUS_F2_PKT_LEN_SHIFT;
self.bus.wlan_read(&mut buf[..(len as usize + 3) / 4]).await;
self.bus.wlan_read(&mut buf, len).await;
trace!("rx {:02x}", &slice8_mut(&mut buf)[..(len as usize).min(48)]);
self.rx(&slice8_mut(&mut buf)[..len as usize]);
}