Skip to content

mspm0: add dma driver #4338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions embassy-mspm0/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ cortex-m = "0.7.6"
critical-section = "1.2.0"

# mspm0-metapac = { version = "" }
mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-26a6f681eda4ef120e8cb614a1631727c848590f" }
mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-235158ac2865d8aac3a1eceb2d62026eb12bf38f" }

[build-dependencies]
proc-macro2 = "1.0.94"
quote = "1.0.40"

# mspm0-metapac = { version = "", default-features = false, features = ["metadata"] }
mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-26a6f681eda4ef120e8cb614a1631727c848590f", default-features = false, features = ["metadata"] }
mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-235158ac2865d8aac3a1eceb2d62026eb12bf38f", default-features = false, features = ["metadata"] }

[features]
default = ["rt"]
Expand Down
21 changes: 19 additions & 2 deletions embassy-mspm0/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ fn generate_code() {
g.extend(generate_peripheral_instances());
g.extend(generate_pin_trait_impls());
g.extend(generate_groups());
g.extend(generate_dma_channel_count());

let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
let out_file = out_dir.join("_generated.rs").to_string_lossy().to_string();
Expand Down Expand Up @@ -209,6 +210,12 @@ fn generate_groups() -> TokenStream {
}
}

fn generate_dma_channel_count() -> TokenStream {
let count = METADATA.dma_channels.len();

quote! { pub const DMA_CHANNELS: usize = #count; }
}

#[derive(Debug, Clone)]
struct Singleton {
name: String,
Expand Down Expand Up @@ -543,8 +550,6 @@ fn generate_peripheral_instances() -> TokenStream {
for peripheral in METADATA.peripherals {
let peri = format_ident!("{}", peripheral.name);

// Will be filled in when uart implementation is finished
let _ = peri;
let tokens = match peripheral.kind {
"uart" => Some(quote! { impl_uart_instance!(#peri); }),
_ => None,
Expand All @@ -555,6 +560,18 @@ fn generate_peripheral_instances() -> TokenStream {
}
}

// DMA channels
for dma_channel in METADATA.dma_channels.iter() {
let peri = format_ident!("DMA_CH{}", dma_channel.number);
let num = dma_channel.number;

if dma_channel.full {
impls.push(quote! { impl_full_dma_channel!(#peri, #num); });
} else {
impls.push(quote! { impl_dma_channel!(#peri, #num); });
}
}

quote! {
#(#impls)*
}
Expand Down
Loading