[−][src]Trait bl602_hal::prelude::_embedded_hal_adc_Channel
A marker trait to identify MCU pins that can be used as inputs to an ADC channel.
This marker trait denotes an object, i.e. a GPIO pin, that is ready for use as an input to the ADC. As ADCs channels can be supplied by multiple pins, this trait defines the relationship between the physical interface and the ADC sampling buffer.
struct Adc1; // Example ADC with single bank of 8 channels struct Gpio1Pin1<MODE>(PhantomData<MODE>); struct Analog(()); // marker type to denote a pin in "analog" mode // GPIO 1 pin 1 can supply an ADC channel when it is configured in Analog mode impl Channel<Adc1> for Gpio1Pin1<Analog> { type ID = u8; // ADC channels are identified numerically fn channel(&self) -> Self::ID { 7_u8 // GPIO pin 1 is connected to ADC channel 7 } } struct Adc2; // ADC with two banks of 16 channels struct Gpio2PinA<MODE>(PhantomData<MODE>); struct AltFun(()); // marker type to denote some alternate function mode for the pin // GPIO 2 pin A can supply an ADC channel when it's configured in some alternate function mode impl Channel<Adc2> for Gpio2PinA<AltFun> { type ID = (u8, u8); // ADC channels are identified by bank number and channel number fn channel(&self) -> Self::ID { (0, 3) // bank 0 channel 3 } }
Associated Types
type ID: Copy
Channel ID type
A type used to identify this ADC channel. For example, if the ADC has eight channels, this
might be a u8
. If the ADC has multiple banks of channels, it could be a tuple, like
(u8: bank_id, u8: channel_id)
.
Required methods
fn channel(&self) -> Self::ID
Get the specific ID that identifies this channel, for example 0_u8
for the first ADC
channel, if Self::ID is u8.