diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-10-11 01:22:01 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-10-11 01:36:31 +0200 |
| commit | 14c3260d88b95a7354dd1d0686d113602e25becb (patch) | |
| tree | 101f0eb13eb69ad1b77eeda221e4de71058d9c03 | |
| parent | cf13dd7df860afeb9bccee2ca64004f0ac3643d2 (diff) | |
nrf/saadc: move chip-specific mappings to chips/
| -rw-r--r-- | embassy-nrf/src/chips/nrf52805.rs | 3 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52810.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52811.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52832.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52833.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf52840.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 47 |
7 files changed, 56 insertions, 39 deletions
diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index 3bf87e3d9..db1fac2ff 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs | |||
| @@ -182,6 +182,9 @@ impl_ppi_channel!(PPI_CH29, 29); | |||
| 182 | impl_ppi_channel!(PPI_CH30, 30); | 182 | impl_ppi_channel!(PPI_CH30, 30); |
| 183 | impl_ppi_channel!(PPI_CH31, 31); | 183 | impl_ppi_channel!(PPI_CH31, 31); |
| 184 | 184 | ||
| 185 | impl_saadc_input!(P0_04, ANALOGINPUT2); | ||
| 186 | impl_saadc_input!(P0_05, ANALOGINPUT3); | ||
| 187 | |||
| 185 | pub mod irqs { | 188 | pub mod irqs { |
| 186 | use crate::pac::Interrupt as InterruptEnum; | 189 | use crate::pac::Interrupt as InterruptEnum; |
| 187 | use embassy_macros::interrupt_declare as declare; | 190 | use embassy_macros::interrupt_declare as declare; |
diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index d3241364b..06b9bfb38 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs | |||
| @@ -197,6 +197,15 @@ impl_ppi_channel!(PPI_CH29, 29); | |||
| 197 | impl_ppi_channel!(PPI_CH30, 30); | 197 | impl_ppi_channel!(PPI_CH30, 30); |
| 198 | impl_ppi_channel!(PPI_CH31, 31); | 198 | impl_ppi_channel!(PPI_CH31, 31); |
| 199 | 199 | ||
| 200 | impl_saadc_input!(P0_02, ANALOGINPUT0); | ||
| 201 | impl_saadc_input!(P0_03, ANALOGINPUT1); | ||
| 202 | impl_saadc_input!(P0_04, ANALOGINPUT2); | ||
| 203 | impl_saadc_input!(P0_05, ANALOGINPUT3); | ||
| 204 | impl_saadc_input!(P0_28, ANALOGINPUT4); | ||
| 205 | impl_saadc_input!(P0_29, ANALOGINPUT5); | ||
| 206 | impl_saadc_input!(P0_30, ANALOGINPUT6); | ||
| 207 | impl_saadc_input!(P0_31, ANALOGINPUT7); | ||
| 208 | |||
| 200 | pub mod irqs { | 209 | pub mod irqs { |
| 201 | use crate::pac::Interrupt as InterruptEnum; | 210 | use crate::pac::Interrupt as InterruptEnum; |
| 202 | use embassy_macros::interrupt_declare as declare; | 211 | use embassy_macros::interrupt_declare as declare; |
diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index 1231ae62b..2f8d98b31 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs | |||
| @@ -198,6 +198,15 @@ impl_ppi_channel!(PPI_CH29, 29); | |||
| 198 | impl_ppi_channel!(PPI_CH30, 30); | 198 | impl_ppi_channel!(PPI_CH30, 30); |
| 199 | impl_ppi_channel!(PPI_CH31, 31); | 199 | impl_ppi_channel!(PPI_CH31, 31); |
| 200 | 200 | ||
| 201 | impl_saadc_input!(P0_02, ANALOGINPUT0); | ||
| 202 | impl_saadc_input!(P0_03, ANALOGINPUT1); | ||
| 203 | impl_saadc_input!(P0_04, ANALOGINPUT2); | ||
| 204 | impl_saadc_input!(P0_05, ANALOGINPUT3); | ||
| 205 | impl_saadc_input!(P0_28, ANALOGINPUT4); | ||
| 206 | impl_saadc_input!(P0_29, ANALOGINPUT5); | ||
| 207 | impl_saadc_input!(P0_30, ANALOGINPUT6); | ||
| 208 | impl_saadc_input!(P0_31, ANALOGINPUT7); | ||
| 209 | |||
| 201 | pub mod irqs { | 210 | pub mod irqs { |
| 202 | use crate::pac::Interrupt as InterruptEnum; | 211 | use crate::pac::Interrupt as InterruptEnum; |
| 203 | use embassy_macros::interrupt_declare as declare; | 212 | use embassy_macros::interrupt_declare as declare; |
diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index 9bbef5438..47cf27de4 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs | |||
| @@ -211,6 +211,15 @@ impl_ppi_channel!(PPI_CH29, 29); | |||
| 211 | impl_ppi_channel!(PPI_CH30, 30); | 211 | impl_ppi_channel!(PPI_CH30, 30); |
| 212 | impl_ppi_channel!(PPI_CH31, 31); | 212 | impl_ppi_channel!(PPI_CH31, 31); |
| 213 | 213 | ||
| 214 | impl_saadc_input!(P0_02, ANALOGINPUT0); | ||
| 215 | impl_saadc_input!(P0_03, ANALOGINPUT1); | ||
| 216 | impl_saadc_input!(P0_04, ANALOGINPUT2); | ||
| 217 | impl_saadc_input!(P0_05, ANALOGINPUT3); | ||
| 218 | impl_saadc_input!(P0_28, ANALOGINPUT4); | ||
| 219 | impl_saadc_input!(P0_29, ANALOGINPUT5); | ||
| 220 | impl_saadc_input!(P0_30, ANALOGINPUT6); | ||
| 221 | impl_saadc_input!(P0_31, ANALOGINPUT7); | ||
| 222 | |||
| 214 | pub mod irqs { | 223 | pub mod irqs { |
| 215 | use crate::pac::Interrupt as InterruptEnum; | 224 | use crate::pac::Interrupt as InterruptEnum; |
| 216 | use embassy_macros::interrupt_declare as declare; | 225 | use embassy_macros::interrupt_declare as declare; |
diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index d9495dd94..b3d813e24 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs | |||
| @@ -251,6 +251,15 @@ impl_ppi_channel!(PPI_CH29, 29); | |||
| 251 | impl_ppi_channel!(PPI_CH30, 30); | 251 | impl_ppi_channel!(PPI_CH30, 30); |
| 252 | impl_ppi_channel!(PPI_CH31, 31); | 252 | impl_ppi_channel!(PPI_CH31, 31); |
| 253 | 253 | ||
| 254 | impl_saadc_input!(P0_02, ANALOGINPUT0); | ||
| 255 | impl_saadc_input!(P0_03, ANALOGINPUT1); | ||
| 256 | impl_saadc_input!(P0_04, ANALOGINPUT2); | ||
| 257 | impl_saadc_input!(P0_05, ANALOGINPUT3); | ||
| 258 | impl_saadc_input!(P0_28, ANALOGINPUT4); | ||
| 259 | impl_saadc_input!(P0_29, ANALOGINPUT5); | ||
| 260 | impl_saadc_input!(P0_30, ANALOGINPUT6); | ||
| 261 | impl_saadc_input!(P0_31, ANALOGINPUT7); | ||
| 262 | |||
| 254 | pub mod irqs { | 263 | pub mod irqs { |
| 255 | use crate::pac::Interrupt as InterruptEnum; | 264 | use crate::pac::Interrupt as InterruptEnum; |
| 256 | use embassy_macros::interrupt_declare as declare; | 265 | use embassy_macros::interrupt_declare as declare; |
diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index ad89afbca..473036f61 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs | |||
| @@ -256,6 +256,15 @@ impl_ppi_channel!(PPI_CH29, 29); | |||
| 256 | impl_ppi_channel!(PPI_CH30, 30); | 256 | impl_ppi_channel!(PPI_CH30, 30); |
| 257 | impl_ppi_channel!(PPI_CH31, 31); | 257 | impl_ppi_channel!(PPI_CH31, 31); |
| 258 | 258 | ||
| 259 | impl_saadc_input!(P0_02, ANALOGINPUT0); | ||
| 260 | impl_saadc_input!(P0_03, ANALOGINPUT1); | ||
| 261 | impl_saadc_input!(P0_04, ANALOGINPUT2); | ||
| 262 | impl_saadc_input!(P0_05, ANALOGINPUT3); | ||
| 263 | impl_saadc_input!(P0_28, ANALOGINPUT4); | ||
| 264 | impl_saadc_input!(P0_29, ANALOGINPUT5); | ||
| 265 | impl_saadc_input!(P0_30, ANALOGINPUT6); | ||
| 266 | impl_saadc_input!(P0_31, ANALOGINPUT7); | ||
| 267 | |||
| 259 | pub mod irqs { | 268 | pub mod irqs { |
| 260 | use crate::pac::Interrupt as InterruptEnum; | 269 | use crate::pac::Interrupt as InterruptEnum; |
| 261 | use embassy_macros::interrupt_declare as declare; | 270 | use embassy_macros::interrupt_declare as declare; |
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index 2f2baefae..2ce7ef16d 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | #![macro_use] | ||
| 2 | |||
| 1 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 2 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 3 | use core::task::Poll; | 5 | use core::task::Poll; |
| @@ -231,45 +233,12 @@ pub trait Input { | |||
| 231 | fn channel(&self) -> InputChannel; | 233 | fn channel(&self) -> InputChannel; |
| 232 | } | 234 | } |
| 233 | 235 | ||
| 234 | macro_rules! input_mappings { | 236 | macro_rules! impl_saadc_input { |
| 235 | ( $($ch:ident => $input:ident,)*) => { | 237 | ($pin:ident, $ch:ident) => { |
| 236 | $( | 238 | impl crate::saadc::Input for crate::peripherals::$pin { |
| 237 | impl Input for crate::peripherals::$input { | 239 | fn channel(&self) -> crate::saadc::InputChannel { |
| 238 | fn channel(&self) -> InputChannel { | 240 | crate::saadc::InputChannel::$ch |
| 239 | InputChannel::$ch | ||
| 240 | } | ||
| 241 | } | 241 | } |
| 242 | )* | 242 | } |
| 243 | }; | 243 | }; |
| 244 | } | 244 | } |
| 245 | |||
| 246 | // TODO the variant names are unchecked | ||
| 247 | // the inputs are copied from nrf hal | ||
| 248 | #[cfg(feature = "nrf9160")] | ||
| 249 | input_mappings! { | ||
| 250 | ANALOGINPUT0 => P0_13, | ||
| 251 | ANALOGINPUT1 => P0_14, | ||
| 252 | ANALOGINPUT2 => P0_15, | ||
| 253 | ANALOGINPUT3 => P0_16, | ||
| 254 | ANALOGINPUT4 => P0_17, | ||
| 255 | ANALOGINPUT5 => P0_18, | ||
| 256 | ANALOGINPUT6 => P0_19, | ||
| 257 | ANALOGINPUT7 => P0_20, | ||
| 258 | } | ||
| 259 | #[cfg(feature = "nrf52805")] | ||
| 260 | input_mappings! { | ||
| 261 | ANALOGINPUT2 => P0_04, | ||
| 262 | ANALOGINPUT3 => P0_05, | ||
| 263 | } | ||
| 264 | |||
| 265 | #[cfg(not(any(feature = "nrf52805", feature = "nrf9160")))] | ||
| 266 | input_mappings! { | ||
| 267 | ANALOGINPUT0 => P0_02, | ||
| 268 | ANALOGINPUT1 => P0_03, | ||
| 269 | ANALOGINPUT2 => P0_04, | ||
| 270 | ANALOGINPUT3 => P0_05, | ||
| 271 | ANALOGINPUT4 => P0_28, | ||
| 272 | ANALOGINPUT5 => P0_29, | ||
| 273 | ANALOGINPUT6 => P0_30, | ||
| 274 | ANALOGINPUT7 => P0_31, | ||
| 275 | } | ||
