nrf/saadc: move chip-specific mappings to chips/

This commit is contained in:
Dario Nieuwenhuis 2021-10-11 01:22:01 +02:00
parent cf13dd7df8
commit 14c3260d88
7 changed files with 56 additions and 39 deletions

View file

@ -182,6 +182,9 @@ 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

@ -197,6 +197,15 @@ 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

@ -198,6 +198,15 @@ 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

@ -211,6 +211,15 @@ 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

@ -251,6 +251,15 @@ 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

@ -256,6 +256,15 @@ 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

@ -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,
}