Skip to content

Commit de87053

Browse files
committed
Add DMA channels to metapac
1 parent 2415922 commit de87053

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

mspm0-metapac-gen/res/metadata.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub struct Metadata {
66
pub pincm_mappings: &'static [PinCmMapping],
77
// pub nvic_priority_bits: Option<u8>,
88
pub interrupts: &'static [Interrupt],
9-
// pub dma_channels: &'static [DmaChannel],
9+
pub dma_channels: &'static [DmaChannel],
1010
}
1111

1212
#[derive(Debug, Eq, PartialEq, Clone)]
@@ -35,3 +35,12 @@ pub struct Interrupt {
3535
pub name: &'static str,
3636
pub number: u32,
3737
}
38+
39+
#[derive(Debug, Eq, PartialEq, Clone)]
40+
pub struct DmaChannel {
41+
/// The number of the dma channel.
42+
pub number: u8,
43+
44+
/// Whether this is a full or basic dma channel.
45+
pub full: bool,
46+
}

mspm0-metapac-gen/src/metadata.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,27 @@ pub fn generate(name: &str, chip: &Chip) -> TokenStream {
4343
});
4444
}
4545

46+
let mut dma_channels = Vec::new();
47+
48+
for (&num, channel) in chip.dma_channels.iter() {
49+
let number = Literal::u32_unsuffixed(num);
50+
let full = channel.full;
51+
52+
dma_channels.push(quote! {
53+
DmaChannel {
54+
number: #number,
55+
full: #full,
56+
}
57+
});
58+
}
59+
4660
quote! {
4761
pub static METADATA: Metadata = Metadata {
4862
name: #name,
4963
peripherals: &[#(#peripherals),*],
5064
pincm_mappings: &[#(#pincm_mappings),*],
5165
interrupts: &[#(#interrupts),*],
66+
dma_channels: &[#(#dma_channels),*],
5267
};
5368
}
5469
}

0 commit comments

Comments
 (0)