@@ -170,9 +170,10 @@ impl SCB {
170170 /// Returns the active exception number
171171 #[ inline]
172172 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 ;
174175
175- match icsr as u8 {
176+ match icsr as u16 {
176177 0 => VectActive :: ThreadMode ,
177178 2 => VectActive :: Exception ( Exception :: NonMaskableInt ) ,
178179 3 => VectActive :: Exception ( Exception :: HardFault ) ,
@@ -274,15 +275,15 @@ pub enum VectActive {
274275
275276 /// Device specific exception (external interrupts)
276277 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 ,
279280 } ,
280281}
281282
282283impl VectActive {
283- /// Converts a `byte` into `VectActive`
284+ /// Converts a vector number into `VectActive`
284285 #[ inline]
285- pub fn from ( vect_active : u8 ) -> Option < Self > {
286+ pub fn from ( vect_active : u16 ) -> Option < Self > {
286287 Some ( match vect_active {
287288 0 => VectActive :: ThreadMode ,
288289 2 => VectActive :: Exception ( Exception :: NonMaskableInt ) ,
@@ -300,7 +301,7 @@ impl VectActive {
300301 12 => VectActive :: Exception ( Exception :: DebugMonitor ) ,
301302 14 => VectActive :: Exception ( Exception :: PendSV ) ,
302303 15 => VectActive :: Exception ( Exception :: SysTick ) ,
303- irqn if irqn >= 16 => VectActive :: Interrupt { irqn } ,
304+ irqn if irqn >= 16 && irqn < 512 => VectActive :: Interrupt { irqn : irqn - 16 } ,
304305 _ => return None ,
305306 } )
306307 }
0 commit comments