-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add more peripherals for the stm32f030 #6
Conversation
|
||
impl<USART> embedded_hal::serial::Read<u8> for Rx<USART> | ||
where | ||
USART: Deref<Target = SerialRegisterBlock>, |
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 again feels kinda sketchy to me, as it is relying on all the USART peripherals continuing to use the same register block definition.
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.
If it's going to break, we're getting a compile error, so in that's ok. In the worst case you can do some macro based approach where you can separately implement the different register blocks.
Added all possible pin combinations and split up the pin traits for Serial. Also wrapped pin traits in a macro, otherwise the selection based on features is really large |
src/serial.rs
Outdated
usart_pins! { | ||
// TODO WTF look at this again, in the datasheet PB10 is both tx and rx | ||
// USART3: (gpiob::PB10, AF4, gpiob::PA11, AF4), | ||
USART3: (gpioc::PC4<Alternate<AF1>>, gpioc::PC5<Alternate<AF1>>), |
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.
Instead of specifying pairs wouldn't it make more sense to actually single out the TX/RX functions and let the user chose any possible combination? Using this macro in this way means you're passing on a few possible combinations, e.g. you use also use PC10 and PC5 for USART3, or PC4 and PC11.
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.
Thats the whole purpose of the separate Rx and Tx traits, the combinations are done by the templates. The only reason i defined them pairwise is because that what ST seems to have done and it seemed cleaner this way.
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.
If it would be helpful I could probably rig that macro so that you just specify each USART once and then list all the TX pins and then all the RX pins.
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.
@HarkonenBade That sounds like a good idea.
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.
@HarkonenBade Agree. We could also reuse that for the spi, where the pin combinations aren't that clear.
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.
Done, if @david-sawatzke could pull the fresh commit from https://github.com/HarkonenBade/stm32f0xx-hal/tree/stm32f030_v2 that would be great.
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.
I took some slight liberties with making the macro syntax a a bit more verbose, but I think it makes it a lot clearer what is going on.
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.
@HarkonenBade Yeah, that's better. The syntax also seems more "rusty".
e9d6bba
to
e1bced0
Compare
Is this still WIP? Looks pretty much complete to me. |
I'd also like to port spi & i2c to the same approach as serial and add the 2nd instance |
Currently getting a rustc panic
EDIT: |
Found a way to confirm binding
da2563a
to
2aa1d1b
Compare
I think this is ready to merge now |
stm32f030x8 = ["stm32f030", "stm32f0/stm32f0x0"] | ||
stm32f030xc = ["stm32f030", "stm32f0/stm32f0x0"] | ||
stm32f030x8 = ["stm32f030"] | ||
stm32f030xc = ["stm32f030"] |
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.
Snuck in another unrelated change, eh? ;)
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.
It's technically not completely unrelated
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.
LGTM, thanks.
TODO