-
Notifications
You must be signed in to change notification settings - Fork 215
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
Fix broken rtic-monotonic stm32 behavior #958
Changes from 4 commits
811dbc0
7f425ec
29140a0
b474fee
ed6c1e8
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 |
---|---|---|
|
@@ -240,8 +240,8 @@ macro_rules! make_timer { | |
$timer.dier().modify(|r| r.set_uie(true)); | ||
|
||
// Configure and enable half-period interrupt | ||
$timer.ccr(2).write(|r| r.set_ccr(($bits::MAX - ($bits::MAX >> 1)).into())); | ||
$timer.dier().modify(|r| r.set_ccie(2, true)); | ||
$timer.ccr(1).write(|r| r.set_ccr(($bits::MAX - ($bits::MAX >> 1)).into())); | ||
$timer.dier().modify(|r| r.set_ccie(1, true)); | ||
|
||
// Trigger an update event to load the prescaler value to the clock. | ||
$timer.egr().write(|r| r.set_ug(true)); | ||
|
@@ -294,21 +294,13 @@ macro_rules! make_timer { | |
} | ||
|
||
fn clear_compare_flag() { | ||
$timer.sr().modify(|r| r.set_ccif(1, false)); | ||
// Do nothing, because the flags are cleared below in on_interrupt | ||
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. This is incorrect, this flag is for the user triggered interrupt, the other one is for the half-overflow interrupt. Please do not remove this line. |
||
} | ||
|
||
fn pend_interrupt() { | ||
cortex_m::peripheral::NVIC::pend(pac::Interrupt::$timer); | ||
} | ||
|
||
fn enable_timer() { | ||
$timer.dier().modify(|r| r.set_ccie(1, true)); | ||
} | ||
|
||
fn disable_timer() { | ||
$timer.dier().modify(|r| r.set_ccie(1, false)); | ||
} | ||
|
||
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. Please leave this. It is used by |
||
fn on_interrupt() { | ||
// Full period | ||
if $timer.sr().read().uif() { | ||
|
@@ -317,8 +309,8 @@ macro_rules! make_timer { | |
assert!(prev % 2 == 1, "Monotonic must have missed an interrupt!"); | ||
} | ||
// Half period | ||
if $timer.sr().read().ccif(2) { | ||
$timer.sr().modify(|r| r.set_ccif(2, false)); | ||
if $timer.sr().read().ccif(1) { | ||
$timer.sr().modify(|r| r.set_ccif(1, false)); | ||
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. Use |
||
let prev = $overflow.fetch_add(1, Ordering::Relaxed); | ||
assert!(prev % 2 == 0, "Monotonic must have missed an interrupt!"); | ||
} | ||
|
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.
Modify to
ccr(0)
.ccr(1)
is already occupied.