Struct ChargerDetector

Source
pub struct ChargerDetector<D> { /* private fields */ }
Expand description

A MAX14578E/MAX14578AE USB charger detector

Implementations§

Source§

impl<D: I2c> ChargerDetector<D>

Source

pub fn new(i2c_dev: D) -> Self

Create a new ChargerDetector

Source

pub async fn device_id(&mut self) -> Result<u8, D::Error>

Get the device ID. Should return 0b0010_0001.

Source

pub async fn enable_irq(&mut self, enable: bool) -> Result<(), D::Error>

Enable the /INT pin of the charger detector

Source

pub async fn irq_status(&mut self) -> Result<InterruptStatus, D::Error>

Read and clear the current interrupt status flags

Source

pub async fn set_usb_switch<T: DelayNs>( &mut self, closed: bool, delay: T, ) -> Result<(), D::Error>

Close or open the USB switch.

The switch should be closed after a USB data port is detected and re-opened when the data port is detached.

Auto Trait Implementations§

§

impl<D> Freeze for ChargerDetector<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for ChargerDetector<D>
where D: RefUnwindSafe,

§

impl<D> Send for ChargerDetector<D>
where D: Send,

§

impl<D> Sync for ChargerDetector<D>
where D: Sync,

§

impl<D> Unpin for ChargerDetector<D>
where D: Unpin,

§

impl<D> UnwindSafe for ChargerDetector<D>
where D: UnwindSafe,

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>,

Source§

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>,

Source§

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.