Skip to content

Also release owned Pins with Usart::free()#261

Merged
jonas-schievink merged 4 commits into
nrf-rs:masterfrom
timokroeger:usart-free-pins
Oct 30, 2020
Merged

Also release owned Pins with Usart::free()#261
jonas-schievink merged 4 commits into
nrf-rs:masterfrom
timokroeger:usart-free-pins

Conversation

@timokroeger
Copy link
Copy Markdown
Contributor

Return ownership of the pins back to the user when calling free()
Useful to multiplex a single USARTE instance to multiple serial connections on different pins (for smaller NRF52 devices which only have one USARTE instance).

Alternative: Only take a reference to the pins in in new().
Please let me know which one is the preferred approach.

@jonas-schievink
Copy link
Copy Markdown
Contributor

Alternative: Only take a reference to the pins in in new().

This would mean that Usart<_>: 'static never holds and prevent usage of Usart in RTIC resources, so we probably shouldn't do that.

I think we can do better than storing the Pins instance in every Usart though – what if we just read from the USART's pin configuration registers in free and create the pins from those? That way we don't have to pay for the extra Pins storage.

@timokroeger
Copy link
Copy Markdown
Contributor Author

Reading back the pins from the peripheral is a nifty idea. Going to try that tomorrow.

@Yatekii
Copy link
Copy Markdown
Contributor

Yatekii commented Oct 29, 2020

Cool stuff, thanks for doing this! I required this a few times already but just for debugging things and I just used unsfe for that :P

I think we can do better than storing the Pins instance in every Usart though – what if we just read from the USART's pin configuration registers in free and create the pins from those? That way we don't have to pay for the extra Pins storage.

I fully agree with this :)

Copy link
Copy Markdown
Contributor

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Can you also add a changelog entry?

Comment thread nrf-hal-common/src/gpio.rs Outdated
@jonas-schievink jonas-schievink merged commit e932eea into nrf-rs:master Oct 30, 2020
@timokroeger timokroeger deleted the usart-free-pins branch October 30, 2020 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants