pub trait Gpio<'a> {
// Required methods
fn setup(
&mut self,
pin: u32,
callback: impl FnMut(u32, EventType) + 'a,
) -> Result<(), i32>;
fn set_direction(
&mut self,
pin: u32,
direction: Direction,
) -> Result<(), i32>;
fn set_output_mode(&mut self, pin: u32, mode: OutputMode) -> Result<(), i32>;
fn set_pull_resistor(
&mut self,
pin: u32,
resistor: PullResistor,
) -> Result<(), i32>;
fn set_event_trigger(
&mut self,
pin: u32,
trigger: EventTrigger,
) -> Result<(), i32>;
fn set_output(&mut self, pin: u32, value: bool);
fn get_input(&self, pin: u32) -> bool;
}Expand description
A trait that defines a standard interface for a GPIO driver. This trait manages a collection of GPIO pins.
Required Methods§
Sourcefn setup(
&mut self,
pin: u32,
callback: impl FnMut(u32, EventType) + 'a,
) -> Result<(), i32>
fn setup( &mut self, pin: u32, callback: impl FnMut(u32, EventType) + 'a, ) -> Result<(), i32>
Initializes a GPIO pin and registers a callback for events.
Sourcefn set_direction(&mut self, pin: u32, direction: Direction) -> Result<(), i32>
fn set_direction(&mut self, pin: u32, direction: Direction) -> Result<(), i32>
Sets the direction of a GPIO pin.
Sourcefn set_output_mode(&mut self, pin: u32, mode: OutputMode) -> Result<(), i32>
fn set_output_mode(&mut self, pin: u32, mode: OutputMode) -> Result<(), i32>
Sets the output mode of a GPIO pin.
Sourcefn set_pull_resistor(
&mut self,
pin: u32,
resistor: PullResistor,
) -> Result<(), i32>
fn set_pull_resistor( &mut self, pin: u32, resistor: PullResistor, ) -> Result<(), i32>
Sets the internal pull-up or pull-down resistor for a GPIO pin.
Sourcefn set_event_trigger(
&mut self,
pin: u32,
trigger: EventTrigger,
) -> Result<(), i32>
fn set_event_trigger( &mut self, pin: u32, trigger: EventTrigger, ) -> Result<(), i32>
Sets the event trigger for a GPIO pin.
Sourcefn set_output(&mut self, pin: u32, value: bool)
fn set_output(&mut self, pin: u32, value: bool)
Sets the output level of a GPIO pin.
value is true for high, false for low.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.