aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-10-11 01:42:28 +0200
committerGitHub <[email protected]>2021-10-11 01:42:28 +0200
commit9fec833015579cca5f1b398745cac7ad08245f0c (patch)
tree101f0eb13eb69ad1b77eeda221e4de71058d9c03
parent34637bf2d0e7d01003607521cf91c26317f7094c (diff)
parent14c3260d88b95a7354dd1d0686d113602e25becb (diff)
Merge pull request #419 from embassy-rs/nrf-fixes-2
Nrf fixes 2
-rw-r--r--embassy-nrf/src/chips/nrf52805.rs26
-rw-r--r--embassy-nrf/src/chips/nrf52810.rs42
-rw-r--r--embassy-nrf/src/chips/nrf52811.rs42
-rw-r--r--embassy-nrf/src/chips/nrf52820.rs33
-rw-r--r--embassy-nrf/src/chips/nrf52832.rs42
-rw-r--r--embassy-nrf/src/chips/nrf52833.rs42
-rw-r--r--embassy-nrf/src/chips/nrf52840.rs42
-rw-r--r--embassy-nrf/src/gpiote.rs8
-rw-r--r--embassy-nrf/src/ppi.rs63
-rw-r--r--embassy-nrf/src/saadc.rs47
-rw-r--r--embassy-nrf/src/util.rs2
11 files changed, 296 insertions, 93 deletions
diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs
index f214d927b..db1fac2ff 100644
--- a/embassy-nrf/src/chips/nrf52805.rs
+++ b/embassy-nrf/src/chips/nrf52805.rs
@@ -159,6 +159,32 @@ impl_pin!(P0_29, 0, 29);
159impl_pin!(P0_30, 0, 30); 159impl_pin!(P0_30, 0, 30);
160impl_pin!(P0_31, 0, 31); 160impl_pin!(P0_31, 0, 31);
161 161
162impl_ppi_channel!(PPI_CH0, 0, configurable);
163impl_ppi_channel!(PPI_CH1, 1, configurable);
164impl_ppi_channel!(PPI_CH2, 2, configurable);
165impl_ppi_channel!(PPI_CH3, 3, configurable);
166impl_ppi_channel!(PPI_CH4, 4, configurable);
167impl_ppi_channel!(PPI_CH5, 5, configurable);
168impl_ppi_channel!(PPI_CH6, 6, configurable);
169impl_ppi_channel!(PPI_CH7, 7, configurable);
170impl_ppi_channel!(PPI_CH8, 8, configurable);
171impl_ppi_channel!(PPI_CH9, 9, configurable);
172impl_ppi_channel!(PPI_CH20, 20);
173impl_ppi_channel!(PPI_CH21, 21);
174impl_ppi_channel!(PPI_CH22, 22);
175impl_ppi_channel!(PPI_CH23, 23);
176impl_ppi_channel!(PPI_CH24, 24);
177impl_ppi_channel!(PPI_CH25, 25);
178impl_ppi_channel!(PPI_CH26, 26);
179impl_ppi_channel!(PPI_CH27, 27);
180impl_ppi_channel!(PPI_CH28, 28);
181impl_ppi_channel!(PPI_CH29, 29);
182impl_ppi_channel!(PPI_CH30, 30);
183impl_ppi_channel!(PPI_CH31, 31);
184
185impl_saadc_input!(P0_04, ANALOGINPUT2);
186impl_saadc_input!(P0_05, ANALOGINPUT3);
187
162pub mod irqs { 188pub mod irqs {
163 use crate::pac::Interrupt as InterruptEnum; 189 use crate::pac::Interrupt as InterruptEnum;
164 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 caef3e7e7..06b9bfb38 100644
--- a/embassy-nrf/src/chips/nrf52810.rs
+++ b/embassy-nrf/src/chips/nrf52810.rs
@@ -164,6 +164,48 @@ impl_pin!(P0_29, 0, 29);
164impl_pin!(P0_30, 0, 30); 164impl_pin!(P0_30, 0, 30);
165impl_pin!(P0_31, 0, 31); 165impl_pin!(P0_31, 0, 31);
166 166
167impl_ppi_channel!(PPI_CH0, 0, configurable);
168impl_ppi_channel!(PPI_CH1, 1, configurable);
169impl_ppi_channel!(PPI_CH2, 2, configurable);
170impl_ppi_channel!(PPI_CH3, 3, configurable);
171impl_ppi_channel!(PPI_CH4, 4, configurable);
172impl_ppi_channel!(PPI_CH5, 5, configurable);
173impl_ppi_channel!(PPI_CH6, 6, configurable);
174impl_ppi_channel!(PPI_CH7, 7, configurable);
175impl_ppi_channel!(PPI_CH8, 8, configurable);
176impl_ppi_channel!(PPI_CH9, 9, configurable);
177impl_ppi_channel!(PPI_CH10, 10, configurable);
178impl_ppi_channel!(PPI_CH11, 11, configurable);
179impl_ppi_channel!(PPI_CH12, 12, configurable);
180impl_ppi_channel!(PPI_CH13, 13, configurable);
181impl_ppi_channel!(PPI_CH14, 14, configurable);
182impl_ppi_channel!(PPI_CH15, 15, configurable);
183impl_ppi_channel!(PPI_CH16, 16, configurable);
184impl_ppi_channel!(PPI_CH17, 17, configurable);
185impl_ppi_channel!(PPI_CH18, 18, configurable);
186impl_ppi_channel!(PPI_CH19, 19, configurable);
187impl_ppi_channel!(PPI_CH20, 20);
188impl_ppi_channel!(PPI_CH21, 21);
189impl_ppi_channel!(PPI_CH22, 22);
190impl_ppi_channel!(PPI_CH23, 23);
191impl_ppi_channel!(PPI_CH24, 24);
192impl_ppi_channel!(PPI_CH25, 25);
193impl_ppi_channel!(PPI_CH26, 26);
194impl_ppi_channel!(PPI_CH27, 27);
195impl_ppi_channel!(PPI_CH28, 28);
196impl_ppi_channel!(PPI_CH29, 29);
197impl_ppi_channel!(PPI_CH30, 30);
198impl_ppi_channel!(PPI_CH31, 31);
199
200impl_saadc_input!(P0_02, ANALOGINPUT0);
201impl_saadc_input!(P0_03, ANALOGINPUT1);
202impl_saadc_input!(P0_04, ANALOGINPUT2);
203impl_saadc_input!(P0_05, ANALOGINPUT3);
204impl_saadc_input!(P0_28, ANALOGINPUT4);
205impl_saadc_input!(P0_29, ANALOGINPUT5);
206impl_saadc_input!(P0_30, ANALOGINPUT6);
207impl_saadc_input!(P0_31, ANALOGINPUT7);
208
167pub mod irqs { 209pub mod irqs {
168 use crate::pac::Interrupt as InterruptEnum; 210 use crate::pac::Interrupt as InterruptEnum;
169 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 cbf14df2a..2f8d98b31 100644
--- a/embassy-nrf/src/chips/nrf52811.rs
+++ b/embassy-nrf/src/chips/nrf52811.rs
@@ -165,6 +165,48 @@ impl_pin!(P0_29, 0, 29);
165impl_pin!(P0_30, 0, 30); 165impl_pin!(P0_30, 0, 30);
166impl_pin!(P0_31, 0, 31); 166impl_pin!(P0_31, 0, 31);
167 167
168impl_ppi_channel!(PPI_CH0, 0, configurable);
169impl_ppi_channel!(PPI_CH1, 1, configurable);
170impl_ppi_channel!(PPI_CH2, 2, configurable);
171impl_ppi_channel!(PPI_CH3, 3, configurable);
172impl_ppi_channel!(PPI_CH4, 4, configurable);
173impl_ppi_channel!(PPI_CH5, 5, configurable);
174impl_ppi_channel!(PPI_CH6, 6, configurable);
175impl_ppi_channel!(PPI_CH7, 7, configurable);
176impl_ppi_channel!(PPI_CH8, 8, configurable);
177impl_ppi_channel!(PPI_CH9, 9, configurable);
178impl_ppi_channel!(PPI_CH10, 10, configurable);
179impl_ppi_channel!(PPI_CH11, 11, configurable);
180impl_ppi_channel!(PPI_CH12, 12, configurable);
181impl_ppi_channel!(PPI_CH13, 13, configurable);
182impl_ppi_channel!(PPI_CH14, 14, configurable);
183impl_ppi_channel!(PPI_CH15, 15, configurable);
184impl_ppi_channel!(PPI_CH16, 16, configurable);
185impl_ppi_channel!(PPI_CH17, 17, configurable);
186impl_ppi_channel!(PPI_CH18, 18, configurable);
187impl_ppi_channel!(PPI_CH19, 19, configurable);
188impl_ppi_channel!(PPI_CH20, 20);
189impl_ppi_channel!(PPI_CH21, 21);
190impl_ppi_channel!(PPI_CH22, 22);
191impl_ppi_channel!(PPI_CH23, 23);
192impl_ppi_channel!(PPI_CH24, 24);
193impl_ppi_channel!(PPI_CH25, 25);
194impl_ppi_channel!(PPI_CH26, 26);
195impl_ppi_channel!(PPI_CH27, 27);
196impl_ppi_channel!(PPI_CH28, 28);
197impl_ppi_channel!(PPI_CH29, 29);
198impl_ppi_channel!(PPI_CH30, 30);
199impl_ppi_channel!(PPI_CH31, 31);
200
201impl_saadc_input!(P0_02, ANALOGINPUT0);
202impl_saadc_input!(P0_03, ANALOGINPUT1);
203impl_saadc_input!(P0_04, ANALOGINPUT2);
204impl_saadc_input!(P0_05, ANALOGINPUT3);
205impl_saadc_input!(P0_28, ANALOGINPUT4);
206impl_saadc_input!(P0_29, ANALOGINPUT5);
207impl_saadc_input!(P0_30, ANALOGINPUT6);
208impl_saadc_input!(P0_31, ANALOGINPUT7);
209
168pub mod irqs { 210pub mod irqs {
169 use crate::pac::Interrupt as InterruptEnum; 211 use crate::pac::Interrupt as InterruptEnum;
170 use embassy_macros::interrupt_declare as declare; 212 use embassy_macros::interrupt_declare as declare;
diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs
index e434c0096..fc7a367ef 100644
--- a/embassy-nrf/src/chips/nrf52820.rs
+++ b/embassy-nrf/src/chips/nrf52820.rs
@@ -160,6 +160,39 @@ impl_pin!(P0_29, 0, 29);
160impl_pin!(P0_30, 0, 30); 160impl_pin!(P0_30, 0, 30);
161impl_pin!(P0_31, 0, 31); 161impl_pin!(P0_31, 0, 31);
162 162
163impl_ppi_channel!(PPI_CH0, 0, configurable);
164impl_ppi_channel!(PPI_CH1, 1, configurable);
165impl_ppi_channel!(PPI_CH2, 2, configurable);
166impl_ppi_channel!(PPI_CH3, 3, configurable);
167impl_ppi_channel!(PPI_CH4, 4, configurable);
168impl_ppi_channel!(PPI_CH5, 5, configurable);
169impl_ppi_channel!(PPI_CH6, 6, configurable);
170impl_ppi_channel!(PPI_CH7, 7, configurable);
171impl_ppi_channel!(PPI_CH8, 8, configurable);
172impl_ppi_channel!(PPI_CH9, 9, configurable);
173impl_ppi_channel!(PPI_CH10, 10, configurable);
174impl_ppi_channel!(PPI_CH11, 11, configurable);
175impl_ppi_channel!(PPI_CH12, 12, configurable);
176impl_ppi_channel!(PPI_CH13, 13, configurable);
177impl_ppi_channel!(PPI_CH14, 14, configurable);
178impl_ppi_channel!(PPI_CH15, 15, configurable);
179impl_ppi_channel!(PPI_CH16, 16, configurable);
180impl_ppi_channel!(PPI_CH17, 17, configurable);
181impl_ppi_channel!(PPI_CH18, 18, configurable);
182impl_ppi_channel!(PPI_CH19, 19, configurable);
183impl_ppi_channel!(PPI_CH20, 20);
184impl_ppi_channel!(PPI_CH21, 21);
185impl_ppi_channel!(PPI_CH22, 22);
186impl_ppi_channel!(PPI_CH23, 23);
187impl_ppi_channel!(PPI_CH24, 24);
188impl_ppi_channel!(PPI_CH25, 25);
189impl_ppi_channel!(PPI_CH26, 26);
190impl_ppi_channel!(PPI_CH27, 27);
191impl_ppi_channel!(PPI_CH28, 28);
192impl_ppi_channel!(PPI_CH29, 29);
193impl_ppi_channel!(PPI_CH30, 30);
194impl_ppi_channel!(PPI_CH31, 31);
195
163pub mod irqs { 196pub mod irqs {
164 use crate::pac::Interrupt as InterruptEnum; 197 use crate::pac::Interrupt as InterruptEnum;
165 use embassy_macros::interrupt_declare as declare; 198 use embassy_macros::interrupt_declare as declare;
diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs
index b95aa604b..47cf27de4 100644
--- a/embassy-nrf/src/chips/nrf52832.rs
+++ b/embassy-nrf/src/chips/nrf52832.rs
@@ -178,6 +178,48 @@ impl_pin!(P0_29, 0, 29);
178impl_pin!(P0_30, 0, 30); 178impl_pin!(P0_30, 0, 30);
179impl_pin!(P0_31, 0, 31); 179impl_pin!(P0_31, 0, 31);
180 180
181impl_ppi_channel!(PPI_CH0, 0, configurable);
182impl_ppi_channel!(PPI_CH1, 1, configurable);
183impl_ppi_channel!(PPI_CH2, 2, configurable);
184impl_ppi_channel!(PPI_CH3, 3, configurable);
185impl_ppi_channel!(PPI_CH4, 4, configurable);
186impl_ppi_channel!(PPI_CH5, 5, configurable);
187impl_ppi_channel!(PPI_CH6, 6, configurable);
188impl_ppi_channel!(PPI_CH7, 7, configurable);
189impl_ppi_channel!(PPI_CH8, 8, configurable);
190impl_ppi_channel!(PPI_CH9, 9, configurable);
191impl_ppi_channel!(PPI_CH10, 10, configurable);
192impl_ppi_channel!(PPI_CH11, 11, configurable);
193impl_ppi_channel!(PPI_CH12, 12, configurable);
194impl_ppi_channel!(PPI_CH13, 13, configurable);
195impl_ppi_channel!(PPI_CH14, 14, configurable);
196impl_ppi_channel!(PPI_CH15, 15, configurable);
197impl_ppi_channel!(PPI_CH16, 16, configurable);
198impl_ppi_channel!(PPI_CH17, 17, configurable);
199impl_ppi_channel!(PPI_CH18, 18, configurable);
200impl_ppi_channel!(PPI_CH19, 19, configurable);
201impl_ppi_channel!(PPI_CH20, 20);
202impl_ppi_channel!(PPI_CH21, 21);
203impl_ppi_channel!(PPI_CH22, 22);
204impl_ppi_channel!(PPI_CH23, 23);
205impl_ppi_channel!(PPI_CH24, 24);
206impl_ppi_channel!(PPI_CH25, 25);
207impl_ppi_channel!(PPI_CH26, 26);
208impl_ppi_channel!(PPI_CH27, 27);
209impl_ppi_channel!(PPI_CH28, 28);
210impl_ppi_channel!(PPI_CH29, 29);
211impl_ppi_channel!(PPI_CH30, 30);
212impl_ppi_channel!(PPI_CH31, 31);
213
214impl_saadc_input!(P0_02, ANALOGINPUT0);
215impl_saadc_input!(P0_03, ANALOGINPUT1);
216impl_saadc_input!(P0_04, ANALOGINPUT2);
217impl_saadc_input!(P0_05, ANALOGINPUT3);
218impl_saadc_input!(P0_28, ANALOGINPUT4);
219impl_saadc_input!(P0_29, ANALOGINPUT5);
220impl_saadc_input!(P0_30, ANALOGINPUT6);
221impl_saadc_input!(P0_31, ANALOGINPUT7);
222
181pub mod irqs { 223pub mod irqs {
182 use crate::pac::Interrupt as InterruptEnum; 224 use crate::pac::Interrupt as InterruptEnum;
183 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 570e4b103..b3d813e24 100644
--- a/embassy-nrf/src/chips/nrf52833.rs
+++ b/embassy-nrf/src/chips/nrf52833.rs
@@ -218,6 +218,48 @@ impl_pin!(P1_13, 1, 13);
218impl_pin!(P1_14, 1, 14); 218impl_pin!(P1_14, 1, 14);
219impl_pin!(P1_15, 1, 15); 219impl_pin!(P1_15, 1, 15);
220 220
221impl_ppi_channel!(PPI_CH0, 0, configurable);
222impl_ppi_channel!(PPI_CH1, 1, configurable);
223impl_ppi_channel!(PPI_CH2, 2, configurable);
224impl_ppi_channel!(PPI_CH3, 3, configurable);
225impl_ppi_channel!(PPI_CH4, 4, configurable);
226impl_ppi_channel!(PPI_CH5, 5, configurable);
227impl_ppi_channel!(PPI_CH6, 6, configurable);
228impl_ppi_channel!(PPI_CH7, 7, configurable);
229impl_ppi_channel!(PPI_CH8, 8, configurable);
230impl_ppi_channel!(PPI_CH9, 9, configurable);
231impl_ppi_channel!(PPI_CH10, 10, configurable);
232impl_ppi_channel!(PPI_CH11, 11, configurable);
233impl_ppi_channel!(PPI_CH12, 12, configurable);
234impl_ppi_channel!(PPI_CH13, 13, configurable);
235impl_ppi_channel!(PPI_CH14, 14, configurable);
236impl_ppi_channel!(PPI_CH15, 15, configurable);
237impl_ppi_channel!(PPI_CH16, 16, configurable);
238impl_ppi_channel!(PPI_CH17, 17, configurable);
239impl_ppi_channel!(PPI_CH18, 18, configurable);
240impl_ppi_channel!(PPI_CH19, 19, configurable);
241impl_ppi_channel!(PPI_CH20, 20);
242impl_ppi_channel!(PPI_CH21, 21);
243impl_ppi_channel!(PPI_CH22, 22);
244impl_ppi_channel!(PPI_CH23, 23);
245impl_ppi_channel!(PPI_CH24, 24);
246impl_ppi_channel!(PPI_CH25, 25);
247impl_ppi_channel!(PPI_CH26, 26);
248impl_ppi_channel!(PPI_CH27, 27);
249impl_ppi_channel!(PPI_CH28, 28);
250impl_ppi_channel!(PPI_CH29, 29);
251impl_ppi_channel!(PPI_CH30, 30);
252impl_ppi_channel!(PPI_CH31, 31);
253
254impl_saadc_input!(P0_02, ANALOGINPUT0);
255impl_saadc_input!(P0_03, ANALOGINPUT1);
256impl_saadc_input!(P0_04, ANALOGINPUT2);
257impl_saadc_input!(P0_05, ANALOGINPUT3);
258impl_saadc_input!(P0_28, ANALOGINPUT4);
259impl_saadc_input!(P0_29, ANALOGINPUT5);
260impl_saadc_input!(P0_30, ANALOGINPUT6);
261impl_saadc_input!(P0_31, ANALOGINPUT7);
262
221pub mod irqs { 263pub mod irqs {
222 use crate::pac::Interrupt as InterruptEnum; 264 use crate::pac::Interrupt as InterruptEnum;
223 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 1221f23b3..473036f61 100644
--- a/embassy-nrf/src/chips/nrf52840.rs
+++ b/embassy-nrf/src/chips/nrf52840.rs
@@ -223,6 +223,48 @@ impl_pin!(P1_13, 1, 13);
223impl_pin!(P1_14, 1, 14); 223impl_pin!(P1_14, 1, 14);
224impl_pin!(P1_15, 1, 15); 224impl_pin!(P1_15, 1, 15);
225 225
226impl_ppi_channel!(PPI_CH0, 0, configurable);
227impl_ppi_channel!(PPI_CH1, 1, configurable);
228impl_ppi_channel!(PPI_CH2, 2, configurable);
229impl_ppi_channel!(PPI_CH3, 3, configurable);
230impl_ppi_channel!(PPI_CH4, 4, configurable);
231impl_ppi_channel!(PPI_CH5, 5, configurable);
232impl_ppi_channel!(PPI_CH6, 6, configurable);
233impl_ppi_channel!(PPI_CH7, 7, configurable);
234impl_ppi_channel!(PPI_CH8, 8, configurable);
235impl_ppi_channel!(PPI_CH9, 9, configurable);
236impl_ppi_channel!(PPI_CH10, 10, configurable);
237impl_ppi_channel!(PPI_CH11, 11, configurable);
238impl_ppi_channel!(PPI_CH12, 12, configurable);
239impl_ppi_channel!(PPI_CH13, 13, configurable);
240impl_ppi_channel!(PPI_CH14, 14, configurable);
241impl_ppi_channel!(PPI_CH15, 15, configurable);
242impl_ppi_channel!(PPI_CH16, 16, configurable);
243impl_ppi_channel!(PPI_CH17, 17, configurable);
244impl_ppi_channel!(PPI_CH18, 18, configurable);
245impl_ppi_channel!(PPI_CH19, 19, configurable);
246impl_ppi_channel!(PPI_CH20, 20);
247impl_ppi_channel!(PPI_CH21, 21);
248impl_ppi_channel!(PPI_CH22, 22);
249impl_ppi_channel!(PPI_CH23, 23);
250impl_ppi_channel!(PPI_CH24, 24);
251impl_ppi_channel!(PPI_CH25, 25);
252impl_ppi_channel!(PPI_CH26, 26);
253impl_ppi_channel!(PPI_CH27, 27);
254impl_ppi_channel!(PPI_CH28, 28);
255impl_ppi_channel!(PPI_CH29, 29);
256impl_ppi_channel!(PPI_CH30, 30);
257impl_ppi_channel!(PPI_CH31, 31);
258
259impl_saadc_input!(P0_02, ANALOGINPUT0);
260impl_saadc_input!(P0_03, ANALOGINPUT1);
261impl_saadc_input!(P0_04, ANALOGINPUT2);
262impl_saadc_input!(P0_05, ANALOGINPUT3);
263impl_saadc_input!(P0_28, ANALOGINPUT4);
264impl_saadc_input!(P0_29, ANALOGINPUT5);
265impl_saadc_input!(P0_30, ANALOGINPUT6);
266impl_saadc_input!(P0_31, ANALOGINPUT7);
267
226pub mod irqs { 268pub mod irqs {
227 use crate::pac::Interrupt as InterruptEnum; 269 use crate::pac::Interrupt as InterruptEnum;
228 use embassy_macros::interrupt_declare as declare; 270 use embassy_macros::interrupt_declare as declare;
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index 001ee7fb8..25d09db4e 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -239,14 +239,14 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> {
239 } 239 }
240 240
241 /// Triggers `task set` (set associated pin high). 241 /// Triggers `task set` (set associated pin high).
242 #[cfg(not(feature = "51"))] 242 #[cfg(not(feature = "nrf51"))]
243 pub fn set(&self) { 243 pub fn set(&self) {
244 let g = unsafe { &*pac::GPIOTE::ptr() }; 244 let g = unsafe { &*pac::GPIOTE::ptr() };
245 g.tasks_set[self.ch.number()].write(|w| unsafe { w.bits(1) }); 245 g.tasks_set[self.ch.number()].write(|w| unsafe { w.bits(1) });
246 } 246 }
247 247
248 /// Triggers `task clear` (set associated pin low). 248 /// Triggers `task clear` (set associated pin low).
249 #[cfg(not(feature = "51"))] 249 #[cfg(not(feature = "nrf51"))]
250 pub fn clear(&self) { 250 pub fn clear(&self) {
251 let g = unsafe { &*pac::GPIOTE::ptr() }; 251 let g = unsafe { &*pac::GPIOTE::ptr() };
252 g.tasks_clr[self.ch.number()].write(|w| unsafe { w.bits(1) }); 252 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> {
259 } 259 }
260 260
261 /// Returns the CLR task, for use with PPI. 261 /// Returns the CLR task, for use with PPI.
262 #[cfg(not(feature = "51"))] 262 #[cfg(not(feature = "nrf51"))]
263 pub fn task_clr(&self) -> Task { 263 pub fn task_clr(&self) -> Task {
264 let g = unsafe { &*pac::GPIOTE::ptr() }; 264 let g = unsafe { &*pac::GPIOTE::ptr() };
265 Task::from_reg(&g.tasks_clr[self.ch.number()]) 265 Task::from_reg(&g.tasks_clr[self.ch.number()])
266 } 266 }
267 267
268 /// Returns the SET task, for use with PPI. 268 /// Returns the SET task, for use with PPI.
269 #[cfg(not(feature = "51"))] 269 #[cfg(not(feature = "nrf51"))]
270 pub fn task_set(&self) -> Task { 270 pub fn task_set(&self) -> Task {
271 let g = unsafe { &*pac::GPIOTE::ptr() }; 271 let g = unsafe { &*pac::GPIOTE::ptr() };
272 Task::from_reg(&g.tasks_set[self.ch.number()]) 272 Task::from_reg(&g.tasks_set[self.ch.number()])
diff --git a/embassy-nrf/src/ppi.rs b/embassy-nrf/src/ppi.rs
index 61028c03a..1b12b1e95 100644
--- a/embassy-nrf/src/ppi.rs
+++ b/embassy-nrf/src/ppi.rs
@@ -1,3 +1,5 @@
1#![macro_use]
2
1//! HAL interface for the PPI peripheral. 3//! HAL interface for the PPI peripheral.
2//! 4//!
3//! The Programmable Peripheral Interconnect interface allows for an autonomous interoperability 5//! The Programmable Peripheral Interconnect interface allows for an autonomous interoperability
@@ -31,7 +33,7 @@ impl<'d, C: Channel> Ppi<'d, C> {
31 ch, 33 ch,
32 phantom: PhantomData, 34 phantom: PhantomData,
33 }; 35 };
34 #[cfg(not(feature = "51"))] 36 #[cfg(not(feature = "nrf51"))]
35 this.clear_fork_task(); 37 this.clear_fork_task();
36 this 38 this
37 } 39 }
@@ -50,7 +52,7 @@ impl<'d, C: Channel> Ppi<'d, C> {
50 .write(|w| unsafe { w.bits(1 << self.ch.number()) }); 52 .write(|w| unsafe { w.bits(1 << self.ch.number()) });
51 } 53 }
52 54
53 #[cfg(not(feature = "51"))] 55 #[cfg(not(feature = "nrf51"))]
54 /// Sets the fork task that must be triggered when the configured event occurs. The user must 56 /// Sets the fork task that must be triggered when the configured event occurs. The user must
55 /// provide a reference to the task. 57 /// provide a reference to the task.
56 pub fn set_fork_task(&mut self, task: Task) { 58 pub fn set_fork_task(&mut self, task: Task) {
@@ -60,7 +62,7 @@ impl<'d, C: Channel> Ppi<'d, C> {
60 .write(|w| unsafe { w.bits(task.0.as_ptr() as u32) }) 62 .write(|w| unsafe { w.bits(task.0.as_ptr() as u32) })
61 } 63 }
62 64
63 #[cfg(not(feature = "51"))] 65 #[cfg(not(feature = "nrf51"))]
64 /// Clear the fork task endpoint. Previously set task will no longer be triggered. 66 /// Clear the fork task endpoint. Previously set task will no longer be triggered.
65 pub fn clear_fork_task(&mut self) { 67 pub fn clear_fork_task(&mut self) {
66 let r = unsafe { &*pac::PPI::ptr() }; 68 let r = unsafe { &*pac::PPI::ptr() };
@@ -109,7 +111,7 @@ impl Event {
109 } 111 }
110} 112}
111 113
112mod sealed { 114pub(crate) mod sealed {
113 pub trait ConfigurableChannel {} 115 pub trait ConfigurableChannel {}
114 pub trait Channel {} 116 pub trait Channel {}
115 pub trait Group {} 117 pub trait Group {}
@@ -167,15 +169,15 @@ impl Channel for AnyConfigurableChannel {
167 } 169 }
168} 170}
169 171
170macro_rules! impl_channel { 172macro_rules! impl_ppi_channel {
171 ($type:ident, $number:expr, configurable) => { 173 ($type:ident, $number:expr, configurable) => {
172 impl_channel!($type, $number); 174 impl_ppi_channel!($type, $number);
173 impl sealed::ConfigurableChannel for peripherals::$type {} 175 impl crate::ppi::sealed::ConfigurableChannel for peripherals::$type {}
174 impl ConfigurableChannel for peripherals::$type {} 176 impl crate::ppi::ConfigurableChannel for peripherals::$type {}
175 }; 177 };
176 ($type:ident, $number:expr) => { 178 ($type:ident, $number:expr) => {
177 impl sealed::Channel for peripherals::$type {} 179 impl crate::ppi::sealed::Channel for peripherals::$type {}
178 impl Channel for peripherals::$type { 180 impl crate::ppi::Channel for peripherals::$type {
179 fn number(&self) -> usize { 181 fn number(&self) -> usize {
180 $number 182 $number
181 } 183 }
@@ -183,43 +185,6 @@ macro_rules! impl_channel {
183 }; 185 };
184} 186}
185 187
186impl_channel!(PPI_CH0, 0, configurable);
187impl_channel!(PPI_CH1, 1, configurable);
188impl_channel!(PPI_CH2, 2, configurable);
189impl_channel!(PPI_CH3, 3, configurable);
190impl_channel!(PPI_CH4, 4, configurable);
191impl_channel!(PPI_CH5, 5, configurable);
192impl_channel!(PPI_CH6, 6, configurable);
193impl_channel!(PPI_CH7, 7, configurable);
194impl_channel!(PPI_CH8, 8, configurable);
195impl_channel!(PPI_CH9, 9, configurable);
196impl_channel!(PPI_CH10, 10, configurable);
197impl_channel!(PPI_CH11, 11, configurable);
198impl_channel!(PPI_CH12, 12, configurable);
199impl_channel!(PPI_CH13, 13, configurable);
200impl_channel!(PPI_CH14, 14, configurable);
201impl_channel!(PPI_CH15, 15, configurable);
202#[cfg(not(feature = "51"))]
203impl_channel!(PPI_CH16, 16, configurable);
204#[cfg(not(feature = "51"))]
205impl_channel!(PPI_CH17, 17, configurable);
206#[cfg(not(feature = "51"))]
207impl_channel!(PPI_CH18, 18, configurable);
208#[cfg(not(feature = "51"))]
209impl_channel!(PPI_CH19, 19, configurable);
210impl_channel!(PPI_CH20, 20);
211impl_channel!(PPI_CH21, 21);
212impl_channel!(PPI_CH22, 22);
213impl_channel!(PPI_CH23, 23);
214impl_channel!(PPI_CH24, 24);
215impl_channel!(PPI_CH25, 25);
216impl_channel!(PPI_CH26, 26);
217impl_channel!(PPI_CH27, 27);
218impl_channel!(PPI_CH28, 28);
219impl_channel!(PPI_CH29, 29);
220impl_channel!(PPI_CH30, 30);
221impl_channel!(PPI_CH31, 31);
222
223// ====================== 188// ======================
224// groups 189// groups
225 190
@@ -249,7 +214,7 @@ impl_group!(PPI_GROUP0, 0);
249impl_group!(PPI_GROUP1, 1); 214impl_group!(PPI_GROUP1, 1);
250impl_group!(PPI_GROUP2, 2); 215impl_group!(PPI_GROUP2, 2);
251impl_group!(PPI_GROUP3, 3); 216impl_group!(PPI_GROUP3, 3);
252#[cfg(not(feature = "51"))] 217#[cfg(not(feature = "nrf51"))]
253impl_group!(PPI_GROUP4, 4); 218impl_group!(PPI_GROUP4, 4);
254#[cfg(not(feature = "51"))] 219#[cfg(not(feature = "nrf51"))]
255impl_group!(PPI_GROUP5, 5); 220impl_group!(PPI_GROUP5, 5);
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
1use core::marker::PhantomData; 3use core::marker::PhantomData;
2use core::sync::atomic::{compiler_fence, Ordering}; 4use core::sync::atomic::{compiler_fence, Ordering};
3use core::task::Poll; 5use core::task::Poll;
@@ -231,45 +233,12 @@ pub trait Input {
231 fn channel(&self) -> InputChannel; 233 fn channel(&self) -> InputChannel;
232} 234}
233 235
234macro_rules! input_mappings { 236macro_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")]
249input_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")]
260input_mappings! {
261 ANALOGINPUT2 => P0_04,
262 ANALOGINPUT3 => P0_05,
263}
264
265#[cfg(not(any(feature = "nrf52805", feature = "nrf9160")))]
266input_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}
diff --git a/embassy-nrf/src/util.rs b/embassy-nrf/src/util.rs
index 7c3974eeb..344fb01f9 100644
--- a/embassy-nrf/src/util.rs
+++ b/embassy-nrf/src/util.rs
@@ -8,7 +8,7 @@ pub(crate) fn slice_in_ram(slice: &[u8]) -> bool {
8} 8}
9 9
10/// Return an error if slice is not in RAM. 10/// Return an error if slice is not in RAM.
11#[cfg(not(feature = "51"))] 11#[cfg(not(feature = "nrf51"))]
12pub(crate) fn slice_in_ram_or<T>(slice: &[u8], err: T) -> Result<(), T> { 12pub(crate) fn slice_in_ram_or<T>(slice: &[u8], err: T) -> Result<(), T> {
13 if slice.len() == 0 || slice_in_ram(slice) { 13 if slice.len() == 0 || slice_in_ram(slice) {
14 Ok(()) 14 Ok(())