aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src
diff options
context:
space:
mode:
authorMathias <[email protected]>2022-10-27 07:12:34 +0200
committerMathias <[email protected]>2022-10-27 07:12:34 +0200
commitc871fe0848e50c8682b8a8d9fe8da31ca9185592 (patch)
treee24f9edc23385080968d4b427aed3eddb4bd2f21 /embassy-rp/src
parent3c6c382465131c6f76567f976198b77e327df4b2 (diff)
parent61560e740dea1b4c7ca036dafd66c834a1ff92e2 (diff)
Rebase on master
Diffstat (limited to 'embassy-rp/src')
-rw-r--r--embassy-rp/src/timer.rs15
-rw-r--r--embassy-rp/src/uart/buffered.rs16
2 files changed, 18 insertions, 13 deletions
diff --git a/embassy-rp/src/timer.rs b/embassy-rp/src/timer.rs
index 5215c0c0f..80efd779f 100644
--- a/embassy-rp/src/timer.rs
+++ b/embassy-rp/src/timer.rs
@@ -68,7 +68,7 @@ impl Driver for TimerDriver {
68 }) 68 })
69 } 69 }
70 70
71 fn set_alarm(&self, alarm: AlarmHandle, timestamp: u64) { 71 fn set_alarm(&self, alarm: AlarmHandle, timestamp: u64) -> bool {
72 let n = alarm.id() as usize; 72 let n = alarm.id() as usize;
73 critical_section::with(|cs| { 73 critical_section::with(|cs| {
74 let alarm = &self.alarms.borrow(cs)[n]; 74 let alarm = &self.alarms.borrow(cs)[n];
@@ -81,11 +81,16 @@ impl Driver for TimerDriver {
81 unsafe { pac::TIMER.alarm(n).write_value(timestamp as u32) }; 81 unsafe { pac::TIMER.alarm(n).write_value(timestamp as u32) };
82 82
83 let now = self.now(); 83 let now = self.now();
84
85 // If alarm timestamp has passed, trigger it instantly.
86 // This disarms it.
87 if timestamp <= now { 84 if timestamp <= now {
88 self.trigger_alarm(n, cs); 85 // If alarm timestamp has passed the alarm will not fire.
86 // Disarm the alarm and return `false` to indicate that.
87 unsafe { pac::TIMER.armed().write(|w| w.set_armed(1 << n)) }
88
89 alarm.timestamp.set(u64::MAX);
90
91 false
92 } else {
93 true
89 } 94 }
90 }) 95 })
91 } 96 }
diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs
index 87e16f0eb..4f0a55532 100644
--- a/embassy-rp/src/uart/buffered.rs
+++ b/embassy-rp/src/uart/buffered.rs
@@ -355,7 +355,7 @@ impl<'d, T: Instance> embedded_io::Io for BufferedUartTx<'d, T> {
355} 355}
356 356
357impl<'d, T: Instance + 'd> embedded_io::asynch::Read for BufferedUart<'d, T> { 357impl<'d, T: Instance + 'd> embedded_io::asynch::Read for BufferedUart<'d, T> {
358 type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> 358 type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
359 where 359 where
360 Self: 'a; 360 Self: 'a;
361 361
@@ -376,7 +376,7 @@ impl<'d, T: Instance + 'd> embedded_io::asynch::Read for BufferedUart<'d, T> {
376} 376}
377 377
378impl<'d, T: Instance + 'd> embedded_io::asynch::Read for BufferedUartRx<'d, T> { 378impl<'d, T: Instance + 'd> embedded_io::asynch::Read for BufferedUartRx<'d, T> {
379 type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> 379 type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
380 where 380 where
381 Self: 'a; 381 Self: 'a;
382 382
@@ -397,7 +397,7 @@ impl<'d, T: Instance + 'd> embedded_io::asynch::Read for BufferedUartRx<'d, T> {
397} 397}
398 398
399impl<'d, T: Instance + 'd> embedded_io::asynch::BufRead for BufferedUart<'d, T> { 399impl<'d, T: Instance + 'd> embedded_io::asynch::BufRead for BufferedUart<'d, T> {
400 type FillBufFuture<'a> = impl Future<Output = Result<&'a [u8], Self::Error>> 400 type FillBufFuture<'a> = impl Future<Output = Result<&'a [u8], Self::Error>> + 'a
401 where 401 where
402 Self: 'a; 402 Self: 'a;
403 403
@@ -419,7 +419,7 @@ impl<'d, T: Instance + 'd> embedded_io::asynch::BufRead for BufferedUart<'d, T>
419} 419}
420 420
421impl<'d, T: Instance + 'd> embedded_io::asynch::BufRead for BufferedUartRx<'d, T> { 421impl<'d, T: Instance + 'd> embedded_io::asynch::BufRead for BufferedUartRx<'d, T> {
422 type FillBufFuture<'a> = impl Future<Output = Result<&'a [u8], Self::Error>> 422 type FillBufFuture<'a> = impl Future<Output = Result<&'a [u8], Self::Error>> + 'a
423 where 423 where
424 Self: 'a; 424 Self: 'a;
425 425
@@ -441,7 +441,7 @@ impl<'d, T: Instance + 'd> embedded_io::asynch::BufRead for BufferedUartRx<'d, T
441} 441}
442 442
443impl<'d, T: Instance + 'd> embedded_io::asynch::Write for BufferedUart<'d, T> { 443impl<'d, T: Instance + 'd> embedded_io::asynch::Write for BufferedUart<'d, T> {
444 type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> 444 type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
445 where 445 where
446 Self: 'a; 446 Self: 'a;
447 447
@@ -455,7 +455,7 @@ impl<'d, T: Instance + 'd> embedded_io::asynch::Write for BufferedUart<'d, T> {
455 }) 455 })
456 } 456 }
457 457
458 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> 458 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a
459 where 459 where
460 Self: 'a; 460 Self: 'a;
461 461
@@ -465,7 +465,7 @@ impl<'d, T: Instance + 'd> embedded_io::asynch::Write for BufferedUart<'d, T> {
465} 465}
466 466
467impl<'d, T: Instance + 'd> embedded_io::asynch::Write for BufferedUartTx<'d, T> { 467impl<'d, T: Instance + 'd> embedded_io::asynch::Write for BufferedUartTx<'d, T> {
468 type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> 468 type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
469 where 469 where
470 Self: 'a; 470 Self: 'a;
471 471
@@ -479,7 +479,7 @@ impl<'d, T: Instance + 'd> embedded_io::asynch::Write for BufferedUartTx<'d, T>
479 }) 479 })
480 } 480 }
481 481
482 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> 482 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a
483 where 483 where
484 Self: 'a; 484 Self: 'a;
485 485