aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-10-07 01:46:57 +0200
committerDario Nieuwenhuis <[email protected]>2023-10-07 01:47:20 +0200
commitd4ed8e5779d5e09ea57728a48fc8654d93b786f8 (patch)
tree227f634813e4d9001f6d78d1fe8f3f2484fff1d5 /embassy-rp/src
parent3e054a6f0d3ba018315f7cb7f0a373221e15737a (diff)
rp/bootsel: change it to a method on the peripheral.
Diffstat (limited to 'embassy-rp/src')
-rw-r--r--embassy-rp/src/bootsel.rs20
-rw-r--r--embassy-rp/src/lib.rs1
2 files changed, 12 insertions, 9 deletions
diff --git a/embassy-rp/src/bootsel.rs b/embassy-rp/src/bootsel.rs
index 69d620e8d..540255ae3 100644
--- a/embassy-rp/src/bootsel.rs
+++ b/embassy-rp/src/bootsel.rs
@@ -9,17 +9,19 @@
9 9
10use crate::flash::in_ram; 10use crate::flash::in_ram;
11 11
12/// Polls the BOOTSEL button. Returns true if the button is pressed. 12impl crate::peripherals::BOOTSEL {
13/// 13 /// Polls the BOOTSEL button. Returns true if the button is pressed.
14/// Polling isn't cheap, as this function waits for core 1 to finish it's current 14 ///
15/// task and for any DMAs from flash to complete 15 /// Polling isn't cheap, as this function waits for core 1 to finish it's current
16pub fn poll_bootsel() -> bool { 16 /// task and for any DMAs from flash to complete
17 let mut cs_status = Default::default(); 17 pub fn is_pressed(&mut self) -> bool {
18 let mut cs_status = Default::default();
18 19
19 unsafe { in_ram(|| cs_status = ram_helpers::read_cs_status()) }.expect("Must be called from Core 0"); 20 unsafe { in_ram(|| cs_status = ram_helpers::read_cs_status()) }.expect("Must be called from Core 0");
20 21
21 // bootsel is active low, so invert 22 // bootsel is active low, so invert
22 !cs_status.infrompad() 23 !cs_status.infrompad()
24 }
23} 25}
24 26
25mod ram_helpers { 27mod ram_helpers {
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs
index fb9189203..2728395b2 100644
--- a/embassy-rp/src/lib.rs
+++ b/embassy-rp/src/lib.rs
@@ -194,6 +194,7 @@ embassy_hal_internal::peripherals! {
194 PIO1, 194 PIO1,
195 195
196 WATCHDOG, 196 WATCHDOG,
197 BOOTSEL,
197} 198}
198 199
199macro_rules! select_bootloader { 200macro_rules! select_bootloader {