Skip to content

Commit

Permalink
riot-rs-embassy: provide usb builder hook
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed Feb 19, 2024
1 parent 14520b7 commit f4620dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/riot-rs-embassy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub mod arch;
pub use linkme::{self, distributed_slice};
pub use static_cell::make_static;

use crate::define_peripherals::DefinePeripheralsError;
pub use embassy_executor::Spawner;

#[cfg(feature = "threading")]
Expand Down Expand Up @@ -67,13 +66,17 @@ pub static EMBASSY_TASKS: [Task] = [..];
//
// usb common start
#[cfg(feature = "usb")]
use arch::usb::UsbDriver;
pub use arch::usb::UsbDriver;

#[cfg(feature = "usb")]
#[embassy_executor::task]
async fn usb_task(mut device: embassy_usb::UsbDevice<'static, UsbDriver>) -> ! {
device.run().await
}

#[cfg(feature = "usb")]
#[distributed_slice]
pub static USB_BUILDER_HOOKS: [&delegate::Delegate<UsbBuilder>] = [..];
// usb common end
//

Expand Down Expand Up @@ -233,6 +236,11 @@ async fn init_task(mut peripherals: arch::OptionalPeripherals) {
builder
};

#[cfg(feature = "usb")]
for hook in USB_BUILDER_HOOKS {
hook.lend(&mut usb_builder).await;
}

// Our MAC addr.
#[cfg(feature = "usb_ethernet")]
let our_mac_addr = [0xCA, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC];
Expand Down
1 change: 1 addition & 0 deletions src/riot-rs-rt/linkme.x
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SECTIONS {
linkm2_INIT_FUNCS : { *(linkm2_INIT_FUNCS) } > FLASH
linkme_EMBASSY_TASKS : { *(linkme_EMBASSY_TASKS) } > FLASH
linkm2_EMBASSY_TASKS : { *(linkm2_EMBASSY_TASKS) } > FLASH
linkm2_USB_BUILDER_HOOKS : { *(linkm2_USB_BUILDER_HOOKS) } > FLASH
linkm2_THREAD_FNS : { *(linkm2_THREAD_FNS) } > FLASH
}

Expand Down

0 comments on commit f4620dd

Please sign in to comment.