Struct driver_cp2130::Cp2130

source ·
pub struct Cp2130 { /* private fields */ }
Expand description

CP2130 provides methods to interact with the device, as well as create new spi and gpio connectors.

Implementations§

source§

impl Cp2130

source

pub fn new( device: UsbDevice<UsbContext>, descriptor: DeviceDescriptor, options: UsbOptions ) -> Result<Self, Error>

Create a new CP2130 instance from a libusb device and descriptor

source

pub fn info(&self) -> Info

Fetch information for the connected device

source

pub fn reset(&self) -> Result<(), Error>

source

pub fn spi( &self, channel: u8, config: SpiConfig, cs_pin: Option<u8> ) -> Result<Spi, Error>

Create an SPI connector with an optional CS pin

source

pub fn gpio_out( &self, index: u8, mode: GpioMode, level: GpioLevel ) -> Result<OutputPin, Error>

Create a GPIO OutputPin

source

pub fn gpio_in(&self, index: u8) -> Result<InputPin, Error>

Create a GPIO InputPin

Trait Implementations§

source§

impl Device for Cp2130

Underlying device functions

source§

fn spi_read(&self, buff: &mut [u8]) -> Result<usize, Error>

Read from the SPI device
source§

fn spi_write(&self, buff: &[u8]) -> Result<(), Error>

Write to the SPI device
source§

fn spi_write_read( &self, buff_out: &[u8], buff_in: &mut [u8] ) -> Result<usize, Error>

source§

fn version(&self) -> Result<u16, Error>

Fetch the CP2130 chip version
source§

fn set_gpio_mode_level( &self, pin: u8, mode: GpioMode, level: GpioLevel ) -> Result<(), Error>

Set the mode and level for a given GPIO pin
source§

fn get_gpio_values(&self) -> Result<GpioLevels, Error>

Fetch the values for all GPIO pins
source§

fn get_gpio_level(&self, pin: u8) -> Result<bool, Error>

Fetch the value for a given GPIO pin

Auto Trait Implementations§

§

impl Freeze for Cp2130

§

impl RefUnwindSafe for Cp2130

§

impl Send for Cp2130

§

impl Sync for Cp2130

§

impl Unpin for Cp2130

§

impl UnwindSafe for Cp2130

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.