embassy-rs / embassy

Modern embedded framework, using Rust and async.
https://embassy.dev
Apache License 2.0
4.79k stars 650 forks source link

Improve stm32 ucpd packet reception #3084

Closed sjoerdsimons closed 2 weeks ago

sjoerdsimons commented 2 weeks ago

When using stm32g071b-disco as a PD interceptor i noticed especially GoodCrc packets got missed and sometimes corrupted packets were received. This PR seems to fix both issues :)

timokroeger commented 2 weeks ago

Changes look good to me and for the very fast GoodCRC messages that totally makes sense. Now that the receiver is disabled on drop only, it could be enabled in split_pd_phy().

Trying to remember why I implemented it the way it was before. I think it was to match the (unbuffered) uart behaviour where data can only be received when rx future is active.

In case you are interested: https://github.com/timokroeger/usb-pd-lib-embassy I played around a bit a tried to implement basic PD communication some time ago.

sjoerdsimons commented 2 weeks ago

Changes look good to me and for the very fast GoodCRC messages that totally makes sense. Now that the receiver is disabled on drop only, it could be enabled in split_pd_phy().

Good point; changed that.

Trying to remember why I implemented it the way it was before. I think it was to match the (unbuffered) uart behaviour where data can only be received when rx future is active.

In case you are interested: https://github.com/timokroeger/usb-pd-lib-embassy I played around a bit a tried to implement basic PD communication some time ago.

Nice didn't see that before; fwiw i've been contributing to https://github.com/fmckeogh/usb-pd-rs/tree/main/usb-pd for the packet parsing; To put together a bit of tooling to debug/analyse usb-pd communications: https://github.com/sjoerdsimons/ucpd-tools