esp_idf_svc::hal::usb_serial

Struct UsbSerialDriver

Source
pub struct UsbSerialDriver<'d>(/* private fields */);
Expand description

USB-SERIAL driver

Implementations§

Source§

impl<'d> UsbSerialDriver<'d>

Source

pub fn new( usb_serial: impl Peripheral<P = USB_SERIAL> + 'd, _usb_d_min: impl Peripheral<P = Gpio18>, _usb_d_plus: impl Peripheral<P = Gpio19>, config: &Config, ) -> Result<UsbSerialDriver<'d>, EspError>

Create a new USB Serial driver

§Arguments
  • usb_serial: The USB Serial peripheral
  • config: The driver configuration
  • usb_d_min: The USB D- GPIO pin
  • usb_d_plus: The USB D+ GPIO pin
Source

pub fn is_connected(&self) -> bool

Check if the USB Serial is connected

Source

pub fn read(&mut self, buf: &mut [u8], timeout: u32) -> Result<usize, EspError>

Read bytes into a slice

§Arguments
  • buf: The buffer to read into
  • timeout: The timeout in ticks
§Returns

The number of bytes read or an error if the operation failed or the timeout was reached

Source

pub fn write(&mut self, bytes: &[u8], timeout: u32) -> Result<usize, EspError>

Write bytes from a slice

§Arguments
  • bytes: The bytes to write
  • timeout: The timeout in ticks
§Returns

The number of bytes written or an error if the operation failed or the timeout was reached

Trait Implementations§

Source§

impl Drop for UsbSerialDriver<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl ErrorType for UsbSerialDriver<'_>

Source§

type Error = EspIOError

Error type of all the IO operations on this type.
Source§

impl Read for UsbSerialDriver<'_>

Source§

fn read( &mut self, buf: &mut [u8], ) -> Result<usize, <UsbSerialDriver<'_> as ErrorType>::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl Write<u8> for UsbSerialDriver<'_>

Source§

type Error = EspError

Write error
Source§

fn flush( &mut self, ) -> Result<(), Error<<UsbSerialDriver<'_> as Write<u8>>::Error>>

Ensures that none of the previously written words are still buffered
Source§

fn write( &mut self, byte: u8, ) -> Result<(), Error<<UsbSerialDriver<'_> as Write<u8>>::Error>>

Writes a single word to the serial interface
Source§

impl Write for UsbSerialDriver<'_>

Source§

fn write( &mut self, buf: &[u8], ) -> Result<usize, <UsbSerialDriver<'_> as ErrorType>::Error>

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<(), <UsbSerialDriver<'_> as ErrorType>::Error>

Flush this output stream, blocking until all intermediately buffered contents reach their destination.
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Write an entire buffer into this writer. Read more
Source§

fn write_fmt( &mut self, fmt: Arguments<'_>, ) -> Result<(), WriteFmtError<Self::Error>>

Write a formatted string into this writer, returning any error encountered. Read more
Source§

impl Write for UsbSerialDriver<'_>

Source§

fn write_str(&mut self, s: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a [char] into this writer, returning whether the write succeeded. Read more
1.0.0§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the [write!] macro with implementors of this trait. Read more
Source§

impl Send for UsbSerialDriver<'_>

Auto Trait Implementations§

§

impl<'d> Freeze for UsbSerialDriver<'d>

§

impl<'d> RefUnwindSafe for UsbSerialDriver<'d>

§

impl<'d> !Sync for UsbSerialDriver<'d>

§

impl<'d> Unpin for UsbSerialDriver<'d>

§

impl<'d> !UnwindSafe for UsbSerialDriver<'d>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.