Trait opentitanlib::io::gpio::GpioPin
source · pub trait GpioPin {
// Required methods
fn read(&self) -> Result<bool>;
fn write(&self, value: bool) -> Result<()>;
fn set_mode(&self, mode: PinMode) -> Result<()>;
fn set_pull_mode(&self, mode: PullMode) -> Result<()>;
// Provided methods
fn analog_read(&self) -> Result<f32> { ... }
fn analog_write(&self, _volts: f32) -> Result<()> { ... }
fn set(
&self,
mode: Option<PinMode>,
value: Option<bool>,
pull: Option<PullMode>,
analog_value: Option<f32>
) -> Result<()> { ... }
fn get_internal_pin_name(&self) -> Option<&str> { ... }
}
Expand description
A trait which represents a single GPIO pin.
Required Methods§
sourcefn set_mode(&self, mode: PinMode) -> Result<()>
fn set_mode(&self, mode: PinMode) -> Result<()>
Sets the mode of the GPIO pin as input, output, or open drain I/O.
sourcefn set_pull_mode(&self, mode: PullMode) -> Result<()>
fn set_pull_mode(&self, mode: PullMode) -> Result<()>
Sets the weak pull resistors of the GPIO pin.
Provided Methods§
sourcefn analog_read(&self) -> Result<f32>
fn analog_read(&self) -> Result<f32>
Reads the analog value of the GPIO pin in Volts. AnalogInput
mode disables digital
circuitry for better results, but this method may also work in other modes.
sourcefn analog_write(&self, _volts: f32) -> Result<()>
fn analog_write(&self, _volts: f32) -> Result<()>
Sets the analog value of the GPIO pin to value
Volts, must be in AnalogOutput
mode.
sourcefn set(
&self,
mode: Option<PinMode>,
value: Option<bool>,
pull: Option<PullMode>,
analog_value: Option<f32>
) -> Result<()>
fn set( &self, mode: Option<PinMode>, value: Option<bool>, pull: Option<PullMode>, analog_value: Option<f32> ) -> Result<()>
Simultaneously sets mode, value, and weak pull, some transports may guarantee atomicity.
sourcefn get_internal_pin_name(&self) -> Option<&str>
fn get_internal_pin_name(&self) -> Option<&str>
Not meant for API clients, this method returns the pin name as it is known to the
transport (which may have been through one or more alias mappings from the name provided
by the API client.) This method is used by implementations of GpioMonitoring
.