-
Notifications
You must be signed in to change notification settings - Fork 181
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
initial CRC support #202
initial CRC support #202
Conversation
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.
Thanks for the PR and sorry for the delayed reply!
Is there a reason you split the peripheral into a DR
and a CR
part instead of keeping them in one struct? Doing the latter would get rid of all the pointer dereferencing the CRC
struct to get access to the registers instead of doing a bunch of unsafe
pointer dereferencing
src/crc.rs
Outdated
_0: (), | ||
} | ||
|
||
#[allow(dead_code)] |
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.
This probably shouldn't be needed
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.
Really, why not just:
let mut crc = Crc::new(p.CRC, &mut rcc.ahb);
crc.reset();
crc.write(0x12345678);
let val = crc.read();
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.
Fixed, could you review it again?
37fb18c
to
43ad70e
Compare
src/crc.rs
Outdated
} | ||
|
||
pub fn write(&mut self, val: u32) { | ||
unsafe { self.crc.dr.write(|w| w.bits(val)) } |
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.
This unsafe
is unneeded:
https://docs.rs/stm32f1/0.11.0/stm32f1/stm32f103/crc/dr/struct.DR_W.html
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.
Fixed, thanks!
Looks good to me, thanks! |
Actually, would you mind adding an entry to the |
@TheZoq2 I updated |
Lovely, thanks! |
I'm complete newcomer on microcontroller & stm32, so please feel free to comment.
stm32f103c8
split
orconstrain
.prelude
caused byrustfmt
.