Skip to content

Commit 1c674fc

Browse files
Merge pull request #244 from ferrous-systems/radio-fixes
Fix radio timeout
2 parents 9be51f0 + 6804d52 commit 1c674fc

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

nrf52-code/boards/dk-solution/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ impl Timer {
179179

180180
/// Start the timer with the given microsecond duration.
181181
pub fn start(&mut self, microseconds: u32) {
182-
self.0.cc(0).clear_events();
182+
self.0.stop();
183+
self.0.clear();
183184
self.0.cc(0).write(microseconds);
184-
self.0.task_clear();
185-
self.0.task_start();
185+
self.0.start();
186186
}
187187

188188
/// If the timer has finished, resets it and returns true.

nrf52-code/boards/dk-solution/src/radio.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,15 @@ impl<'d> Radio<'d> {
454454
// Check if either receive is done or timeout occured
455455
loop {
456456
match recv.is_done() {
457-
Ok(crc) => break Ok(crc),
458-
Err(err) => match err {
459-
nb::Error::Other(crc) => break Err(Error::Crc(crc)),
460-
nb::Error::WouldBlock => (),
461-
},
457+
Ok(crc) => {
458+
break Ok(crc);
459+
}
460+
Err(nb::Error::Other(crc)) => {
461+
break Err(Error::Crc(crc));
462+
}
463+
Err(nb::Error::WouldBlock) => {
464+
// do nothing
465+
}
462466
}
463467

464468
if timer.reset_if_finished() {

nrf52-code/boards/dk/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ impl Timer {
151151

152152
/// Start the timer with the given microsecond duration.
153153
pub fn start(&mut self, microseconds: u32) {
154-
self.0.cc(0).clear_events();
154+
self.0.stop();
155+
self.0.clear();
155156
self.0.cc(0).write(microseconds);
156-
self.0.task_clear();
157-
self.0.task_start();
157+
self.0.start();
158158
}
159159

160160
/// If the timer has finished, resets it and returns true.

nrf52-code/boards/dk/src/radio.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,15 @@ impl<'d> Radio<'d> {
454454
// Check if either receive is done or timeout occured
455455
loop {
456456
match recv.is_done() {
457-
Ok(crc) => break Ok(crc),
458-
Err(err) => match err {
459-
nb::Error::Other(crc) => break Err(Error::Crc(crc)),
460-
nb::Error::WouldBlock => (),
461-
},
457+
Ok(crc) => {
458+
break Ok(crc);
459+
}
460+
Err(nb::Error::Other(crc)) => {
461+
break Err(Error::Crc(crc));
462+
}
463+
Err(nb::Error::WouldBlock) => {
464+
// do nothing
465+
}
462466
}
463467

464468
if timer.reset_if_finished() {

0 commit comments

Comments
 (0)