nrf/saadc: move chip-specific mappings to chips/
This commit is contained in:
parent
cf13dd7df8
commit
14c3260d88
7 changed files with 56 additions and 39 deletions
|
@ -182,6 +182,9 @@ impl_ppi_channel!(PPI_CH29, 29);
|
||||||
impl_ppi_channel!(PPI_CH30, 30);
|
impl_ppi_channel!(PPI_CH30, 30);
|
||||||
impl_ppi_channel!(PPI_CH31, 31);
|
impl_ppi_channel!(PPI_CH31, 31);
|
||||||
|
|
||||||
|
impl_saadc_input!(P0_04, ANALOGINPUT2);
|
||||||
|
impl_saadc_input!(P0_05, ANALOGINPUT3);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
use embassy_macros::interrupt_declare as declare;
|
use embassy_macros::interrupt_declare as declare;
|
||||||
|
|
|
@ -197,6 +197,15 @@ impl_ppi_channel!(PPI_CH29, 29);
|
||||||
impl_ppi_channel!(PPI_CH30, 30);
|
impl_ppi_channel!(PPI_CH30, 30);
|
||||||
impl_ppi_channel!(PPI_CH31, 31);
|
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 {
|
pub mod irqs {
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
use embassy_macros::interrupt_declare as declare;
|
use embassy_macros::interrupt_declare as declare;
|
||||||
|
|
|
@ -198,6 +198,15 @@ impl_ppi_channel!(PPI_CH29, 29);
|
||||||
impl_ppi_channel!(PPI_CH30, 30);
|
impl_ppi_channel!(PPI_CH30, 30);
|
||||||
impl_ppi_channel!(PPI_CH31, 31);
|
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 {
|
pub mod irqs {
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
use embassy_macros::interrupt_declare as declare;
|
use embassy_macros::interrupt_declare as declare;
|
||||||
|
|
|
@ -211,6 +211,15 @@ impl_ppi_channel!(PPI_CH29, 29);
|
||||||
impl_ppi_channel!(PPI_CH30, 30);
|
impl_ppi_channel!(PPI_CH30, 30);
|
||||||
impl_ppi_channel!(PPI_CH31, 31);
|
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 {
|
pub mod irqs {
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
use embassy_macros::interrupt_declare as declare;
|
use embassy_macros::interrupt_declare as declare;
|
||||||
|
|
|
@ -251,6 +251,15 @@ impl_ppi_channel!(PPI_CH29, 29);
|
||||||
impl_ppi_channel!(PPI_CH30, 30);
|
impl_ppi_channel!(PPI_CH30, 30);
|
||||||
impl_ppi_channel!(PPI_CH31, 31);
|
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 {
|
pub mod irqs {
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
use embassy_macros::interrupt_declare as declare;
|
use embassy_macros::interrupt_declare as declare;
|
||||||
|
|
|
@ -256,6 +256,15 @@ impl_ppi_channel!(PPI_CH29, 29);
|
||||||
impl_ppi_channel!(PPI_CH30, 30);
|
impl_ppi_channel!(PPI_CH30, 30);
|
||||||
impl_ppi_channel!(PPI_CH31, 31);
|
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 {
|
pub mod irqs {
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
use embassy_macros::interrupt_declare as declare;
|
use embassy_macros::interrupt_declare as declare;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![macro_use]
|
||||||
|
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use core::sync::atomic::{compiler_fence, Ordering};
|
use core::sync::atomic::{compiler_fence, Ordering};
|
||||||
use core::task::Poll;
|
use core::task::Poll;
|
||||||
|
@ -231,45 +233,12 @@ pub trait Input {
|
||||||
fn channel(&self) -> InputChannel;
|
fn channel(&self) -> InputChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! input_mappings {
|
macro_rules! impl_saadc_input {
|
||||||
( $($ch:ident => $input:ident,)*) => {
|
($pin:ident, $ch:ident) => {
|
||||||
$(
|
impl crate::saadc::Input for crate::peripherals::$pin {
|
||||||
impl Input for crate::peripherals::$input {
|
fn channel(&self) -> crate::saadc::InputChannel {
|
||||||
fn channel(&self) -> InputChannel {
|
crate::saadc::InputChannel::$ch
|
||||||
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,
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue