mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
rp/bootsel: change it to a method on the peripheral.
This commit is contained in:
parent
3e054a6f0d
commit
d4ed8e5779
@ -9,11 +9,12 @@
|
|||||||
|
|
||||||
use crate::flash::in_ram;
|
use crate::flash::in_ram;
|
||||||
|
|
||||||
|
impl crate::peripherals::BOOTSEL {
|
||||||
/// Polls the BOOTSEL button. Returns true if the button is pressed.
|
/// Polls the BOOTSEL button. Returns true if the button is pressed.
|
||||||
///
|
///
|
||||||
/// Polling isn't cheap, as this function waits for core 1 to finish it's current
|
/// Polling isn't cheap, as this function waits for core 1 to finish it's current
|
||||||
/// task and for any DMAs from flash to complete
|
/// task and for any DMAs from flash to complete
|
||||||
pub fn poll_bootsel() -> bool {
|
pub fn is_pressed(&mut self) -> bool {
|
||||||
let mut cs_status = Default::default();
|
let mut cs_status = Default::default();
|
||||||
|
|
||||||
unsafe { in_ram(|| cs_status = ram_helpers::read_cs_status()) }.expect("Must be called from Core 0");
|
unsafe { in_ram(|| cs_status = ram_helpers::read_cs_status()) }.expect("Must be called from Core 0");
|
||||||
@ -21,6 +22,7 @@ pub fn poll_bootsel() -> bool {
|
|||||||
// bootsel is active low, so invert
|
// bootsel is active low, so invert
|
||||||
!cs_status.infrompad()
|
!cs_status.infrompad()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mod ram_helpers {
|
mod ram_helpers {
|
||||||
use rp_pac::io::regs::GpioStatus;
|
use rp_pac::io::regs::GpioStatus;
|
||||||
|
@ -194,6 +194,7 @@ embassy_hal_internal::peripherals! {
|
|||||||
PIO1,
|
PIO1,
|
||||||
|
|
||||||
WATCHDOG,
|
WATCHDOG,
|
||||||
|
BOOTSEL,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! select_bootloader {
|
macro_rules! select_bootloader {
|
||||||
|
Loading…
Reference in New Issue
Block a user