diff options
| author | kalkyl <[email protected]> | 2022-12-10 13:43:29 +0100 |
|---|---|---|
| committer | kalkyl <[email protected]> | 2022-12-10 13:43:29 +0100 |
| commit | 96d6c7243b7b5f7f8c90dab666ded0ca0cf29c75 (patch) | |
| tree | 127809759feb41cb90cf3e739990c218980566b2 | |
| parent | d8821cfd41eb1776b904a5766be43f242af938f7 (diff) | |
Cleanup
| -rw-r--r-- | embassy-rp/src/multicore.rs | 12 | ||||
| -rw-r--r-- | examples/rp/src/bin/multicore.rs | 7 |
2 files changed, 9 insertions, 10 deletions
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs index cc5c192b1..bf635db2d 100644 --- a/embassy-rp/src/multicore.rs +++ b/embassy-rp/src/multicore.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | //! Multicore support | 1 | //! MultiCore support |
| 2 | //! | 2 | //! |
| 3 | //! This module handles setup of the 2nd cpu core on the rp2040, which we refer to as core1. | 3 | //! This module handles setup of the 2nd cpu core on the rp2040, which we refer to as core1. |
| 4 | //! It provides functionality for setting up the stack, and starting core1. | 4 | //! It provides functionality for setting up the stack, and starting core1. |
| @@ -62,9 +62,9 @@ fn core1_setup(stack_bottom: *mut usize) { | |||
| 62 | install_stack_guard(stack_bottom); | 62 | install_stack_guard(stack_bottom); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | /// Multicore execution management. | 65 | /// MultiCore execution management. |
| 66 | pub struct Multicore { | 66 | pub struct MultiCore { |
| 67 | cores: (Core, Core), | 67 | pub cores: (Core, Core), |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | /// Data type for a properly aligned stack of N 32-bit (usize) words | 70 | /// Data type for a properly aligned stack of N 32-bit (usize) words |
| @@ -81,8 +81,8 @@ impl<const SIZE: usize> Stack<SIZE> { | |||
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | impl Multicore { | 84 | impl MultiCore { |
| 85 | /// Create a new |Multicore| instance. | 85 | /// Create a new |MultiCore| instance. |
| 86 | pub fn new() -> Self { | 86 | pub fn new() -> Self { |
| 87 | Self { | 87 | Self { |
| 88 | cores: (Core { id: CoreId::Core0 }, Core { id: CoreId::Core1 }), | 88 | cores: (Core { id: CoreId::Core0 }, Core { id: CoreId::Core1 }), |
diff --git a/examples/rp/src/bin/multicore.rs b/examples/rp/src/bin/multicore.rs index cfb91e21f..53941da60 100644 --- a/examples/rp/src/bin/multicore.rs +++ b/examples/rp/src/bin/multicore.rs | |||
| @@ -6,7 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Executor; | 6 | use embassy_executor::Executor; |
| 7 | use embassy_executor::_export::StaticCell; | 7 | use embassy_executor::_export::StaticCell; |
| 8 | use embassy_rp::gpio::{Level, Output}; | 8 | use embassy_rp::gpio::{Level, Output}; |
| 9 | use embassy_rp::multicore::{Multicore, Stack}; | 9 | use embassy_rp::multicore::{MultiCore, Stack}; |
| 10 | use embassy_rp::peripherals::PIN_25; | 10 | use embassy_rp::peripherals::PIN_25; |
| 11 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 11 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 12 | use embassy_sync::channel::Channel; | 12 | use embassy_sync::channel::Channel; |
| @@ -28,9 +28,8 @@ fn main() -> ! { | |||
| 28 | let p = embassy_rp::init(Default::default()); | 28 | let p = embassy_rp::init(Default::default()); |
| 29 | let led = Output::new(p.PIN_25, Level::Low); | 29 | let led = Output::new(p.PIN_25, Level::Low); |
| 30 | 30 | ||
| 31 | let mut mc = Multicore::new(); | 31 | let mut mc = MultiCore::new(); |
| 32 | let (_, core1) = mc.cores(); | 32 | let _ = mc.cores.1.spawn(unsafe { &mut CORE1_STACK.mem }, move || { |
| 33 | let _ = core1.spawn(unsafe { &mut CORE1_STACK.mem }, move || { | ||
| 34 | let executor1 = EXECUTOR1.init(Executor::new()); | 33 | let executor1 = EXECUTOR1.init(Executor::new()); |
| 35 | executor1.run(|spawner| unwrap!(spawner.spawn(core1_task(led)))); | 34 | executor1.run(|spawner| unwrap!(spawner.spawn(core1_task(led)))); |
| 36 | }); | 35 | }); |
