Merge pull request #68 from timokroeger/update-nrf-hal
Update `nrf-hal` to v0.12.1
This commit is contained in:
commit
f8172316cd
@ -28,5 +28,5 @@ cortex-m = { version = "0.7.1", features = ["inline-asm"] }
|
||||
cortex-m-rt = "0.6.13"
|
||||
embedded-hal = { version = "0.2.4" }
|
||||
panic-probe = "0.1.0"
|
||||
nrf52840-hal = { version = "0.12.0" }
|
||||
nrf52840-hal = { version = "0.12.1" }
|
||||
futures = { version = "0.3.8", default-features = false, features = ["async-await"] }
|
@ -35,8 +35,8 @@ nrf52832-pac = { version = "0.9.0", optional = true }
|
||||
nrf52833-pac = { version = "0.9.0", optional = true }
|
||||
nrf52840-pac = { version = "0.9.0", optional = true }
|
||||
|
||||
nrf52810-hal = { version = "0.12.0", optional = true }
|
||||
#nrf52811-hal = { version = "0.12.0", optional = true } # doesn't exist yet
|
||||
nrf52832-hal = { version = "0.12.0", optional = true }
|
||||
nrf52833-hal = { version = "0.12.0", optional = true }
|
||||
nrf52840-hal = { version = "0.12.0", optional = true }
|
||||
nrf52810-hal = { version = "0.12.1", optional = true }
|
||||
#nrf52811-hal = { version = "0.12.1", optional = true } # doesn't exist yet
|
||||
nrf52832-hal = { version = "0.12.1", optional = true }
|
||||
nrf52833-hal = { version = "0.12.1", optional = true }
|
||||
nrf52840-hal = { version = "0.12.1", optional = true }
|
||||
|
@ -15,7 +15,6 @@ use embassy::io::{AsyncBufRead, AsyncWrite, Result};
|
||||
use embassy::util::WakerRegistration;
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
|
||||
use crate::hal::gpio::Port as GpioPort;
|
||||
use crate::hal::ppi::ConfigurablePpi;
|
||||
use crate::interrupt::{self, Interrupt};
|
||||
use crate::pac;
|
||||
@ -72,14 +71,6 @@ pub struct BufferedUarte<
|
||||
inner: PeripheralMutex<State<'a, U, T, P1, P2>>,
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
fn port_bit(port: GpioPort) -> bool {
|
||||
match port {
|
||||
GpioPort::Port0 => false,
|
||||
GpioPort::Port1 => true,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi>
|
||||
BufferedUarte<'a, U, T, P1, P2>
|
||||
{
|
||||
@ -97,25 +88,19 @@ impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi
|
||||
) -> Self {
|
||||
// Select pins
|
||||
uarte.psel.rxd.write(|w| {
|
||||
let w = unsafe { w.pin().bits(pins.rxd.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(pins.rxd.port()));
|
||||
unsafe { w.bits(pins.rxd.psel_bits()) };
|
||||
w.connect().connected()
|
||||
});
|
||||
pins.txd.set_high().unwrap();
|
||||
uarte.psel.txd.write(|w| {
|
||||
let w = unsafe { w.pin().bits(pins.txd.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(pins.txd.port()));
|
||||
unsafe { w.bits(pins.txd.psel_bits()) };
|
||||
w.connect().connected()
|
||||
});
|
||||
|
||||
// Optional pins
|
||||
uarte.psel.cts.write(|w| {
|
||||
if let Some(ref pin) = pins.cts {
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
} else {
|
||||
w.connect().disconnected()
|
||||
@ -124,15 +109,14 @@ impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi
|
||||
|
||||
uarte.psel.rts.write(|w| {
|
||||
if let Some(ref pin) = pins.rts {
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
} else {
|
||||
w.connect().disconnected()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Enable UARTE instance
|
||||
uarte.enable.write(|w| w.enable().enabled());
|
||||
|
||||
|
@ -3,7 +3,7 @@ use core::pin::Pin;
|
||||
use core::task::Poll;
|
||||
|
||||
use crate::fmt::{assert, assert_eq, *};
|
||||
use crate::hal::gpio::{Output, Pin as GpioPin, Port as GpioPort, PushPull};
|
||||
use crate::hal::gpio::{Output, Pin as GpioPin, PushPull};
|
||||
use crate::interrupt::{self};
|
||||
use crate::pac::QSPI;
|
||||
|
||||
@ -59,43 +59,31 @@ pub struct Qspi {
|
||||
inner: PeripheralMutex<State>,
|
||||
}
|
||||
|
||||
fn port_bit(port: GpioPort) -> bool {
|
||||
match port {
|
||||
GpioPort::Port0 => false,
|
||||
GpioPort::Port1 => true,
|
||||
}
|
||||
}
|
||||
|
||||
impl Qspi {
|
||||
pub fn new(qspi: QSPI, irq: interrupt::QSPI, config: Config) -> Self {
|
||||
qspi.psel.sck.write(|w| {
|
||||
let pin = &config.pins.sck;
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
});
|
||||
qspi.psel.csn.write(|w| {
|
||||
let pin = &config.pins.csn;
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
});
|
||||
qspi.psel.io0.write(|w| {
|
||||
let pin = &config.pins.io0;
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
});
|
||||
qspi.psel.io1.write(|w| {
|
||||
let pin = &config.pins.io1;
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
});
|
||||
qspi.psel.io2.write(|w| {
|
||||
if let Some(ref pin) = config.pins.io2 {
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
} else {
|
||||
w.connect().disconnected()
|
||||
@ -103,8 +91,7 @@ impl Qspi {
|
||||
});
|
||||
qspi.psel.io3.write(|w| {
|
||||
if let Some(ref pin) = config.pins.io3 {
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
} else {
|
||||
w.connect().disconnected()
|
||||
|
@ -5,7 +5,6 @@ use core::task::Poll;
|
||||
use embassy::util::WakerRegistration;
|
||||
use futures::future::poll_fn;
|
||||
|
||||
use crate::hal::gpio::Port as GpioPort;
|
||||
use crate::interrupt::{self, Interrupt};
|
||||
use crate::util::peripheral::{PeripheralMutex, PeripheralState};
|
||||
use crate::{pac, slice_in_ram_or};
|
||||
@ -33,14 +32,6 @@ pub struct Spim<T: Instance> {
|
||||
inner: PeripheralMutex<State<T>>,
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
fn port_bit(port: GpioPort) -> bool {
|
||||
match port {
|
||||
GpioPort::Port0 => false,
|
||||
GpioPort::Port1 => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Config {
|
||||
pub pins: Pins,
|
||||
pub frequency: Frequency,
|
||||
@ -54,26 +45,20 @@ impl<T: Instance> Spim<T> {
|
||||
|
||||
// Select pins.
|
||||
r.psel.sck.write(|w| {
|
||||
let w = unsafe { w.pin().bits(config.pins.sck.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(config.pins.sck.port()));
|
||||
unsafe { w.bits(config.pins.sck.psel_bits()) };
|
||||
w.connect().connected()
|
||||
});
|
||||
|
||||
match config.pins.mosi {
|
||||
Some(mosi) => r.psel.mosi.write(|w| {
|
||||
let w = unsafe { w.pin().bits(mosi.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(mosi.port()));
|
||||
unsafe { w.bits(mosi.psel_bits()) };
|
||||
w.connect().connected()
|
||||
}),
|
||||
None => r.psel.mosi.write(|w| w.connect().disconnected()),
|
||||
}
|
||||
match config.pins.miso {
|
||||
Some(miso) => r.psel.miso.write(|w| {
|
||||
let w = unsafe { w.pin().bits(miso.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(miso.port()));
|
||||
unsafe { w.bits(miso.psel_bits()) };
|
||||
w.connect().connected()
|
||||
}),
|
||||
None => r.psel.miso.write(|w| w.connect().disconnected()),
|
||||
|
@ -13,8 +13,6 @@ use embassy::interrupt::InterruptExt;
|
||||
use embassy::util::Signal;
|
||||
|
||||
use crate::fmt::{assert, *};
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
use crate::hal::gpio::Port as GpioPort;
|
||||
use crate::hal::pac;
|
||||
use crate::hal::prelude::*;
|
||||
use crate::hal::target_constants::EASY_DMA_SIZE;
|
||||
@ -40,15 +38,6 @@ pub struct State {
|
||||
rx_done: Signal<u32>,
|
||||
}
|
||||
|
||||
// TODO: Remove when https://github.com/nrf-rs/nrf-hal/pull/276 has landed
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
fn port_bit(port: GpioPort) -> bool {
|
||||
match port {
|
||||
GpioPort::Port0 => false,
|
||||
GpioPort::Port1 => true,
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Uarte<T>
|
||||
where
|
||||
T: Instance,
|
||||
@ -72,26 +61,20 @@ where
|
||||
assert!(uarte.enable.read().enable().is_disabled());
|
||||
|
||||
uarte.psel.rxd.write(|w| {
|
||||
let w = unsafe { w.pin().bits(pins.rxd.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(pins.rxd.port()));
|
||||
unsafe { w.bits(pins.rxd.psel_bits()) };
|
||||
w.connect().connected()
|
||||
});
|
||||
|
||||
pins.txd.set_high().unwrap();
|
||||
uarte.psel.txd.write(|w| {
|
||||
let w = unsafe { w.pin().bits(pins.txd.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(pins.txd.port()));
|
||||
unsafe { w.bits(pins.txd.psel_bits()) };
|
||||
w.connect().connected()
|
||||
});
|
||||
|
||||
// Optional pins
|
||||
uarte.psel.cts.write(|w| {
|
||||
if let Some(ref pin) = pins.cts {
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
} else {
|
||||
w.connect().disconnected()
|
||||
@ -100,9 +83,7 @@ where
|
||||
|
||||
uarte.psel.rts.write(|w| {
|
||||
if let Some(ref pin) = pins.rts {
|
||||
let w = unsafe { w.pin().bits(pin.pin()) };
|
||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||
let w = w.port().bit(port_bit(pin.port()));
|
||||
unsafe { w.bits(pin.psel_bits()) };
|
||||
w.connect().connected()
|
||||
} else {
|
||||
w.connect().disconnected()
|
||||
|
Loading…
Reference in New Issue
Block a user