Skip to content

Add STIR register to NVIC peripheral #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "register", "peripheral"]
license = "MIT OR Apache-2.0"
name = "cortex-m"
repository = "https://github.com/japaric/cortex-m"
version = "0.5.1"
version = "0.5.2"

[build-dependencies]
cc = "1.0.10"
Expand All @@ -20,4 +20,4 @@ volatile-register = "0.2.0"
[features]
cm7-r0p1 = []
const-fn = ["bare-metal/const-fn"]
inline-asm = []
inline-asm = []
23 changes: 22 additions & 1 deletion src/peripheral/nvic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#[cfg(not(armv6m))]
use volatile_register::RO;
use volatile_register::RW;
use volatile_register::{RW, WO};

use interrupt::Nr;
use peripheral::NVIC;
Expand Down Expand Up @@ -65,9 +65,30 @@ pub struct RegisterBlock {
/// so convenient byte-sized representation wouldn't work on that
/// architecture.
pub ipr: [RW<u32>; 8],

#[cfg(not(armv6m))]
reserved5: [u32; 208],

#[cfg(armv6m)]
reserved5: [u32; 696],

/// Software Trigger Interrupt
pub stir: WO<u32>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STIR is not present on ARMv6-M so this needs #[cfg(not(armv6m))].

}

impl NVIC {
/// Request an IRQ in software
pub fn req_irq<I>(&mut self, interrupt: I)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method should be renamed to request. The other NVIC methods like enabled(interrupt: I) are read as "enable interrupt", so I think "request interrupt" would be more fitting.

I think this method should include a comment similar to what's included in the ARM documentation:

Writing a value to the INTID field is the same as manually pending an interrupt by setting the corresponding interrupt bit in an Interrupt Set Pending Register.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method should include a comment similar to what's included in the ARM documentation:

in particular the comment should mention that this method is similar to set_pending.

where
I: Nr,
{
let nr = interrupt.nr();

unsafe {
self.stir.write(nr as u32);
}
}

/// Clears `interrupt`'s pending state
pub fn clear_pending<I>(&mut self, interrupt: I)
where
Expand Down