-
Notifications
You must be signed in to change notification settings - Fork 8
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
Improve split between USART's receiver and transmitter #210
Conversation
This change doesn't make a whole lot of sense by itself, but it is necessary for something else I'm working on (see next commit). Since that commit is already big enough, I've extracted this change into a separate one.
It was already possible to split a USART peripheral into a receiver and transmitter, but that feature was mostly useless. Both still borrowed the original USART, which severely limited the use cases. It wasn't possible to move a receiver or transmitter somewhere else, without also moving the USART or moving the USART into a `static`. This commit changes this, by creating a strong split that doesn't require any borrowing. `Rx` and `Tx` can just be moved out of `USART` and used independently. To do anything with `USART` that would affect either of them (disabling it, for example), they have to be moved back in. The `RegProxy` stuff got a bit crazy here, but I wasn't able to find a simpler solution. The only alternative I can think of is not use `RegProxy` and instead unsafely access the peripheral everywhere it is used.
This is a convenience feature that makes functionality accessible on `USART` directly, as long as `Rx` or `Tx` haven't been moved out.
Please don't merge. I'm having problems downstream, possibly related to receiving. I'll investigate. |
Okay, whatever my problem is, I don't think it's related to this pull request. Now everything works again. Since the whole thing happened at the same time GDB/OpenOCD were acting up, I'm inclined to blame those two. I'll keep an eye out, but for now, I don't think there's anything wrong with this pull request. Feel free to review/merge. |
I really dislike the magic numbers for the TXDAT address.
and getting the address itself inside
? With that, you could remove all other additions to the trait, which would simplify the code quite a bit and be worth it. (In my opinion, certainly not a blocker) LGTM otherwise |
I also use the method described by david in the EFM32PG12-HAL. |
Thank you for the suggestions, both of you. I've pushed a new commit that gets rid of the magic numbers.
I might be misunderstanding what you're saying, but I think the other additions to the trait are required because of We could just get rid of
But in any case, I'd prefer to merge this pull request as-is and continue this discussion elsewhere (I've opened #211). Should we decide to get rid of |
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.
Looks good now!
No description provided.