Remove anyfmt
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
use anyfmt::{panic, *};
|
||||
use core::cell::Cell;
|
||||
use core::future::Future;
|
||||
use core::ptr;
|
||||
use core::task::{Context, Poll};
|
||||
use defmt::{panic, *};
|
||||
use embassy::util::Signal;
|
||||
|
||||
use crate::hal::gpio::{Input, Level, Output, Pin, Port};
|
||||
@ -51,8 +51,7 @@ pub enum OutputChannelPolarity {
|
||||
Toggle,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, defmt::Format)]
|
||||
pub enum NewChannelError {
|
||||
NoFreeChannels,
|
||||
}
|
||||
|
@ -10,10 +10,9 @@ use crate::pac::{NVIC, NVIC_PRIO_BITS};
|
||||
// Re-exports
|
||||
pub use crate::pac::Interrupt;
|
||||
pub use crate::pac::Interrupt::*; // needed for cortex-m-rt #[interrupt]
|
||||
pub use bare_metal::{CriticalSection, Mutex};
|
||||
pub use cortex_m::interrupt::{CriticalSection, Mutex};
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, defmt::Format)]
|
||||
#[repr(u8)]
|
||||
pub enum Priority {
|
||||
Level0 = 0,
|
||||
|
@ -1,4 +1,5 @@
|
||||
use core::future::Future;
|
||||
use defmt::{assert, assert_eq, panic, *};
|
||||
|
||||
use crate::hal::gpio::{Output, Pin as GpioPin, Port as GpioPort, PushPull};
|
||||
use crate::pac::{Interrupt, QSPI};
|
||||
@ -32,12 +33,18 @@ pub struct Pins {
|
||||
pub io3: Option<GpioPin<Output<PushPull>>>,
|
||||
}
|
||||
|
||||
pub struct DeepPowerDownConfig {
|
||||
pub enter_time: u16,
|
||||
pub exit_time: u16,
|
||||
}
|
||||
|
||||
pub struct Config {
|
||||
pub pins: Pins,
|
||||
pub xip_offset: u32,
|
||||
pub read_opcode: ReadOpcode,
|
||||
pub write_opcode: WriteOpcode,
|
||||
pub write_page_size: WritePageSize,
|
||||
pub deep_power_down: Option<DeepPowerDownConfig>,
|
||||
}
|
||||
|
||||
pub struct Qspi {
|
||||
@ -96,15 +103,27 @@ impl Qspi {
|
||||
}
|
||||
});
|
||||
|
||||
qspi.ifconfig0.write(|w| {
|
||||
let w = w.addrmode().variant(AddressMode::_24BIT);
|
||||
let w = w.dpmenable().disable();
|
||||
let w = w.ppsize().variant(config.write_page_size);
|
||||
let w = w.readoc().variant(config.read_opcode);
|
||||
let w = w.writeoc().variant(config.write_opcode);
|
||||
qspi.ifconfig0.write(|mut w| {
|
||||
w = w.addrmode().variant(AddressMode::_24BIT);
|
||||
if config.deep_power_down.is_some() {
|
||||
w = w.dpmenable().enable();
|
||||
} else {
|
||||
w = w.dpmenable().disable();
|
||||
}
|
||||
w = w.ppsize().variant(config.write_page_size);
|
||||
w = w.readoc().variant(config.read_opcode);
|
||||
w = w.writeoc().variant(config.write_opcode);
|
||||
w
|
||||
});
|
||||
|
||||
if let Some(dpd) = &config.deep_power_down {
|
||||
qspi.dpmdur.write(|mut w| unsafe {
|
||||
w = w.enter().bits(dpd.enter_time);
|
||||
w = w.exit().bits(dpd.exit_time);
|
||||
w
|
||||
})
|
||||
}
|
||||
|
||||
qspi.ifconfig1.write(|w| {
|
||||
let w = unsafe { w.sckdelay().bits(80) };
|
||||
let w = w.dpmen().exit();
|
||||
@ -125,13 +144,28 @@ impl Qspi {
|
||||
qspi.events_ready.reset();
|
||||
|
||||
// Enable READY interrupt
|
||||
SIGNAL.reset();
|
||||
qspi.intenset.write(|w| w.ready().set());
|
||||
interrupt::set_priority(Interrupt::QSPI, interrupt::Priority::Level7);
|
||||
interrupt::unpend(Interrupt::QSPI);
|
||||
interrupt::enable(Interrupt::QSPI);
|
||||
|
||||
Self { inner: qspi }
|
||||
}
|
||||
|
||||
pub fn sleep(&mut self) {
|
||||
info!("flash: sleeping");
|
||||
info!("flash: state = {:?}", self.inner.status.read().bits());
|
||||
self.inner.ifconfig1.modify(|r, w| w.dpmen().enter());
|
||||
info!("flash: state = {:?}", self.inner.status.read().bits());
|
||||
cortex_m::asm::delay(1000000);
|
||||
info!("flash: state = {:?}", self.inner.status.read().bits());
|
||||
|
||||
self.inner
|
||||
.tasks_deactivate
|
||||
.write(|w| w.tasks_deactivate().set_bit());
|
||||
}
|
||||
|
||||
pub fn custom_instruction<'a>(
|
||||
&'a mut self,
|
||||
opcode: u8,
|
||||
@ -318,6 +352,7 @@ unsafe fn QSPI() {
|
||||
let p = crate::pac::Peripherals::steal().QSPI;
|
||||
if p.events_ready.read().events_ready().bit_is_set() {
|
||||
p.events_ready.reset();
|
||||
info!("qspi ready");
|
||||
SIGNAL.signal(());
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub use uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity};
|
||||
use embassy::io::{AsyncBufRead, AsyncWrite, Result};
|
||||
use embassy::util::WakerStore;
|
||||
|
||||
use anyfmt::{assert, panic, *};
|
||||
use defmt::{assert, panic, todo, *};
|
||||
|
||||
//use crate::trace;
|
||||
|
||||
|
Reference in New Issue
Block a user