@@ -172,25 +172,8 @@ impl SCB {
172172 pub fn vect_active ( ) -> VectActive {
173173 let icsr = unsafe { ptr:: read ( & ( * SCB :: PTR ) . icsr as * const _ as * const u32 ) } ;
174174
175- match icsr as u8 {
176- 0 => VectActive :: ThreadMode ,
177- 2 => VectActive :: Exception ( Exception :: NonMaskableInt ) ,
178- 3 => VectActive :: Exception ( Exception :: HardFault ) ,
179- #[ cfg( not( armv6m) ) ]
180- 4 => VectActive :: Exception ( Exception :: MemoryManagement ) ,
181- #[ cfg( not( armv6m) ) ]
182- 5 => VectActive :: Exception ( Exception :: BusFault ) ,
183- #[ cfg( not( armv6m) ) ]
184- 6 => VectActive :: Exception ( Exception :: UsageFault ) ,
185- #[ cfg( any( armv8m, native) ) ]
186- 7 => VectActive :: Exception ( Exception :: SecureFault ) ,
187- 11 => VectActive :: Exception ( Exception :: SVCall ) ,
188- #[ cfg( not( armv6m) ) ]
189- 12 => VectActive :: Exception ( Exception :: DebugMonitor ) ,
190- 14 => VectActive :: Exception ( Exception :: PendSV ) ,
191- 15 => VectActive :: Exception ( Exception :: SysTick ) ,
192- irqn => VectActive :: Interrupt { irqn : irqn - 16 } ,
193- }
175+ // NOTE(unsafe): Assume correctly selected target.
176+ unsafe { VectActive :: from ( icsr as u8 ) . unwrap_unchecked ( ) }
194177 }
195178}
196179
@@ -300,7 +283,7 @@ impl VectActive {
300283 12 => VectActive :: Exception ( Exception :: DebugMonitor ) ,
301284 14 => VectActive :: Exception ( Exception :: PendSV ) ,
302285 15 => VectActive :: Exception ( Exception :: SysTick ) ,
303- irqn if irqn >= 16 => VectActive :: Interrupt { irqn } ,
286+ irqn if irqn >= 16 => VectActive :: Interrupt { irqn : irqn - 16 } ,
304287 _ => return None ,
305288 } )
306289 }
0 commit comments