Skip to content

Remove Started/Stopped type state from Rtc#252

Merged
jonas-schievink merged 2 commits intonrf-rs:masterfrom
timokroeger:no-rtc-typestate
Oct 26, 2020
Merged

Remove Started/Stopped type state from Rtc#252
jonas-schievink merged 2 commits intonrf-rs:masterfrom
timokroeger:no-rtc-typestate

Conversation

@timokroeger
Copy link
Copy Markdown
Contributor

The type states make it difficult to enable and disable the RTC on demand with RTIC.
Started/Stopped types were only used to restrict the usage of set_prescaler() to a disabled RTC.
Pass the prescaler as argument to the costructor instead.

This made it really difficult to enable and disable the RTC on demand with RTIC.
Pass the prescaler as argument to the costructor.
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.

Thanks, this looks reasonable!

This does mean that you can't change the prescaler after creating the RTC though. I don't think that's a common thing to do, so it should be fine, but we might want to add a fn free(self) -> RTC to enable that use case again.

@jonas-schievink
Copy link
Copy Markdown
Contributor

Oh, it already has a release function that does exactly that.

@jonas-schievink jonas-schievink merged commit 63cba63 into nrf-rs:master Oct 26, 2020
@timokroeger timokroeger deleted the no-rtc-typestate branch October 27, 2020 10:52
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.

2 participants