@@ -170,9 +170,10 @@ impl SCB {
170
170
/// Returns the active exception number
171
171
#[ inline]
172
172
pub fn vect_active ( ) -> VectActive {
173
- let icsr = unsafe { ptr:: read ( & ( * SCB :: ptr ( ) ) . icsr as * const _ as * const u32 ) } ;
173
+ let icsr =
174
+ unsafe { ptr:: read_volatile ( & ( * SCB :: ptr ( ) ) . icsr as * const _ as * const u32 ) } & 0x1FF ;
174
175
175
- match icsr as u8 {
176
+ match icsr as u16 {
176
177
0 => VectActive :: ThreadMode ,
177
178
2 => VectActive :: Exception ( Exception :: NonMaskableInt ) ,
178
179
3 => VectActive :: Exception ( Exception :: HardFault ) ,
@@ -274,15 +275,15 @@ pub enum VectActive {
274
275
275
276
/// Device specific exception (external interrupts)
276
277
Interrupt {
277
- /// Interrupt number. This number is always within half open range `[0, 240)`
278
- irqn : u8 ,
278
+ /// Interrupt number. This number is always within half open range `[0, 512)` (9 bit)
279
+ irqn : u16 ,
279
280
} ,
280
281
}
281
282
282
283
impl VectActive {
283
- /// Converts a `byte` into `VectActive`
284
+ /// Converts a vector number into `VectActive`
284
285
#[ inline]
285
- pub fn from ( vect_active : u8 ) -> Option < Self > {
286
+ pub fn from ( vect_active : u16 ) -> Option < Self > {
286
287
Some ( match vect_active {
287
288
0 => VectActive :: ThreadMode ,
288
289
2 => VectActive :: Exception ( Exception :: NonMaskableInt ) ,
@@ -300,7 +301,7 @@ impl VectActive {
300
301
12 => VectActive :: Exception ( Exception :: DebugMonitor ) ,
301
302
14 => VectActive :: Exception ( Exception :: PendSV ) ,
302
303
15 => VectActive :: Exception ( Exception :: SysTick ) ,
303
- irqn if irqn >= 16 = > VectActive :: Interrupt { irqn } ,
304
+ irqn if ( 16 .. 512 ) . contains ( & irqn) = > VectActive :: Interrupt { irqn : irqn - 16 } ,
304
305
_ => return None ,
305
306
} )
306
307
}
0 commit comments