File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments