-
Notifications
You must be signed in to change notification settings - Fork 205
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
embedded-hal
v1 transition
#723
Conversation
One question for the reviewer, and the atsamd-hal community at large: how do we feel about removing the |
Might be unnecessary breakage that might be annoying, but otherwise I have no problem with it. |
impl<TIM: InterruptDrivenTimer> DelayNs for SleepingDelay<TIM> { | ||
fn delay_ns(&mut self, ns: u32) { | ||
// Determine how many cycles we need to run for this delay, if any | ||
// Avoid timers that run longer than a second because for 48 MHz-based timers, | ||
// there is no valid divisor + cycle count greater than ~1.3s, so we'd panic. | ||
let mut count: u32 = 1 + (us / NUM_US_IN_S); | ||
let mut loop_counter: u32 = 1 + (ns / NUM_NS_IN_S); | ||
|
||
// Start the timer and sleep! | ||
self.timer.start((us / count).nanos()); | ||
self.timer.start((ns / loop_counter).nanos()); | ||
self.timer.enable_interrupt(); | ||
loop { | ||
asm::wfi(); | ||
if self.timer.wait().is_ok() || self.interrupt_fired.load(atomic::Ordering::Relaxed) { | ||
self.interrupt_fired.store(false, atomic::Ordering::Relaxed); | ||
count -= 1; | ||
if count == 0 { | ||
loop_counter -= 1; | ||
if loop_counter == 0 { | ||
break; | ||
} | ||
} | ||
} | ||
self.timer.disable_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.
@sajattack, if there's one change I'd like to see get tested on HW, it'd be this one. I'm not sure if this implementation is correct.
Summary
Transition some modules to
embedded-hal
version 1:embedded-hal
forgpio
embedded-hal
fori2c
embedded-hal
forspi
embedded-hal-nb
forspi
Implementembedded-io
forspi
embedded-hal-nb
foruart
embedded-io
foruart
embedded-hal::DelayNs
and adjust timer implementationsembedded-hal::Pwm
Also removes the
unproven
Cargo feature as it's no longer necessary, and it's been a longtime source of confusion.Supersedes #715.
Closes #332.
Checklist
CHANGELOG.md
for the BSP or HAL updated#[allow]
certain lints where reasonable, but ideally justify those with a short comment.