@@ -172,25 +172,8 @@ impl SCB {
172
172
pub fn vect_active ( ) -> VectActive {
173
173
let icsr = unsafe { ptr:: read ( & ( * SCB :: PTR ) . icsr as * const _ as * const u32 ) } ;
174
174
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 ( ) }
194
177
}
195
178
}
196
179
@@ -300,7 +283,7 @@ impl VectActive {
300
283
12 => VectActive :: Exception ( Exception :: DebugMonitor ) ,
301
284
14 => VectActive :: Exception ( Exception :: PendSV ) ,
302
285
15 => VectActive :: Exception ( Exception :: SysTick ) ,
303
- irqn if irqn >= 16 => VectActive :: Interrupt { irqn } ,
286
+ irqn if irqn >= 16 => VectActive :: Interrupt { irqn : irqn - 16 } ,
304
287
_ => return None ,
305
288
} )
306
289
}
0 commit comments