-
Notifications
You must be signed in to change notification settings - Fork 141
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
Implement embedded-hal 1.0 traits #431
Conversation
Hi, could I get a review of this soon? It's blocking me from updating some other things to embedded-hal 1.0. |
nrf-hal-common/src/delay.rs
Outdated
// The SysTick Reload Value register supports values between 1 and 0x00FFFFFF. | ||
const MAX_RVR: u32 = 0x00FF_FFFF; | ||
|
||
let mut total_rvr = us * (HFCLK_FREQ / 1_000_000); | ||
let mut total_rvr = ns * (HFCLK_FREQ / 1_000_000_000); |
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.
HFCLK_FREQ
is 64_000_000
, so isn't this always going to come out as zero?
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.
Whoops, good point. Fixed.
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.
That fix looks correct to me, and I can verify that the SYST-based DelayNs
implementation works given the fix, when it didn't before.
But I'm not a maintainer of this repository, and I haven't read through this whole PR.
I'll try these out with some of my stuff over the weekend and let you know if I see anything. I have only reviewed a couple of these so far — will get to the rest shortly. |
Also removed unused error variants.
Use u64 for intermediate value to avoid overflow.
Now that
embedded-hal
1.0 is released, this PR adds implementations of most of its relevant traits. For now I've added them alongside the existingembedded-hal
0.2 trait implementations, so that users can still use drivers based on the old traits. We can remove the old traits in a later release.I haven't implemented the
embedded-hal-nb
andembedded-hal-async
traits yet, and the I2C traits are also missing as the design has changed and implementing it correctly is non-trivial.