Run rustfmt.
This commit is contained in:
@ -20,10 +20,7 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error
|
||||
let mut ret: Result<(), Error> = Ok(());
|
||||
let mut offset = offset;
|
||||
for chunk in buf.chunks(2) {
|
||||
write_volatile(
|
||||
offset as *mut u16,
|
||||
u16::from_le_bytes(chunk[0..2].try_into().unwrap()),
|
||||
);
|
||||
write_volatile(offset as *mut u16, u16::from_le_bytes(chunk[0..2].try_into().unwrap()));
|
||||
offset += chunk.len() as u32;
|
||||
|
||||
ret = blocking_wait_ready();
|
||||
|
@ -26,10 +26,7 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error
|
||||
let mut offset = offset;
|
||||
for chunk in buf.chunks(super::WRITE_SIZE) {
|
||||
for val in chunk.chunks(4) {
|
||||
write_volatile(
|
||||
offset as *mut u32,
|
||||
u32::from_le_bytes(val[0..4].try_into().unwrap()),
|
||||
);
|
||||
write_volatile(offset as *mut u32, u32::from_le_bytes(val[0..4].try_into().unwrap()));
|
||||
offset += val.len() as u32;
|
||||
|
||||
// prevents parallelism errors
|
||||
|
@ -28,8 +28,7 @@ pub(crate) unsafe fn unlock() {
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error> {
|
||||
let bank = if !is_dual_bank() || (offset - super::FLASH_BASE as u32) < SECOND_BANK_OFFSET as u32
|
||||
{
|
||||
let bank = if !is_dual_bank() || (offset - super::FLASH_BASE as u32) < SECOND_BANK_OFFSET as u32 {
|
||||
pac::FLASH.bank(0)
|
||||
} else {
|
||||
pac::FLASH.bank(1)
|
||||
@ -46,10 +45,7 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error
|
||||
'outer: for chunk in buf.chunks(super::WRITE_SIZE) {
|
||||
for val in chunk.chunks(4) {
|
||||
trace!("Writing at {:x}", offset);
|
||||
write_volatile(
|
||||
offset as *mut u32,
|
||||
u32::from_le_bytes(val[0..4].try_into().unwrap()),
|
||||
);
|
||||
write_volatile(offset as *mut u32, u32::from_le_bytes(val[0..4].try_into().unwrap()));
|
||||
offset += val.len() as u32;
|
||||
|
||||
ret = blocking_wait_ready(bank);
|
||||
|
@ -42,10 +42,7 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error
|
||||
let mut offset = offset;
|
||||
for chunk in buf.chunks(super::WRITE_SIZE) {
|
||||
for val in chunk.chunks(4) {
|
||||
write_volatile(
|
||||
offset as *mut u32,
|
||||
u32::from_le_bytes(val[0..4].try_into().unwrap()),
|
||||
);
|
||||
write_volatile(offset as *mut u32, u32::from_le_bytes(val[0..4].try_into().unwrap()));
|
||||
offset += val.len() as u32;
|
||||
}
|
||||
|
||||
@ -80,11 +77,7 @@ pub(crate) unsafe fn blocking_erase(from: u32, to: u32) -> Result<(), Error> {
|
||||
let idx = (page - super::FLASH_BASE as u32) / super::ERASE_SIZE as u32;
|
||||
|
||||
#[cfg(flash_l4)]
|
||||
let (idx, bank) = if idx > 255 {
|
||||
(idx - 256, true)
|
||||
} else {
|
||||
(idx, false)
|
||||
};
|
||||
let (idx, bank) = if idx > 255 { (idx - 256, true) } else { (idx, false) };
|
||||
|
||||
pac::FLASH.cr().modify(|w| {
|
||||
w.set_per(true);
|
||||
|
@ -1,17 +1,11 @@
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use embassy_hal_common::unborrow;
|
||||
use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash};
|
||||
|
||||
pub use crate::pac::{ERASE_SIZE, ERASE_VALUE, FLASH_BASE, FLASH_SIZE, WRITE_SIZE};
|
||||
use crate::peripherals::FLASH;
|
||||
use crate::Unborrow;
|
||||
use core::marker::PhantomData;
|
||||
use embassy_hal_common::unborrow;
|
||||
|
||||
use embedded_storage::nor_flash::{
|
||||
ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash,
|
||||
};
|
||||
|
||||
pub use crate::pac::ERASE_SIZE;
|
||||
pub use crate::pac::ERASE_VALUE;
|
||||
pub use crate::pac::FLASH_BASE;
|
||||
pub use crate::pac::FLASH_SIZE;
|
||||
pub use crate::pac::WRITE_SIZE;
|
||||
const FLASH_END: usize = FLASH_BASE + FLASH_SIZE;
|
||||
|
||||
#[cfg_attr(any(flash_wl, flash_wb, flash_l0, flash_l1, flash_l4), path = "l.rs")]
|
||||
|
Reference in New Issue
Block a user