You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At this point, the USART and I2C APIs consume and drop the functions that they require. This ensures that they run correctly, but it means that the functions are no longer available after that. More dynamic use of the APIs is inhibited. For example, an application couldn't use the same pins for different things at various points. This would require the functions to still be available after use, so they can be unassigned from the pins.
I have some thoughts on a possible design:
Since the functions are only required while the peripherals are enabled, it might make sense to add a payload (with a generic type) to init_state::Enabled, which can be used to store the functions, and any other data that is only required while a peripheral is enabled.
Once init_state::Enabled is extended in that way, it should be possible to store mutable references to the functions in it. This would have the advantage of being easy to implement, and in some situations also easy to use, as the compiler would take care of tracking the references. More advanced use cases would need to add the lifetimes to various type signatures, though.
A better option is probably to move the functions into the peripheral (like it works now), and later return them again from disable.
The text was updated successfully, but these errors were encountered:
At this point, the USART and I2C APIs consume and drop the functions that they require. This ensures that they run correctly, but it means that the functions are no longer available after that. More dynamic use of the APIs is inhibited. For example, an application couldn't use the same pins for different things at various points. This would require the functions to still be available after use, so they can be unassigned from the pins.
I have some thoughts on a possible design:
init_state::Enabled
, which can be used to store the functions, and any other data that is only required while a peripheral is enabled.init_state::Enabled
is extended in that way, it should be possible to store mutable references to the functions in it. This would have the advantage of being easy to implement, and in some situations also easy to use, as the compiler would take care of tracking the references. More advanced use cases would need to add the lifetimes to various type signatures, though.disable
.The text was updated successfully, but these errors were encountered: