Merge pull request #419 from embassy-rs/nrf-fixes-2

Nrf fixes 2
This commit is contained in:
Dario Nieuwenhuis 2021-10-11 01:42:28 +02:00 committed by GitHub
commit 9fec833015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 296 additions and 93 deletions

View File

@ -159,6 +159,32 @@ impl_pin!(P0_29, 0, 29);
impl_pin!(P0_30, 0, 30);
impl_pin!(P0_31, 0, 31);
impl_ppi_channel!(PPI_CH0, 0, configurable);
impl_ppi_channel!(PPI_CH1, 1, configurable);
impl_ppi_channel!(PPI_CH2, 2, configurable);
impl_ppi_channel!(PPI_CH3, 3, configurable);
impl_ppi_channel!(PPI_CH4, 4, configurable);
impl_ppi_channel!(PPI_CH5, 5, configurable);
impl_ppi_channel!(PPI_CH6, 6, configurable);
impl_ppi_channel!(PPI_CH7, 7, configurable);
impl_ppi_channel!(PPI_CH8, 8, configurable);
impl_ppi_channel!(PPI_CH9, 9, configurable);
impl_ppi_channel!(PPI_CH20, 20);
impl_ppi_channel!(PPI_CH21, 21);
impl_ppi_channel!(PPI_CH22, 22);
impl_ppi_channel!(PPI_CH23, 23);
impl_ppi_channel!(PPI_CH24, 24);
impl_ppi_channel!(PPI_CH25, 25);
impl_ppi_channel!(PPI_CH26, 26);
impl_ppi_channel!(PPI_CH27, 27);
impl_ppi_channel!(PPI_CH28, 28);
impl_ppi_channel!(PPI_CH29, 29);
impl_ppi_channel!(PPI_CH30, 30);
impl_ppi_channel!(PPI_CH31, 31);
impl_saadc_input!(P0_04, ANALOGINPUT2);
impl_saadc_input!(P0_05, ANALOGINPUT3);
pub mod irqs {
use crate::pac::Interrupt as InterruptEnum;
use embassy_macros::interrupt_declare as declare;

View File

@ -164,6 +164,48 @@ impl_pin!(P0_29, 0, 29);
impl_pin!(P0_30, 0, 30);
impl_pin!(P0_31, 0, 31);
impl_ppi_channel!(PPI_CH0, 0, configurable);
impl_ppi_channel!(PPI_CH1, 1, configurable);
impl_ppi_channel!(PPI_CH2, 2, configurable);
impl_ppi_channel!(PPI_CH3, 3, configurable);
impl_ppi_channel!(PPI_CH4, 4, configurable);
impl_ppi_channel!(PPI_CH5, 5, configurable);
impl_ppi_channel!(PPI_CH6, 6, configurable);
impl_ppi_channel!(PPI_CH7, 7, configurable);
impl_ppi_channel!(PPI_CH8, 8, configurable);
impl_ppi_channel!(PPI_CH9, 9, configurable);
impl_ppi_channel!(PPI_CH10, 10, configurable);
impl_ppi_channel!(PPI_CH11, 11, configurable);
impl_ppi_channel!(PPI_CH12, 12, configurable);
impl_ppi_channel!(PPI_CH13, 13, configurable);
impl_ppi_channel!(PPI_CH14, 14, configurable);
impl_ppi_channel!(PPI_CH15, 15, configurable);
impl_ppi_channel!(PPI_CH16, 16, configurable);
impl_ppi_channel!(PPI_CH17, 17, configurable);
impl_ppi_channel!(PPI_CH18, 18, configurable);
impl_ppi_channel!(PPI_CH19, 19, configurable);
impl_ppi_channel!(PPI_CH20, 20);
impl_ppi_channel!(PPI_CH21, 21);
impl_ppi_channel!(PPI_CH22, 22);
impl_ppi_channel!(PPI_CH23, 23);
impl_ppi_channel!(PPI_CH24, 24);
impl_ppi_channel!(PPI_CH25, 25);
impl_ppi_channel!(PPI_CH26, 26);
impl_ppi_channel!(PPI_CH27, 27);
impl_ppi_channel!(PPI_CH28, 28);
impl_ppi_channel!(PPI_CH29, 29);
impl_ppi_channel!(PPI_CH30, 30);
impl_ppi_channel!(PPI_CH31, 31);
impl_saadc_input!(P0_02, ANALOGINPUT0);
impl_saadc_input!(P0_03, ANALOGINPUT1);
impl_saadc_input!(P0_04, ANALOGINPUT2);
impl_saadc_input!(P0_05, ANALOGINPUT3);
impl_saadc_input!(P0_28, ANALOGINPUT4);
impl_saadc_input!(P0_29, ANALOGINPUT5);
impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use crate::pac::Interrupt as InterruptEnum;
use embassy_macros::interrupt_declare as declare;

View File

@ -165,6 +165,48 @@ impl_pin!(P0_29, 0, 29);
impl_pin!(P0_30, 0, 30);
impl_pin!(P0_31, 0, 31);
impl_ppi_channel!(PPI_CH0, 0, configurable);
impl_ppi_channel!(PPI_CH1, 1, configurable);
impl_ppi_channel!(PPI_CH2, 2, configurable);
impl_ppi_channel!(PPI_CH3, 3, configurable);
impl_ppi_channel!(PPI_CH4, 4, configurable);
impl_ppi_channel!(PPI_CH5, 5, configurable);
impl_ppi_channel!(PPI_CH6, 6, configurable);
impl_ppi_channel!(PPI_CH7, 7, configurable);
impl_ppi_channel!(PPI_CH8, 8, configurable);
impl_ppi_channel!(PPI_CH9, 9, configurable);
impl_ppi_channel!(PPI_CH10, 10, configurable);
impl_ppi_channel!(PPI_CH11, 11, configurable);
impl_ppi_channel!(PPI_CH12, 12, configurable);
impl_ppi_channel!(PPI_CH13, 13, configurable);
impl_ppi_channel!(PPI_CH14, 14, configurable);
impl_ppi_channel!(PPI_CH15, 15, configurable);
impl_ppi_channel!(PPI_CH16, 16, configurable);
impl_ppi_channel!(PPI_CH17, 17, configurable);
impl_ppi_channel!(PPI_CH18, 18, configurable);
impl_ppi_channel!(PPI_CH19, 19, configurable);
impl_ppi_channel!(PPI_CH20, 20);
impl_ppi_channel!(PPI_CH21, 21);
impl_ppi_channel!(PPI_CH22, 22);
impl_ppi_channel!(PPI_CH23, 23);
impl_ppi_channel!(PPI_CH24, 24);
impl_ppi_channel!(PPI_CH25, 25);
impl_ppi_channel!(PPI_CH26, 26);
impl_ppi_channel!(PPI_CH27, 27);
impl_ppi_channel!(PPI_CH28, 28);
impl_ppi_channel!(PPI_CH29, 29);
impl_ppi_channel!(PPI_CH30, 30);
impl_ppi_channel!(PPI_CH31, 31);
impl_saadc_input!(P0_02, ANALOGINPUT0);
impl_saadc_input!(P0_03, ANALOGINPUT1);
impl_saadc_input!(P0_04, ANALOGINPUT2);
impl_saadc_input!(P0_05, ANALOGINPUT3);
impl_saadc_input!(P0_28, ANALOGINPUT4);
impl_saadc_input!(P0_29, ANALOGINPUT5);
impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use crate::pac::Interrupt as InterruptEnum;
use embassy_macros::interrupt_declare as declare;

View File

@ -160,6 +160,39 @@ impl_pin!(P0_29, 0, 29);
impl_pin!(P0_30, 0, 30);
impl_pin!(P0_31, 0, 31);
impl_ppi_channel!(PPI_CH0, 0, configurable);
impl_ppi_channel!(PPI_CH1, 1, configurable);
impl_ppi_channel!(PPI_CH2, 2, configurable);
impl_ppi_channel!(PPI_CH3, 3, configurable);
impl_ppi_channel!(PPI_CH4, 4, configurable);
impl_ppi_channel!(PPI_CH5, 5, configurable);
impl_ppi_channel!(PPI_CH6, 6, configurable);
impl_ppi_channel!(PPI_CH7, 7, configurable);
impl_ppi_channel!(PPI_CH8, 8, configurable);
impl_ppi_channel!(PPI_CH9, 9, configurable);
impl_ppi_channel!(PPI_CH10, 10, configurable);
impl_ppi_channel!(PPI_CH11, 11, configurable);
impl_ppi_channel!(PPI_CH12, 12, configurable);
impl_ppi_channel!(PPI_CH13, 13, configurable);
impl_ppi_channel!(PPI_CH14, 14, configurable);
impl_ppi_channel!(PPI_CH15, 15, configurable);
impl_ppi_channel!(PPI_CH16, 16, configurable);
impl_ppi_channel!(PPI_CH17, 17, configurable);
impl_ppi_channel!(PPI_CH18, 18, configurable);
impl_ppi_channel!(PPI_CH19, 19, configurable);
impl_ppi_channel!(PPI_CH20, 20);
impl_ppi_channel!(PPI_CH21, 21);
impl_ppi_channel!(PPI_CH22, 22);
impl_ppi_channel!(PPI_CH23, 23);
impl_ppi_channel!(PPI_CH24, 24);
impl_ppi_channel!(PPI_CH25, 25);
impl_ppi_channel!(PPI_CH26, 26);
impl_ppi_channel!(PPI_CH27, 27);
impl_ppi_channel!(PPI_CH28, 28);
impl_ppi_channel!(PPI_CH29, 29);
impl_ppi_channel!(PPI_CH30, 30);
impl_ppi_channel!(PPI_CH31, 31);
pub mod irqs {
use crate::pac::Interrupt as InterruptEnum;
use embassy_macros::interrupt_declare as declare;

View File

@ -178,6 +178,48 @@ impl_pin!(P0_29, 0, 29);
impl_pin!(P0_30, 0, 30);
impl_pin!(P0_31, 0, 31);
impl_ppi_channel!(PPI_CH0, 0, configurable);
impl_ppi_channel!(PPI_CH1, 1, configurable);
impl_ppi_channel!(PPI_CH2, 2, configurable);
impl_ppi_channel!(PPI_CH3, 3, configurable);
impl_ppi_channel!(PPI_CH4, 4, configurable);
impl_ppi_channel!(PPI_CH5, 5, configurable);
impl_ppi_channel!(PPI_CH6, 6, configurable);
impl_ppi_channel!(PPI_CH7, 7, configurable);
impl_ppi_channel!(PPI_CH8, 8, configurable);
impl_ppi_channel!(PPI_CH9, 9, configurable);
impl_ppi_channel!(PPI_CH10, 10, configurable);
impl_ppi_channel!(PPI_CH11, 11, configurable);
impl_ppi_channel!(PPI_CH12, 12, configurable);
impl_ppi_channel!(PPI_CH13, 13, configurable);
impl_ppi_channel!(PPI_CH14, 14, configurable);
impl_ppi_channel!(PPI_CH15, 15, configurable);
impl_ppi_channel!(PPI_CH16, 16, configurable);
impl_ppi_channel!(PPI_CH17, 17, configurable);
impl_ppi_channel!(PPI_CH18, 18, configurable);
impl_ppi_channel!(PPI_CH19, 19, configurable);
impl_ppi_channel!(PPI_CH20, 20);
impl_ppi_channel!(PPI_CH21, 21);
impl_ppi_channel!(PPI_CH22, 22);
impl_ppi_channel!(PPI_CH23, 23);
impl_ppi_channel!(PPI_CH24, 24);
impl_ppi_channel!(PPI_CH25, 25);
impl_ppi_channel!(PPI_CH26, 26);
impl_ppi_channel!(PPI_CH27, 27);
impl_ppi_channel!(PPI_CH28, 28);
impl_ppi_channel!(PPI_CH29, 29);
impl_ppi_channel!(PPI_CH30, 30);
impl_ppi_channel!(PPI_CH31, 31);
impl_saadc_input!(P0_02, ANALOGINPUT0);
impl_saadc_input!(P0_03, ANALOGINPUT1);
impl_saadc_input!(P0_04, ANALOGINPUT2);
impl_saadc_input!(P0_05, ANALOGINPUT3);
impl_saadc_input!(P0_28, ANALOGINPUT4);
impl_saadc_input!(P0_29, ANALOGINPUT5);
impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use crate::pac::Interrupt as InterruptEnum;
use embassy_macros::interrupt_declare as declare;

View File

@ -218,6 +218,48 @@ impl_pin!(P1_13, 1, 13);
impl_pin!(P1_14, 1, 14);
impl_pin!(P1_15, 1, 15);
impl_ppi_channel!(PPI_CH0, 0, configurable);
impl_ppi_channel!(PPI_CH1, 1, configurable);
impl_ppi_channel!(PPI_CH2, 2, configurable);
impl_ppi_channel!(PPI_CH3, 3, configurable);
impl_ppi_channel!(PPI_CH4, 4, configurable);
impl_ppi_channel!(PPI_CH5, 5, configurable);
impl_ppi_channel!(PPI_CH6, 6, configurable);
impl_ppi_channel!(PPI_CH7, 7, configurable);
impl_ppi_channel!(PPI_CH8, 8, configurable);
impl_ppi_channel!(PPI_CH9, 9, configurable);
impl_ppi_channel!(PPI_CH10, 10, configurable);
impl_ppi_channel!(PPI_CH11, 11, configurable);
impl_ppi_channel!(PPI_CH12, 12, configurable);
impl_ppi_channel!(PPI_CH13, 13, configurable);
impl_ppi_channel!(PPI_CH14, 14, configurable);
impl_ppi_channel!(PPI_CH15, 15, configurable);
impl_ppi_channel!(PPI_CH16, 16, configurable);
impl_ppi_channel!(PPI_CH17, 17, configurable);
impl_ppi_channel!(PPI_CH18, 18, configurable);
impl_ppi_channel!(PPI_CH19, 19, configurable);
impl_ppi_channel!(PPI_CH20, 20);
impl_ppi_channel!(PPI_CH21, 21);
impl_ppi_channel!(PPI_CH22, 22);
impl_ppi_channel!(PPI_CH23, 23);
impl_ppi_channel!(PPI_CH24, 24);
impl_ppi_channel!(PPI_CH25, 25);
impl_ppi_channel!(PPI_CH26, 26);
impl_ppi_channel!(PPI_CH27, 27);
impl_ppi_channel!(PPI_CH28, 28);
impl_ppi_channel!(PPI_CH29, 29);
impl_ppi_channel!(PPI_CH30, 30);
impl_ppi_channel!(PPI_CH31, 31);
impl_saadc_input!(P0_02, ANALOGINPUT0);
impl_saadc_input!(P0_03, ANALOGINPUT1);
impl_saadc_input!(P0_04, ANALOGINPUT2);
impl_saadc_input!(P0_05, ANALOGINPUT3);
impl_saadc_input!(P0_28, ANALOGINPUT4);
impl_saadc_input!(P0_29, ANALOGINPUT5);
impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use crate::pac::Interrupt as InterruptEnum;
use embassy_macros::interrupt_declare as declare;

View File

@ -223,6 +223,48 @@ impl_pin!(P1_13, 1, 13);
impl_pin!(P1_14, 1, 14);
impl_pin!(P1_15, 1, 15);
impl_ppi_channel!(PPI_CH0, 0, configurable);
impl_ppi_channel!(PPI_CH1, 1, configurable);
impl_ppi_channel!(PPI_CH2, 2, configurable);
impl_ppi_channel!(PPI_CH3, 3, configurable);
impl_ppi_channel!(PPI_CH4, 4, configurable);
impl_ppi_channel!(PPI_CH5, 5, configurable);
impl_ppi_channel!(PPI_CH6, 6, configurable);
impl_ppi_channel!(PPI_CH7, 7, configurable);
impl_ppi_channel!(PPI_CH8, 8, configurable);
impl_ppi_channel!(PPI_CH9, 9, configurable);
impl_ppi_channel!(PPI_CH10, 10, configurable);
impl_ppi_channel!(PPI_CH11, 11, configurable);
impl_ppi_channel!(PPI_CH12, 12, configurable);
impl_ppi_channel!(PPI_CH13, 13, configurable);
impl_ppi_channel!(PPI_CH14, 14, configurable);
impl_ppi_channel!(PPI_CH15, 15, configurable);
impl_ppi_channel!(PPI_CH16, 16, configurable);
impl_ppi_channel!(PPI_CH17, 17, configurable);
impl_ppi_channel!(PPI_CH18, 18, configurable);
impl_ppi_channel!(PPI_CH19, 19, configurable);
impl_ppi_channel!(PPI_CH20, 20);
impl_ppi_channel!(PPI_CH21, 21);
impl_ppi_channel!(PPI_CH22, 22);
impl_ppi_channel!(PPI_CH23, 23);
impl_ppi_channel!(PPI_CH24, 24);
impl_ppi_channel!(PPI_CH25, 25);
impl_ppi_channel!(PPI_CH26, 26);
impl_ppi_channel!(PPI_CH27, 27);
impl_ppi_channel!(PPI_CH28, 28);
impl_ppi_channel!(PPI_CH29, 29);
impl_ppi_channel!(PPI_CH30, 30);
impl_ppi_channel!(PPI_CH31, 31);
impl_saadc_input!(P0_02, ANALOGINPUT0);
impl_saadc_input!(P0_03, ANALOGINPUT1);
impl_saadc_input!(P0_04, ANALOGINPUT2);
impl_saadc_input!(P0_05, ANALOGINPUT3);
impl_saadc_input!(P0_28, ANALOGINPUT4);
impl_saadc_input!(P0_29, ANALOGINPUT5);
impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use crate::pac::Interrupt as InterruptEnum;
use embassy_macros::interrupt_declare as declare;

View File

@ -239,14 +239,14 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> {
}
/// Triggers `task set` (set associated pin high).
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
pub fn set(&self) {
let g = unsafe { &*pac::GPIOTE::ptr() };
g.tasks_set[self.ch.number()].write(|w| unsafe { w.bits(1) });
}
/// Triggers `task clear` (set associated pin low).
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
pub fn clear(&self) {
let g = unsafe { &*pac::GPIOTE::ptr() };
g.tasks_clr[self.ch.number()].write(|w| unsafe { w.bits(1) });
@ -259,14 +259,14 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> {
}
/// Returns the CLR task, for use with PPI.
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
pub fn task_clr(&self) -> Task {
let g = unsafe { &*pac::GPIOTE::ptr() };
Task::from_reg(&g.tasks_clr[self.ch.number()])
}
/// Returns the SET task, for use with PPI.
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
pub fn task_set(&self) -> Task {
let g = unsafe { &*pac::GPIOTE::ptr() };
Task::from_reg(&g.tasks_set[self.ch.number()])

View File

@ -1,3 +1,5 @@
#![macro_use]
//! HAL interface for the PPI peripheral.
//!
//! The Programmable Peripheral Interconnect interface allows for an autonomous interoperability
@ -31,7 +33,7 @@ impl<'d, C: Channel> Ppi<'d, C> {
ch,
phantom: PhantomData,
};
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
this.clear_fork_task();
this
}
@ -50,7 +52,7 @@ impl<'d, C: Channel> Ppi<'d, C> {
.write(|w| unsafe { w.bits(1 << self.ch.number()) });
}
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
/// Sets the fork task that must be triggered when the configured event occurs. The user must
/// provide a reference to the task.
pub fn set_fork_task(&mut self, task: Task) {
@ -60,7 +62,7 @@ impl<'d, C: Channel> Ppi<'d, C> {
.write(|w| unsafe { w.bits(task.0.as_ptr() as u32) })
}
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
/// Clear the fork task endpoint. Previously set task will no longer be triggered.
pub fn clear_fork_task(&mut self) {
let r = unsafe { &*pac::PPI::ptr() };
@ -109,7 +111,7 @@ impl Event {
}
}
mod sealed {
pub(crate) mod sealed {
pub trait ConfigurableChannel {}
pub trait Channel {}
pub trait Group {}
@ -167,15 +169,15 @@ impl Channel for AnyConfigurableChannel {
}
}
macro_rules! impl_channel {
macro_rules! impl_ppi_channel {
($type:ident, $number:expr, configurable) => {
impl_channel!($type, $number);
impl sealed::ConfigurableChannel for peripherals::$type {}
impl ConfigurableChannel for peripherals::$type {}
impl_ppi_channel!($type, $number);
impl crate::ppi::sealed::ConfigurableChannel for peripherals::$type {}
impl crate::ppi::ConfigurableChannel for peripherals::$type {}
};
($type:ident, $number:expr) => {
impl sealed::Channel for peripherals::$type {}
impl Channel for peripherals::$type {
impl crate::ppi::sealed::Channel for peripherals::$type {}
impl crate::ppi::Channel for peripherals::$type {
fn number(&self) -> usize {
$number
}
@ -183,43 +185,6 @@ macro_rules! impl_channel {
};
}
impl_channel!(PPI_CH0, 0, configurable);
impl_channel!(PPI_CH1, 1, configurable);
impl_channel!(PPI_CH2, 2, configurable);
impl_channel!(PPI_CH3, 3, configurable);
impl_channel!(PPI_CH4, 4, configurable);
impl_channel!(PPI_CH5, 5, configurable);
impl_channel!(PPI_CH6, 6, configurable);
impl_channel!(PPI_CH7, 7, configurable);
impl_channel!(PPI_CH8, 8, configurable);
impl_channel!(PPI_CH9, 9, configurable);
impl_channel!(PPI_CH10, 10, configurable);
impl_channel!(PPI_CH11, 11, configurable);
impl_channel!(PPI_CH12, 12, configurable);
impl_channel!(PPI_CH13, 13, configurable);
impl_channel!(PPI_CH14, 14, configurable);
impl_channel!(PPI_CH15, 15, configurable);
#[cfg(not(feature = "51"))]
impl_channel!(PPI_CH16, 16, configurable);
#[cfg(not(feature = "51"))]
impl_channel!(PPI_CH17, 17, configurable);
#[cfg(not(feature = "51"))]
impl_channel!(PPI_CH18, 18, configurable);
#[cfg(not(feature = "51"))]
impl_channel!(PPI_CH19, 19, configurable);
impl_channel!(PPI_CH20, 20);
impl_channel!(PPI_CH21, 21);
impl_channel!(PPI_CH22, 22);
impl_channel!(PPI_CH23, 23);
impl_channel!(PPI_CH24, 24);
impl_channel!(PPI_CH25, 25);
impl_channel!(PPI_CH26, 26);
impl_channel!(PPI_CH27, 27);
impl_channel!(PPI_CH28, 28);
impl_channel!(PPI_CH29, 29);
impl_channel!(PPI_CH30, 30);
impl_channel!(PPI_CH31, 31);
// ======================
// groups
@ -249,7 +214,7 @@ impl_group!(PPI_GROUP0, 0);
impl_group!(PPI_GROUP1, 1);
impl_group!(PPI_GROUP2, 2);
impl_group!(PPI_GROUP3, 3);
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
impl_group!(PPI_GROUP4, 4);
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
impl_group!(PPI_GROUP5, 5);

View File

@ -1,3 +1,5 @@
#![macro_use]
use core::marker::PhantomData;
use core::sync::atomic::{compiler_fence, Ordering};
use core::task::Poll;
@ -231,45 +233,12 @@ pub trait Input {
fn channel(&self) -> InputChannel;
}
macro_rules! input_mappings {
( $($ch:ident => $input:ident,)*) => {
$(
impl Input for crate::peripherals::$input {
fn channel(&self) -> InputChannel {
InputChannel::$ch
}
macro_rules! impl_saadc_input {
($pin:ident, $ch:ident) => {
impl crate::saadc::Input for crate::peripherals::$pin {
fn channel(&self) -> crate::saadc::InputChannel {
crate::saadc::InputChannel::$ch
}
)*
}
};
}
// TODO the variant names are unchecked
// the inputs are copied from nrf hal
#[cfg(feature = "nrf9160")]
input_mappings! {
ANALOGINPUT0 => P0_13,
ANALOGINPUT1 => P0_14,
ANALOGINPUT2 => P0_15,
ANALOGINPUT3 => P0_16,
ANALOGINPUT4 => P0_17,
ANALOGINPUT5 => P0_18,
ANALOGINPUT6 => P0_19,
ANALOGINPUT7 => P0_20,
}
#[cfg(feature = "nrf52805")]
input_mappings! {
ANALOGINPUT2 => P0_04,
ANALOGINPUT3 => P0_05,
}
#[cfg(not(any(feature = "nrf52805", feature = "nrf9160")))]
input_mappings! {
ANALOGINPUT0 => P0_02,
ANALOGINPUT1 => P0_03,
ANALOGINPUT2 => P0_04,
ANALOGINPUT3 => P0_05,
ANALOGINPUT4 => P0_28,
ANALOGINPUT5 => P0_29,
ANALOGINPUT6 => P0_30,
ANALOGINPUT7 => P0_31,
}

View File

@ -8,7 +8,7 @@ pub(crate) fn slice_in_ram(slice: &[u8]) -> bool {
}
/// Return an error if slice is not in RAM.
#[cfg(not(feature = "51"))]
#[cfg(not(feature = "nrf51"))]
pub(crate) fn slice_in_ram_or<T>(slice: &[u8], err: T) -> Result<(), T> {
if slice.len() == 0 || slice_in_ram(slice) {
Ok(())