Skip to content

Instantly share code, notes, and snippets.

View tarfu's full-sized avatar

Tobias Breitwieser tarfu

View GitHub Profile
@adamgreig
adamgreig / assign_resources.rs
Created November 2, 2023 00:11
assign_resources
/// Extract the specified fields from the `Peripherals` struct into several named
/// structs which can be passed to other tasks to provide them with all their
/// resources, including pins, peripherals, DMA channels, etc.
///
/// The `peripherals` module must be in scope when `resource_assigs!{}` is called,
/// and it defines a new macro `split_resources!()` which uses the `Peripherals` struct
/// and returns a new struct with a field for each of the structs named in `resource_assigs!{}`.
///
/// Defines new structs containing the specified structs from the `peripherals` module,
/// a top-level struct that contains an instance of each of these new structs, and a macro