Conversation
Found out that the offset for setting the pull up/down resistor is wrong during #52
| use super::*; | ||
|
|
||
| let (gpioa, _) = init(); | ||
| let pin = gpioa.pa8; |
There was a problem hiding this comment.
Any reason you're picking PA8 for all these tests?
There was a problem hiding this comment.
No, not really. I can spread out to a couple more pins. Perhaps both sides of 8 since I believe some settings are split into different registers for pin 0..=7 and 8..=15?
There was a problem hiding this comment.
Do you think we should test more ports too, like B, C etc?
There was a problem hiding this comment.
You could conceivably do all the pins if you converted each to an ErasedPin and shoved them all into an array? If you wanted to you could modify the Parts struct defined here to implement that instead of doing it here?
| use hal::stm32; | ||
| use stm32h5xx_hal::{self as hal, gpio}; | ||
|
|
||
| pub const F_SYS: HertzU32 = HertzU32::MHz(16); |
There was a problem hiding this comment.
Shouldn't this be used to set the core clock frequency? Currently, it is set to 250MHz on line 113, so deriving the cycles per µs is incorrect here.
There was a problem hiding this comment.
Also, I just put up #61, which should help with doing this derivation
| pub fn await_lo<const CYCLES_PER_US: u32>( | ||
| timer: &Timer<CYCLES_PER_US>, | ||
| pin: u8, | ||
| timeout: MicrosDurationU32, | ||
| ) -> Result<MicrosDurationU32, ErrorTimedOut> { | ||
| await_p(timer, || is_pax_low(pin), timeout) | ||
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| pub fn await_hi<const CYCLES_PER_US: u32>( | ||
| timer: &Timer<CYCLES_PER_US>, | ||
| pin: u8, | ||
| timeout: MicrosDurationU32, | ||
| ) -> Result<MicrosDurationU32, ErrorTimedOut> { | ||
| await_p(timer, || !is_pax_low(pin), timeout) | ||
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| pub fn await_p<const CYCLES_PER_US: u32>( | ||
| timer: &Timer<CYCLES_PER_US>, | ||
| mut p: impl FnMut() -> bool, | ||
| timeout: MicrosDurationU32, | ||
| ) -> Result<MicrosDurationU32, ErrorTimedOut> { | ||
| let before = timer.now(); | ||
|
|
||
| loop { | ||
| let passed_time = timer.now() - before; | ||
| if p() { | ||
| return Ok(passed_time); | ||
| } | ||
| if passed_time > timeout { | ||
| return Err(ErrorTimedOut); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
I put up #61. Maybe that will help with some of these waiting operations?
Adds some simple gpio self tests to be run on a nucleo-h533
See #50