some improvements
Some checks failed
Rust/va416xx-rs/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Robin Müller 2024-09-17 18:20:42 +02:00
parent 9d1f1e3dac
commit cea9c2fc37
Signed by: muellerr
GPG Key ID: A649FB78196E3849

View File

@ -134,7 +134,11 @@ impl TimerDriverEmbassy {
// Should be called inside the IRQ of the alarm timer.
fn on_interrupt_alarm(&self, idx: usize) {
critical_section::with(|cs| self.trigger_alarm(idx, cs))
critical_section::with(|cs| {
if self.alarms.borrow(cs)[idx].timestamp.get() < self.now() {
self.trigger_alarm(idx, cs)
}
})
}
fn next_period(&self) {
@ -146,10 +150,11 @@ impl TimerDriverEmbassy {
let alarm = &self.alarms.borrow(cs)[i];
let at = alarm.timestamp.get();
let alarm_tim = alarm_tim(0);
if at < t + three_quarters_of_period(alarm_tim.rst_value().read().bits() as u64) {
if at < t + three_quarters_of_period(rst_val) {
alarm_tim.enable().write(|w| unsafe { w.bits(0) });
let rst_val = alarm_tim.rst_value().read().bits();
alarm_tim.cnt_value().write(|w| unsafe { w.bits(rst_val) });
alarm_tim
.cnt_value()
.write(|w| unsafe { w.bits((at - t) as u32) });
alarm_tim.ctrl().modify(|_, w| w.irq_enb().set_bit());
alarm_tim.enable().write(|w| unsafe { w.bits(1) })
}
@ -270,7 +275,7 @@ impl Driver for TimerDriverEmbassy {
.write(|w| unsafe { w.bits(rst_val_alarm) });
let diff = timestamp - t;
if diff < (three_quarters_of_period(rst_val_alarm as u64)) {
if diff < (three_quarters_of_period(rst_val as u64)) {
alarm_tim
.cnt_value()
.write(|w| unsafe { w.bits(rst_val_alarm) });