Merge pull request #183 from rukai/fix_warnings
Fix all warnings on embassy-nrf + embassy-nrf-examples + embassy_extras
This commit is contained in:
commit
ccfcacaaa7
@ -1,4 +1,4 @@
|
|||||||
use crate::fmt::{assert, *};
|
use crate::fmt::assert;
|
||||||
|
|
||||||
pub struct RingBuffer<'a> {
|
pub struct RingBuffer<'a> {
|
||||||
buf: &'a mut [u8],
|
buf: &'a mut [u8],
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#[path = "../example_common.rs"]
|
#[path = "../example_common.rs"]
|
||||||
mod example_common;
|
mod example_common;
|
||||||
use example_common::*;
|
|
||||||
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::Spawner;
|
use embassy::executor::Spawner;
|
||||||
@ -17,7 +16,7 @@ use embassy_nrf::Peripherals;
|
|||||||
use embedded_hal::digital::v2::OutputPin;
|
use embedded_hal::digital::v2::OutputPin;
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -17,7 +17,7 @@ use example_common::*;
|
|||||||
use futures::pin_mut;
|
use futures::pin_mut;
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
let mut config = uarte::Config::default();
|
let mut config = uarte::Config::default();
|
||||||
config.parity = uarte::Parity::EXCLUDED;
|
config.parity = uarte::Parity::EXCLUDED;
|
||||||
config.baudrate = uarte::Baudrate::BAUD115200;
|
config.baudrate = uarte::Baudrate::BAUD115200;
|
||||||
|
@ -40,7 +40,7 @@ async fn run3() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(spawner: Spawner, _p: Peripherals) {
|
||||||
unwrap!(spawner.spawn(run1()));
|
unwrap!(spawner.spawn(run1()));
|
||||||
unwrap!(spawner.spawn(run2()));
|
unwrap!(spawner.spawn(run2()));
|
||||||
unwrap!(spawner.spawn(run3()));
|
unwrap!(spawner.spawn(run3()));
|
||||||
|
@ -16,7 +16,7 @@ use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity};
|
|||||||
use embassy_nrf::{interrupt, Peripherals};
|
use embassy_nrf::{interrupt, Peripherals};
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
info!("Starting!");
|
info!("Starting!");
|
||||||
|
|
||||||
let ch1 = InputChannel::new(
|
let ch1 = InputChannel::new(
|
||||||
|
@ -19,7 +19,7 @@ use embassy_nrf::{interrupt, Peripherals};
|
|||||||
use gpiote::{OutputChannel, OutputChannelPolarity};
|
use gpiote::{OutputChannel, OutputChannelPolarity};
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
info!("Starting!");
|
info!("Starting!");
|
||||||
|
|
||||||
let button1 = InputChannel::new(
|
let button1 = InputChannel::new(
|
||||||
|
@ -87,7 +87,7 @@ static DUTY: [u16; 1024] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
let pwm = Pwm::new(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15);
|
let pwm = Pwm::new(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15);
|
||||||
pwm.set_prescaler(Prescaler::Div1);
|
pwm.set_prescaler(Prescaler::Div1);
|
||||||
info!("pwm initialized!");
|
info!("pwm initialized!");
|
||||||
|
@ -23,7 +23,7 @@ const PAGE_SIZE: usize = 4096;
|
|||||||
struct AlignedBuf([u8; 4096]);
|
struct AlignedBuf([u8; 4096]);
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
let csn = p.P0_17;
|
let csn = p.P0_17;
|
||||||
let sck = p.P0_19;
|
let sck = p.P0_19;
|
||||||
let io0 = p.P0_20;
|
let io0 = p.P0_20;
|
||||||
|
@ -10,7 +10,6 @@ mod example_common;
|
|||||||
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::Spawner;
|
use embassy::executor::Spawner;
|
||||||
use embassy::util::Steal;
|
|
||||||
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
||||||
use embassy_nrf::Peripherals;
|
use embassy_nrf::Peripherals;
|
||||||
use embassy_nrf::{interrupt, spim};
|
use embassy_nrf::{interrupt, spim};
|
||||||
@ -19,7 +18,7 @@ use embedded_hal::digital::v2::*;
|
|||||||
use example_common::*;
|
use example_common::*;
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
info!("running!");
|
info!("running!");
|
||||||
|
|
||||||
let mut config = spim::Config::default();
|
let mut config = spim::Config::default();
|
||||||
|
@ -31,7 +31,7 @@ async fn run2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(spawner: Spawner, _p: Peripherals) {
|
||||||
unwrap!(spawner.spawn(run1()));
|
unwrap!(spawner.spawn(run1()));
|
||||||
unwrap!(spawner.spawn(run2()));
|
unwrap!(spawner.spawn(run2()));
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,11 @@ use example_common::*;
|
|||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::Spawner;
|
use embassy::executor::Spawner;
|
||||||
use embassy::traits::uart::{Read, Write};
|
use embassy::traits::uart::{Read, Write};
|
||||||
use embassy::util::Steal;
|
|
||||||
use embassy_nrf::gpio::NoPin;
|
use embassy_nrf::gpio::NoPin;
|
||||||
use embassy_nrf::{interrupt, uarte, Peripherals};
|
use embassy_nrf::{interrupt, uarte, Peripherals};
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
let mut config = uarte::Config::default();
|
let mut config = uarte::Config::default();
|
||||||
config.parity = uarte::Parity::EXCLUDED;
|
config.parity = uarte::Parity::EXCLUDED;
|
||||||
config.baudrate = uarte::Baudrate::BAUD115200;
|
config.baudrate = uarte::Baudrate::BAUD115200;
|
||||||
|
@ -12,13 +12,12 @@ use example_common::*;
|
|||||||
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::Spawner;
|
use embassy::executor::Spawner;
|
||||||
use embassy::traits::uart::{Read, Write};
|
use embassy::traits::uart::Write;
|
||||||
use embassy::util::Steal;
|
|
||||||
use embassy_nrf::gpio::NoPin;
|
use embassy_nrf::gpio::NoPin;
|
||||||
use embassy_nrf::{interrupt, uarte, Peripherals};
|
use embassy_nrf::{interrupt, uarte, Peripherals};
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
let mut config = uarte::Config::default();
|
let mut config = uarte::Config::default();
|
||||||
config.parity = uarte::Parity::EXCLUDED;
|
config.parity = uarte::Parity::EXCLUDED;
|
||||||
config.baudrate = uarte::Baudrate::BAUD115200;
|
config.baudrate = uarte::Baudrate::BAUD115200;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use core::cmp::min;
|
use core::cmp::min;
|
||||||
|
use core::marker::PhantomData;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use core::sync::atomic::{compiler_fence, Ordering};
|
use core::sync::atomic::{compiler_fence, Ordering};
|
||||||
@ -34,7 +35,7 @@ enum TxState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct State<'d, U: UarteInstance, T: TimerInstance> {
|
struct State<'d, U: UarteInstance, T: TimerInstance> {
|
||||||
uarte: U,
|
phantom: PhantomData<&'d mut U>,
|
||||||
timer: T,
|
timer: T,
|
||||||
_ppi_ch1: Ppi<'d, AnyConfigurableChannel>,
|
_ppi_ch1: Ppi<'d, AnyConfigurableChannel>,
|
||||||
_ppi_ch2: Ppi<'d, AnyConfigurableChannel>,
|
_ppi_ch2: Ppi<'d, AnyConfigurableChannel>,
|
||||||
@ -63,7 +64,7 @@ pub struct BufferedUarte<'d, U: UarteInstance, T: TimerInstance> {
|
|||||||
impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
|
impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
|
||||||
/// unsafe: may not leak self or futures
|
/// unsafe: may not leak self or futures
|
||||||
pub unsafe fn new(
|
pub unsafe fn new(
|
||||||
uarte: impl Unborrow<Target = U> + 'd,
|
_uarte: impl Unborrow<Target = U> + 'd,
|
||||||
timer: impl Unborrow<Target = T> + 'd,
|
timer: impl Unborrow<Target = T> + 'd,
|
||||||
ppi_ch1: impl Unborrow<Target = impl ConfigurableChannel> + 'd,
|
ppi_ch1: impl Unborrow<Target = impl ConfigurableChannel> + 'd,
|
||||||
ppi_ch2: impl Unborrow<Target = impl ConfigurableChannel> + 'd,
|
ppi_ch2: impl Unborrow<Target = impl ConfigurableChannel> + 'd,
|
||||||
@ -76,7 +77,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
|
|||||||
rx_buffer: &'d mut [u8],
|
rx_buffer: &'d mut [u8],
|
||||||
tx_buffer: &'d mut [u8],
|
tx_buffer: &'d mut [u8],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(uarte, timer, ppi_ch1, ppi_ch2, irq, rxd, txd, cts, rts);
|
unborrow!(timer, ppi_ch1, ppi_ch2, irq, rxd, txd, cts, rts);
|
||||||
|
|
||||||
let r = U::regs();
|
let r = U::regs();
|
||||||
let rt = timer.regs();
|
let rt = timer.regs();
|
||||||
@ -158,7 +159,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
|
|||||||
BufferedUarte {
|
BufferedUarte {
|
||||||
inner: PeripheralMutex::new(
|
inner: PeripheralMutex::new(
|
||||||
State {
|
State {
|
||||||
uarte,
|
phantom: PhantomData,
|
||||||
timer,
|
timer,
|
||||||
_ppi_ch1: ppi_ch1,
|
_ppi_ch1: ppi_ch1,
|
||||||
_ppi_ch2: ppi_ch2,
|
_ppi_ch2: ppi_ch2,
|
||||||
|
@ -11,7 +11,6 @@ use gpio::pin_cnf::DRIVE_A;
|
|||||||
|
|
||||||
use crate::pac;
|
use crate::pac;
|
||||||
use crate::pac::p0 as gpio;
|
use crate::pac::p0 as gpio;
|
||||||
use crate::peripherals;
|
|
||||||
|
|
||||||
/// A GPIO port with up to 32 pins.
|
/// A GPIO port with up to 32 pins.
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
|
@ -6,7 +6,7 @@ use core::sync::atomic::{compiler_fence, Ordering};
|
|||||||
use embassy::util::Unborrow;
|
use embassy::util::Unborrow;
|
||||||
use embassy_extras::unborrow;
|
use embassy_extras::unborrow;
|
||||||
|
|
||||||
use crate::fmt::{assert, panic, unreachable, *};
|
use crate::fmt::{unreachable, *};
|
||||||
use crate::gpio::sealed::Pin as _;
|
use crate::gpio::sealed::Pin as _;
|
||||||
use crate::gpio::OptionalPin as GpioOptionalPin;
|
use crate::gpio::OptionalPin as GpioOptionalPin;
|
||||||
use crate::interrupt::Interrupt;
|
use crate::interrupt::Interrupt;
|
||||||
@ -26,7 +26,6 @@ pub enum Prescaler {
|
|||||||
|
|
||||||
/// Interface to the UARTE peripheral
|
/// Interface to the UARTE peripheral
|
||||||
pub struct Pwm<'d, T: Instance> {
|
pub struct Pwm<'d, T: Instance> {
|
||||||
peri: T,
|
|
||||||
phantom: PhantomData<&'d mut T>,
|
phantom: PhantomData<&'d mut T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,13 +40,13 @@ impl<'d, T: Instance> Pwm<'d, T> {
|
|||||||
/// or [`receive`](Pwm::receive).
|
/// or [`receive`](Pwm::receive).
|
||||||
#[allow(unused_unsafe)]
|
#[allow(unused_unsafe)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
pwm: impl Unborrow<Target = T> + 'd,
|
_pwm: impl Unborrow<Target = T> + 'd,
|
||||||
ch0: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
ch0: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
||||||
ch1: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
ch1: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
||||||
ch2: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
ch2: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
||||||
ch3: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
ch3: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(pwm, ch0, ch1, ch2, ch3);
|
unborrow!(ch0, ch1, ch2, ch3);
|
||||||
|
|
||||||
let r = T::regs();
|
let r = T::regs();
|
||||||
let s = T::state();
|
let s = T::state();
|
||||||
@ -97,7 +96,6 @@ impl<'d, T: Instance> Pwm<'d, T> {
|
|||||||
r.loop_.write(|w| w.cnt().disabled());
|
r.loop_.write(|w| w.cnt().disabled());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
peri: pwm,
|
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,7 @@ use futures::future::poll_fn;
|
|||||||
|
|
||||||
use crate::fmt::{assert, assert_eq, *};
|
use crate::fmt::{assert, assert_eq, *};
|
||||||
use crate::gpio::Pin as GpioPin;
|
use crate::gpio::Pin as GpioPin;
|
||||||
use crate::interrupt::{self};
|
use crate::pac;
|
||||||
use crate::{pac, peripherals};
|
|
||||||
|
|
||||||
pub use crate::pac::qspi::ifconfig0::ADDRMODE_A as AddressMode;
|
pub use crate::pac::qspi::ifconfig0::ADDRMODE_A as AddressMode;
|
||||||
pub use crate::pac::qspi::ifconfig0::PPSIZE_A as WritePageSize;
|
pub use crate::pac::qspi::ifconfig0::PPSIZE_A as WritePageSize;
|
||||||
@ -56,14 +55,12 @@ impl Default for Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Qspi<'d, T: Instance> {
|
pub struct Qspi<'d, T: Instance> {
|
||||||
peri: T,
|
|
||||||
irq: T::Interrupt,
|
|
||||||
phantom: PhantomData<&'d mut T>,
|
phantom: PhantomData<&'d mut T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Instance> Qspi<'d, T> {
|
impl<'d, T: Instance> Qspi<'d, T> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
qspi: impl Unborrow<Target = T> + 'd,
|
_qspi: impl Unborrow<Target = T> + 'd,
|
||||||
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||||
sck: impl Unborrow<Target = impl GpioPin> + 'd,
|
sck: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
csn: impl Unborrow<Target = impl GpioPin> + 'd,
|
csn: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
@ -73,7 +70,7 @@ impl<'d, T: Instance> Qspi<'d, T> {
|
|||||||
io3: impl Unborrow<Target = impl GpioPin> + 'd,
|
io3: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(qspi, irq, sck, csn, io0, io1, io2, io3);
|
unborrow!(irq, sck, csn, io0, io1, io2, io3);
|
||||||
|
|
||||||
let r = T::regs();
|
let r = T::regs();
|
||||||
|
|
||||||
@ -140,8 +137,6 @@ impl<'d, T: Instance> Qspi<'d, T> {
|
|||||||
irq.enable();
|
irq.enable();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
peri: qspi,
|
|
||||||
irq,
|
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,6 @@ pub enum Error {}
|
|||||||
|
|
||||||
/// One-shot saadc. Continuous sample mode TODO.
|
/// One-shot saadc. Continuous sample mode TODO.
|
||||||
pub struct OneShot<'d, T: PositivePin> {
|
pub struct OneShot<'d, T: PositivePin> {
|
||||||
peri: peripherals::SAADC,
|
|
||||||
positive_pin: T,
|
|
||||||
irq: interrupt::SAADC,
|
irq: interrupt::SAADC,
|
||||||
phantom: PhantomData<(&'d mut peripherals::SAADC, &'d mut T)>,
|
phantom: PhantomData<(&'d mut peripherals::SAADC, &'d mut T)>,
|
||||||
}
|
}
|
||||||
@ -71,12 +69,12 @@ impl Default for Config {
|
|||||||
|
|
||||||
impl<'d, T: PositivePin> OneShot<'d, T> {
|
impl<'d, T: PositivePin> OneShot<'d, T> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
saadc: impl Unborrow<Target = peripherals::SAADC> + 'd,
|
_saadc: impl Unborrow<Target = peripherals::SAADC> + 'd,
|
||||||
irq: impl Unborrow<Target = interrupt::SAADC> + 'd,
|
irq: impl Unborrow<Target = interrupt::SAADC> + 'd,
|
||||||
positive_pin: impl Unborrow<Target = T> + 'd,
|
positive_pin: impl Unborrow<Target = T> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(saadc, irq, positive_pin);
|
unborrow!(irq, positive_pin);
|
||||||
|
|
||||||
let r = unsafe { &*SAADC::ptr() };
|
let r = unsafe { &*SAADC::ptr() };
|
||||||
|
|
||||||
@ -118,8 +116,6 @@ impl<'d, T: PositivePin> OneShot<'d, T> {
|
|||||||
r.intenclr.write(|w| unsafe { w.bits(0x003F_FFFF) });
|
r.intenclr.write(|w| unsafe { w.bits(0x003F_FFFF) });
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
peri: saadc,
|
|
||||||
positive_pin,
|
|
||||||
irq,
|
irq,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ use traits::spi::FullDuplex;
|
|||||||
|
|
||||||
use crate::gpio::sealed::Pin as _;
|
use crate::gpio::sealed::Pin as _;
|
||||||
use crate::gpio::{OptionalPin, Pin as GpioPin};
|
use crate::gpio::{OptionalPin, Pin as GpioPin};
|
||||||
use crate::interrupt::{self, Interrupt};
|
use crate::interrupt::Interrupt;
|
||||||
use crate::{pac, peripherals, util::slice_in_ram_or};
|
use crate::{pac, util::slice_in_ram_or};
|
||||||
|
|
||||||
pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};
|
pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};
|
||||||
pub use pac::spim0::frequency::FREQUENCY_A as Frequency;
|
pub use pac::spim0::frequency::FREQUENCY_A as Frequency;
|
||||||
@ -30,8 +30,6 @@ pub enum Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Spim<'d, T: Instance> {
|
pub struct Spim<'d, T: Instance> {
|
||||||
peri: T,
|
|
||||||
irq: T::Interrupt,
|
|
||||||
phantom: PhantomData<&'d mut T>,
|
phantom: PhantomData<&'d mut T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,14 +52,14 @@ impl Default for Config {
|
|||||||
|
|
||||||
impl<'d, T: Instance> Spim<'d, T> {
|
impl<'d, T: Instance> Spim<'d, T> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
spim: impl Unborrow<Target = T> + 'd,
|
_spim: impl Unborrow<Target = T> + 'd,
|
||||||
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||||
sck: impl Unborrow<Target = impl GpioPin> + 'd,
|
sck: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
miso: impl Unborrow<Target = impl OptionalPin> + 'd,
|
miso: impl Unborrow<Target = impl OptionalPin> + 'd,
|
||||||
mosi: impl Unborrow<Target = impl OptionalPin> + 'd,
|
mosi: impl Unborrow<Target = impl OptionalPin> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(spim, irq, sck, miso, mosi);
|
unborrow!(irq, sck, miso, mosi);
|
||||||
|
|
||||||
let r = T::regs();
|
let r = T::regs();
|
||||||
|
|
||||||
@ -140,8 +138,6 @@ impl<'d, T: Instance> Spim<'d, T> {
|
|||||||
irq.enable();
|
irq.enable();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
peri: spim,
|
|
||||||
irq,
|
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +281,7 @@ impl<'d, T: Instance> embedded_hal::blocking::spi::Write<u8> for Spim<'d, T> {
|
|||||||
|
|
||||||
fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> {
|
fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> {
|
||||||
slice_in_ram_or(words, Error::DMABufferNotInDataMemory)?;
|
slice_in_ram_or(words, Error::DMABufferNotInDataMemory)?;
|
||||||
let mut recv: &mut [u8] = &mut [];
|
let recv: &mut [u8] = &mut [];
|
||||||
|
|
||||||
// Conservative compiler fence to prevent optimizations that do not
|
// Conservative compiler fence to prevent optimizations that do not
|
||||||
// take in to account actions by DMA. The fence has been placed here,
|
// take in to account actions by DMA. The fence has been placed here,
|
||||||
|
@ -42,20 +42,18 @@ impl Default for Config {
|
|||||||
|
|
||||||
/// Interface to a TWIM instance.
|
/// Interface to a TWIM instance.
|
||||||
pub struct Twim<'d, T: Instance> {
|
pub struct Twim<'d, T: Instance> {
|
||||||
peri: T,
|
|
||||||
irq: T::Interrupt,
|
|
||||||
phantom: PhantomData<&'d mut T>,
|
phantom: PhantomData<&'d mut T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Instance> Twim<'d, T> {
|
impl<'d, T: Instance> Twim<'d, T> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
twim: impl Unborrow<Target = T> + 'd,
|
_twim: impl Unborrow<Target = T> + 'd,
|
||||||
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||||
sda: impl Unborrow<Target = impl GpioPin> + 'd,
|
sda: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
scl: impl Unborrow<Target = impl GpioPin> + 'd,
|
scl: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(twim, irq, sda, scl);
|
unborrow!(irq, sda, scl);
|
||||||
|
|
||||||
let r = T::regs();
|
let r = T::regs();
|
||||||
|
|
||||||
@ -94,8 +92,6 @@ impl<'d, T: Instance> Twim<'d, T> {
|
|||||||
irq.enable();
|
irq.enable();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
peri: twim,
|
|
||||||
irq,
|
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,8 @@ use crate::chip::EASY_DMA_SIZE;
|
|||||||
use crate::fmt::{assert, panic, *};
|
use crate::fmt::{assert, panic, *};
|
||||||
use crate::gpio::sealed::Pin as _;
|
use crate::gpio::sealed::Pin as _;
|
||||||
use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin};
|
use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin};
|
||||||
use crate::interrupt;
|
|
||||||
use crate::interrupt::Interrupt;
|
use crate::interrupt::Interrupt;
|
||||||
use crate::pac;
|
use crate::pac;
|
||||||
use crate::peripherals;
|
|
||||||
use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task};
|
use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task};
|
||||||
use crate::timer::Instance as TimerInstance;
|
use crate::timer::Instance as TimerInstance;
|
||||||
|
|
||||||
@ -43,7 +41,6 @@ impl Default for Config {
|
|||||||
|
|
||||||
/// Interface to the UARTE peripheral
|
/// Interface to the UARTE peripheral
|
||||||
pub struct Uarte<'d, T: Instance> {
|
pub struct Uarte<'d, T: Instance> {
|
||||||
peri: T,
|
|
||||||
phantom: PhantomData<&'d mut T>,
|
phantom: PhantomData<&'d mut T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +55,7 @@ impl<'d, T: Instance> Uarte<'d, T> {
|
|||||||
/// or [`receive`](Uarte::receive).
|
/// or [`receive`](Uarte::receive).
|
||||||
#[allow(unused_unsafe)]
|
#[allow(unused_unsafe)]
|
||||||
pub unsafe fn new(
|
pub unsafe fn new(
|
||||||
uarte: impl Unborrow<Target = T> + 'd,
|
_uarte: impl Unborrow<Target = T> + 'd,
|
||||||
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||||
rxd: impl Unborrow<Target = impl GpioPin> + 'd,
|
rxd: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
txd: impl Unborrow<Target = impl GpioPin> + 'd,
|
txd: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
@ -66,7 +63,7 @@ impl<'d, T: Instance> Uarte<'d, T> {
|
|||||||
rts: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
rts: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(uarte, irq, rxd, txd, cts, rts);
|
unborrow!(irq, rxd, txd, cts, rts);
|
||||||
|
|
||||||
let r = T::regs();
|
let r = T::regs();
|
||||||
|
|
||||||
@ -119,7 +116,6 @@ impl<'d, T: Instance> Uarte<'d, T> {
|
|||||||
r.enable.write(|w| w.enable().enabled());
|
r.enable.write(|w| w.enable().enabled());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
peri: uarte,
|
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user