stm32-rs / stm32g4xx-hal

Peripheral access API for STM32G4 series microcontrollers
Apache License 2.0
66 stars 48 forks source link

More ergonomic opamp API, add lock and pga functionality #113

Closed stabler closed 1 month ago

stabler commented 10 months ago

Here's an attempt to improve the ergonomics of the opamp API. This PR also adds the remaining PGA modes.

Key changes:

Things I think are good:

Things I don't love

Let me know what you think! @usbalbin I know you worked on this code recently, so you may have opinions!

stabler commented 10 months ago

Turns out I didn't need the unwrap after all (ff07d75)

usbalbin commented 10 months ago

I'm just a user, but from what I have seen so far this looks great. I really like not having 6 different modules with their own types. I also like not having to use the Option's for the output :)

Awesome :)

stabler commented 10 months ago

For those interested, here's a branch where I'm working on adding the remaining Pga modes: https://github.com/stabler/stm32g4xx-hal/commit/861a3e77aae5c4d2330a31c1ed80200d956e42cd

It's a bit heavy handed right now (separate structs for each Pga variant), so I'm going to see if I can consolidate a bit (and test it!) before I put a PR up

stabler commented 10 months ago

Ok I cleaned up the Pga implementation (a lot!), so I pulled it into this PR. I haven't tested all of this code on hardware yet (hoping to do that this weekend), but I'm feeling pretty good about the Pga implementation.

stabler commented 10 months ago

Nice compile-time error if you use the wrong input pin in the more complex Pga modes:

image