pub struct GpioToken(/* private fields */);
Expand description
Global instance to help make gpio in Rust slightly safer.
§Safety
To help with safety, the rust types use a global instance of a gpio-token. Methods will take a mutable reference to this, which will require either a single thread in the application code, or something like a mutex or critical section to manage. The operation methods are still unsafe, because we have no control over what happens with the gpio operations outside of Rust code, but this will help make the Rust usage at least better.
Implementations§
Source§impl GpioToken
impl GpioToken
Sourcepub unsafe fn get_instance() -> Option<GpioToken>
pub unsafe fn get_instance() -> Option<GpioToken>
Retrieves the gpio token.
§Safety
This is unsafe because lots of code in zephyr operates on the gpio drivers. The user of the gpio subsystem, in general should either coordinate all gpio access across the system (the token coordinates this only within Rust code), or verify that the particular gpio driver and methods are thread safe.