@@ -21,6 +21,7 @@ pub fn render(device: &Device, target: &Target, peripherals: &[Peripheral]) -> R
2121 interrupts. sort_by_key ( |i| i. value ) ;
2222
2323 let mut arms = vec ! [ ] ;
24+ let mut from_arms = vec ! [ ] ;
2425 let mut elements = vec ! [ ] ;
2526 let mut names = vec ! [ ] ;
2627 let mut variants = vec ! [ ] ;
@@ -60,6 +61,10 @@ pub fn render(device: &Device, target: &Target, peripherals: &[Peripheral]) -> R
6061 Interrupt :: #name_uc => #value,
6162 } ) ;
6263
64+ from_arms. push ( quote ! {
65+ #value => Ok ( Interrupt :: #name_uc) ,
66+ } ) ;
67+
6368 elements. push ( quote ! ( Some ( #name_uc) ) ) ;
6469 names. push ( name_uc) ;
6570 }
@@ -169,6 +174,7 @@ pub fn render(device: &Device, target: &Target, peripherals: &[Peripheral]) -> R
169174 ] ;
170175 } ) ;
171176 }
177+ Target :: RISCV => { }
172178 Target :: None => { }
173179 }
174180
@@ -186,6 +192,23 @@ pub fn render(device: &Device, target: &Target, peripherals: &[Peripheral]) -> R
186192 }
187193 }
188194 }
195+
196+ use core:: convert:: TryFrom ;
197+
198+ #[ derive( Debug , Copy , Clone ) ]
199+ pub struct TryFromInterruptError ( ( ) ) ;
200+
201+ impl TryFrom <u8 > for Interrupt {
202+ type Error = TryFromInterruptError ;
203+
204+ #[ inline]
205+ fn try_from( value: u8 ) -> Result <Self , Self :: Error > {
206+ match value {
207+ #( #from_arms) *
208+ _ => Err ( TryFromInterruptError ( ( ) ) ) ,
209+ }
210+ }
211+ }
189212 } ) ;
190213
191214 if * target != Target :: None {
0 commit comments