Update embedded time

This commit is contained in:
Hmvp 2021-07-26 21:16:09 +02:00 committed by 9names
parent 512172179a
commit bcfbd72ed1
9 changed files with 15 additions and 15 deletions

View file

@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0"
cortex-m = "0.7.2"
rp2040-hal = { path = "../../rp2040-hal", version = "0.1.0" }
cortex-m-rt = { version = "0.6.14", optional = true }
embedded-time = "0.10.1"
embedded-time = "0.12.0"
[dev-dependencies]
panic-halt= "0.2.0"

View file

@ -40,7 +40,7 @@ fn main() -> ! {
.ok()
.unwrap();
let mut delay = cortex_m::delay::Delay::new(core.SYST, *clocks.system_clock.freq().integer());
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer());
let sio = Sio::new(pac.SIO);
let pins = Pins::new(

View file

@ -44,7 +44,7 @@ fn main() -> ! {
.ok()
.unwrap();
let mut delay = cortex_m::delay::Delay::new(core.SYST, *clocks.system_clock.freq().integer());
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer());
let mut pwm_pin = Pwm4::new(25);

View file

@ -12,7 +12,7 @@ license = "MIT OR Apache-2.0"
[dependencies]
cortex-m = "0.7.2"
embedded-hal = { version = "0.2.5", features=["unproven"] }
embedded-time = "0.10"
embedded-time = "0.12.0"
nb = "1.0"
rp2040-pac = { git = "https://github.com/rp-rs/rp2040-pac", branch="main" }
paste = "1.0"

View file

@ -191,7 +191,7 @@ macro_rules! clock {
let div = if freq.eq(&src_freq) {
1 << 8
} else {
*(shifted_src_freq / *freq.integer() as u64).integer() as u32
(shifted_src_freq / freq.integer() as u64).integer() as u32
};
// If increasing divisor, set divisor before source. Otherwise set source
@ -348,7 +348,7 @@ macro_rules! stoppable_clock {
let div = if freq.eq(&src_freq) {
1 << 8
} else {
*(shifted_src_freq / *freq.integer() as u64).integer() as u32
(shifted_src_freq / freq.integer() as u64).integer() as u32
};
// If increasing divisor, set divisor before source. Otherwise set source
@ -370,7 +370,7 @@ macro_rules! stoppable_clock {
// Note XOSC_COUNT is not helpful here because XOSC is not
// necessarily running, nor is timer... so, 3 cycles per loop:
let sys_freq = 125_000_000; // TODO get actual sys_clk frequency
let delay_cyc = sys_freq / *self.frequency.integer() + 1u32;
let delay_cyc = sys_freq / self.frequency.integer() + 1u32;
cortex_m::asm::delay(delay_cyc);
}

View file

@ -173,10 +173,10 @@ impl<D: PhaseLockedLoopDevice> PhaseLockedLoop<Disabled, D> {
}
let fbdiv = vco_freq
.checked_div(ref_freq_hz.integer())
.checked_div(&ref_freq_hz.integer())
.ok_or(Error::BadArgument)?;
let fbdiv: u16 = (*fbdiv.integer())
let fbdiv: u16 = (fbdiv.integer())
.try_into()
.map_err(|_| Error::BadArgument)?;

View file

@ -85,8 +85,8 @@ impl<D: SpiDevice, const DS: u8> Spi<Disabled, D, DS> {
peri_frequency: F,
baudrate: B,
) -> Hertz {
let freq_in = *peri_frequency.into().integer();
let baudrate = *baudrate.into().integer();
let freq_in = peri_frequency.into().integer();
let baudrate = baudrate.into().integer();
let mut prescale: u8 = u8::MAX;
let mut postdiv: u8 = 1;

View file

@ -371,7 +371,7 @@ fn calculate_baudrate_dividers(
let baudrate_div = frequency
.integer()
.checked_mul(8)
.and_then(|r| r.checked_div(*wanted_baudrate.integer()))
.and_then(|r| r.checked_div(wanted_baudrate.integer()))
.ok_or(Error::BadArgument)?;
Ok(match (baudrate_div >> 7, ((baudrate_div & 0x7F) + 1) / 2) {
@ -408,7 +408,7 @@ fn configure_baudrate(
device.uartlcr_h.modify(|_, w| w);
Ok(Baud(
(4 * *frequency.integer()) / (64 * baud_div_int + baud_div_frac) as u32,
(4 * frequency.integer()) / (64 * baud_div_int + baud_div_frac) as u32,
))
}

View file

@ -113,12 +113,12 @@ impl CrystalOscillator<Disabled> {
//See Chapter 2, Section 16, §3)
//We do the calculation first.
let startup_delay = frequency
.checked_div(delay_to_hz.integer())
.checked_div(&delay_to_hz.integer())
.and_then(|r| r.to_generic::<u32>(DIVIDER).ok())
.ok_or(Error::BadArgument)?;
//Then we check if it fits into an u16.
let startup_delay: u16 = (*startup_delay.integer())
let startup_delay: u16 = (startup_delay.integer())
.try_into()
.map_err(|_| Error::BadArgument)?;