USB#63
Conversation
| } | ||
|
|
||
| // Echo back in upper case | ||
| for c in buf[0..count].iter_mut() { | ||
| if 0x61 <= *c && *c <= 0x7a { |
There was a problem hiding this comment.
Any ideas for solving this?
error: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.87.0`
--> examples/usb_serial.rs:72:32
|
72 | if let Ok(s) = str::from_utf8(&buf[0..count]) {
| ^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv
note: the lint level is defined here
--> examples/usb_serial.rs:2:9
There was a problem hiding this comment.
We could bump up the MSRV? We haven't published a crate yet...
There was a problem hiding this comment.
Also, instead of doing this uppercasing manually, you could just call c.to_ascii_uppercase(): https://doc.rust-lang.org/stable/core/primitive.char.html#method.to_ascii_uppercase (and use map instead of a for loop)
There was a problem hiding this comment.
Any suggestions for a MSRV?
There was a problem hiding this comment.
Might as well bump it to 1.88?
|
Note that this is only tested on a Nucleo-H533RE |
| // Enable USB peripheral | ||
| rcc.apb2enr().modify(|_, w| w.usben().set_bit()); | ||
|
|
||
| // Reset USB peripheral | ||
| rcc.apb2rstr().modify(|_, w| w.usbrst().set_bit()); | ||
| rcc.apb2rstr().modify(|_, w| w.usbrst().clear_bit()); |
There was a problem hiding this comment.
How about:
rec::Usb { _marker: PhantomData }.reset().enable();
|
|
||
| fn enable() { | ||
| cortex_m::interrupt::free(|_| { | ||
| let rcc = unsafe { &*stm32::RCC::ptr() }; |
There was a problem hiding this comment.
nit: move this closer to where it's first used.
|
Note: I have not tested this since b6c7432 |
| /// Data negative pin | ||
| pin_dm: DmPin, | ||
| /// Data positive pin | ||
| pin_dp: DpPin, |
There was a problem hiding this comment.
Do we need to hang on to these pins? Doesn't looks like they get used anywhere. Could just consume them in the new function so they can't get used anywhere else (e.g. SPI driver does this).
There was a problem hiding this comment.
Do we need to hang on to these pins? [...]
I dont think we do
| impl fmt::Debug for UsbDevice { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| f.debug_struct("Peripheral") | ||
| .field("usb", &"USB") | ||
| .field("pin_dm", &self.pin_dm) | ||
| .field("pin_dp", &self.pin_dp) | ||
| .finish() | ||
| } | ||
| } |
There was a problem hiding this comment.
this is out of date. how about just using the Debug derive for this?
There was a problem hiding this comment.
We actually don not use the pins for anything once they are put into the struct. As in we have no release method. Should I remove them from the struct?
There was a problem hiding this comment.
fields `pin_dm` and `pin_dp` are never read
`UsbDevice` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
`#[warn(dead_code)]` on by default
There was a problem hiding this comment.
Yep. Latest changes look good.
| fn format(&self, f: defmt::Formatter) { | ||
| defmt::write!( | ||
| f, | ||
| "Peripheral {{ usb: USB, pin_dm: {}, pin_dp: {}}}", |
astapleton
left a comment
There was a problem hiding this comment.
Awesome. Thanks for doing this! Looks good to me.
No description provided.