-
Notifications
You must be signed in to change notification settings - Fork 171
Add SysTick flags #116
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
Add SysTick flags #116
Changes from 2 commits
19d3534
454bb4e
d9ad9d4
fac7e85
2cb6f4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -619,6 +619,9 @@ impl SCB { | |
const SCB_ICSR_PENDSVSET: u32 = 1 << 28; | ||
const SCB_ICSR_PENDSVCLR: u32 = 1 << 27; | ||
|
||
const SCB_ICSR_PENDSTSET: u32 = 1 << 26; | ||
const SCB_ICSR_PENDSTCLR: u32 = 1 << 25; | ||
|
||
impl SCB { | ||
/// Set the PENDSVSET bit in the ICSR register which will pend the PendSV interrupt | ||
pub fn set_pendsv() { | ||
|
@@ -640,4 +643,29 @@ impl SCB { | |
(*Self::ptr()).icsr.write(SCB_ICSR_PENDSVCLR); | ||
} | ||
} | ||
|
||
/// Set the PENDSTCLR bit in the ICSR register which will clear a pending SysTick interrupt | ||
#[inline] | ||
pub fn set_systick(&mut self) { | ||
unsafe { | ||
(*Self::ptr()).icsr.write(SCB_ICSR_PENDSTSET); | ||
} | ||
} | ||
|
||
/// Check if PENDSTSET bit in the ICSR register is set meaning SysTick interrupt is pending | ||
#[inline] | ||
pub fn is_systick_pending() -> bool { | ||
unsafe { | ||
(*Self::ptr()).icsr.read() & SCB_ICSR_PENDSTSET == SCB_ICSR_PENDSTSET | ||
} | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor nit: One blank line too many. |
||
/// Set the PENDSTCLR bit in the ICSR register which will clear a pending SysTick interrupt | ||
#[inline] | ||
pub fn clear_systick_pending(&mut self) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this operation require exclusive access to SCB ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, exclusive access to SCB is not required. I think that |
||
unsafe { | ||
(*Self::ptr()).icsr.write(SCB_ICSR_PENDSTCLR); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about calling this
set_systick
when just above we haveset_pendsv
. Really this one should beset_pendst
or we need to rename both (causing a major version change). Same applies tois_systick_pending
andclear_systick_pending
. I'd prefer just usingpendst
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
set_pendst
looks better.