Skip to content
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

Merged
merged 30 commits into from
May 1, 2024
Merged

embedded-hal v1 transition #723

merged 30 commits into from
May 1, 2024

Conversation

jbeaurivage
Copy link
Contributor

@jbeaurivage jbeaurivage commented Jan 31, 2024

Summary

Transition some modules to embedded-hal version 1:

  • Implement embedded-hal for gpio
  • Implement embedded-hal fori2c
  • Implement embedded-hal for spi
  • Implement embedded-hal-nb for spi
  • Implement embedded-io for spi
  • Implement embedded-hal-nb for uart
  • Implement embedded-io for uart
  • Fix T1 BSP examples
  • Implement embedded-hal::DelayNs and adjust timer implementations
  • Implement embedded-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
  • All new or modified code is well documented, especially public items
  • No new warnings or clippy suggestions have been introduced - CI will deny clippy warnings by default! You may #[allow] certain lints where reasonable, but ideally justify those with a short comment.

@jbeaurivage jbeaurivage changed the base branch from embedded-hal-1 to master April 29, 2024 14:38
@jbeaurivage
Copy link
Contributor Author

One question for the reviewer, and the atsamd-hal community at large: how do we feel about removing the prelude module entirely? Seems like this pattern is less and less recommended, and it mostly reexported ehal v0.2 traits anyways.

@jbeaurivage jbeaurivage requested a review from sajattack April 29, 2024 20:17
@sajattack
Copy link
Member

One question for the reviewer, and the atsamd-hal community at large: how do we feel about removing the prelude module entirely? Seems like this pattern is less and less recommended, and it mostly reexported ehal v0.2 traits anyways.

Might be unnecessary breakage that might be annoying, but otherwise I have no problem with it.

Comment on lines +59 to 81
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();
}
}
Copy link
Contributor Author

@jbeaurivage jbeaurivage May 1, 2024

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.

@sajattack sajattack merged commit 3847d0f into atsamd-rs:master May 1, 2024
107 checks passed
@jbeaurivage jbeaurivage deleted the ehal-1 branch May 1, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update embedded-hal dependency to 1.0
2 participants