Skip to content

Commit e8afc8e

Browse files
author
Jorge Aparicio
committed
implement Nr for the interrupt token
sometimes you want to get the nr from that instead of from the Interrupt enum
1 parent 7b585ac commit e8afc8e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Interrupt tokens now implement the `Nr` trait
13+
1014
### Changed
1115

1216
- [breaking change] the fields of the interrupt::Handlers struct has been

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/generate.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,17 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
9898
pub #name_pc: extern "C" fn(#name_pc),
9999
});
100100

101+
let value = util::unsuffixed(u64(interrupt.value));
101102
mod_items.push(quote! {
102103
#[doc = #description]
103104
pub struct #name_pc { _0: () }
104105
unsafe impl Context for #name_pc {}
106+
unsafe impl Nr for #name_pc {
107+
#[inline(always)]
108+
fn nr(&self) -> u8 {
109+
#value
110+
}
111+
}
105112
});
106113

107114
exprs.push(quote! {
@@ -113,7 +120,6 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
113120
#name_pc,
114121
});
115122

116-
let value = util::unsuffixed(u64(interrupt.value));
117123
arms.push(quote! {
118124
Interrupt::#name_pc => #value,
119125
});

0 commit comments

Comments
 (0)