mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-11 13:01:30 +11:00
Update documentation and drop entrypoint on error
This commit is contained in:
parent
8a261b050c
commit
67ceb65703
|
@ -3,20 +3,20 @@
|
||||||
//! This module handles setup of the 2nd cpu core on the rp2040, which we refer to as core1.
|
//! This module handles setup of the 2nd cpu core on the rp2040, which we refer to as core1.
|
||||||
//! It provides functionality for setting up the stack, and starting core1.
|
//! It provides functionality for setting up the stack, and starting core1.
|
||||||
//!
|
//!
|
||||||
//! The options for an entrypoint for core1 are
|
//! The entrypoint for core1 can be any function that never returns, including closures.
|
||||||
//! - a function that never returns - eg
|
|
||||||
//! `fn core1_task() -> ! { loop{} }; `
|
|
||||||
//! - a lambda (note: This requires a global allocator which requires a nightly compiler. Not recommended for beginners)
|
|
||||||
//!
|
//!
|
||||||
//! # Usage
|
//! # Usage
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! use rp2040_hal::{pac, gpio::Pins, sio::Sio, multicore::{Multicore, Stack}};
|
||||||
|
//!
|
||||||
//! static mut CORE1_STACK: Stack<4096> = Stack::new();
|
//! static mut CORE1_STACK: Stack<4096> = Stack::new();
|
||||||
|
//!
|
||||||
//! fn core1_task() -> ! {
|
//! fn core1_task() -> ! {
|
||||||
//! loop {}
|
//! loop {}
|
||||||
//! }
|
//! }
|
||||||
//! // fn main() -> ! {
|
//!
|
||||||
//! use rp2040_hal::{pac, gpio::Pins, sio::Sio, multicore::{Multicore, Stack}};
|
//! fn main() -> ! {
|
||||||
//! let mut pac = pac::Peripherals::take().unwrap();
|
//! let mut pac = pac::Peripherals::take().unwrap();
|
||||||
//! let mut sio = Sio::new(pac.SIO);
|
//! let mut sio = Sio::new(pac.SIO);
|
||||||
//! // Other init code above this line
|
//! // Other init code above this line
|
||||||
|
@ -25,7 +25,8 @@
|
||||||
//! let core1 = &mut cores[1];
|
//! let core1 = &mut cores[1];
|
||||||
//! let _test = core1.spawn(core1_task, unsafe { &mut CORE1_STACK.mem });
|
//! let _test = core1.spawn(core1_task, unsafe { &mut CORE1_STACK.mem });
|
||||||
//! // The rest of your application below this line
|
//! // The rest of your application below this line
|
||||||
//! //}
|
//! # loop {}
|
||||||
|
//! }
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
@ -212,6 +213,9 @@ impl<'p> Core<'p> {
|
||||||
seq = 0;
|
seq = 0;
|
||||||
fails += 1;
|
fails += 1;
|
||||||
if fails > 16 {
|
if fails > 16 {
|
||||||
|
// The second core isn't responding, and isn't going to take the entrypoint,
|
||||||
|
// so we have to drop it ourselves.
|
||||||
|
drop(ManuallyDrop::into_inner(entry));
|
||||||
return Err(Error::Unresponsive);
|
return Err(Error::Unresponsive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue