Skip to content

Commit 3c758ed

Browse files
committed
add reachability check and docs to interrupt!
1 parent e26155b commit 3c758ed

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/generate/interrupt.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,33 @@ pub fn render(
100100
];
101101

102102
/// Macro to override a device specific interrupt handler
103+
///
104+
/// # Syntax
105+
///
106+
/// ``` ignore
107+
/// interrupt!(
108+
/// // Name of the interrupt
109+
/// $Name:ident,
110+
///
111+
/// // Path to the interrupt handler (a function)
112+
/// $handler:path,
113+
///
114+
/// // Optional, state preserved across invocations of the handler
115+
/// state: $State:ty = $initial_state:expr,
116+
/// );
117+
/// ```
118+
///
119+
/// Where `$Name` must match the name of one of the variants of the `Interrupt`
120+
/// enum.
121+
///
122+
/// The handler must have signature `fn()` is no state was associated to it;
123+
/// otherwise its signature must be `fn(&mut $State)`.
103124
#[cfg(feature = "rt")]
104125
#[macro_export]
105126
macro_rules! interrupt {
106127
($Name:ident, $handler:path,state: $State:ty = $initial_state:expr) => {
107128
#[allow(unsafe_code)]
129+
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
108130
#[no_mangle]
109131
pub unsafe extern "C" fn $Name() {
110132
static mut STATE: $State = $initial_state;
@@ -121,6 +143,7 @@ pub fn render(
121143

122144
($Name:ident, $handler:path) => {
123145
#[allow(unsafe_code)]
146+
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
124147
#[no_mangle]
125148
pub unsafe extern "C" fn $Name() {
126149
// check that this interrupt exists

0 commit comments

Comments
 (0)