pub struct Channel<H, ADC: AdcOps<H>> { /* private fields */ }
Expand description

Representation of any ADC Channel.

Typically, distinct types are used per channel, like for example Pin<mode::Analog, PC0>. In some situations, however, a type is needed which can represent any channel. This is required to, for example, store multiple channels in an array.

Channel is such a type. It can be created by calling the into_channel() method of a distinct type:

let a0 = pins.a0.into_analog_input(&mut adc);
let a1 = pins.a1.into_analog_input(&mut adc);

let channels: [atmega_hal::adc::Channel; 2] = [
    a0.into_channel(),
    a1.into_channel(),
];

for ch in channels.iter() {
    adc.read_blocking(ch);
}

Implementations§

source§

impl<H, ADC: AdcOps<H>> Channel<H, ADC>

source

pub fn new<CH: AdcChannel<H, ADC>>(ch: CH) -> Self

Trait Implementations§

source§

impl<H, ADC: AdcOps<H>> AdcChannel<H, ADC> for Channel<H, ADC>

source§

fn channel(&self) -> ADC::Channel

Auto Trait Implementations§

§

impl<H, ADC> Freeze for Channel<H, ADC>
where <ADC as AdcOps<H>>::Channel: Freeze,

§

impl<H, ADC> RefUnwindSafe for Channel<H, ADC>
where H: RefUnwindSafe, <ADC as AdcOps<H>>::Channel: RefUnwindSafe,

§

impl<H, ADC> Send for Channel<H, ADC>
where H: Send, <ADC as AdcOps<H>>::Channel: Send,

§

impl<H, ADC> Sync for Channel<H, ADC>
where H: Sync, <ADC as AdcOps<H>>::Channel: Sync,

§

impl<H, ADC> Unpin for Channel<H, ADC>
where H: Unpin, <ADC as AdcOps<H>>::Channel: Unpin,

§

impl<H, ADC> UnwindSafe for Channel<H, ADC>
where H: UnwindSafe, <ADC as AdcOps<H>>::Channel: 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>,

§

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.