Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Pin::is_acore_interrupt_set` (#793)
- `Pin::is_acore_non_maskable_interrupt_set` (#793)
- `Pin::enable_hold` (#793)
- Removed the generic return type for ADC reads (#792)

### Breaking

Expand Down
7 changes: 3 additions & 4 deletions esp-hal-common/src/analog/adc/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,14 @@ impl<'d, ADC1> ADC<'d, ADC1> {
}
}

impl<'d, ADCI, WORD, PIN> OneShot<ADCI, WORD, AdcPin<PIN, ADCI>> for ADC<'d, ADCI>
impl<'d, ADCI, PIN> OneShot<ADCI, u16, AdcPin<PIN, ADCI>> for ADC<'d, ADCI>
where
WORD: From<u16>,
PIN: Channel<ADCI, ID = u8>,
ADCI: RegisterAccess,
{
type Error = ();

fn read(&mut self, _pin: &mut AdcPin<PIN, ADCI>) -> nb::Result<WORD, Self::Error> {
fn read(&mut self, _pin: &mut AdcPin<PIN, ADCI>) -> nb::Result<u16, Self::Error> {
if self.attenuations[AdcPin::<PIN, ADCI>::channel() as usize] == None {
panic!(
"Channel {} is not configured reading!",
Expand Down Expand Up @@ -397,7 +396,7 @@ where
// Mark that no conversions are currently in progress
self.active_channel = None;

Ok(converted_value.into())
Ok(converted_value)
}
}

Expand Down
7 changes: 3 additions & 4 deletions esp-hal-common/src/analog/adc/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,16 +613,15 @@ impl AdcCalEfuse for ADC2 {
}
}

impl<'d, ADCI, WORD, PIN, CS> OneShot<ADCI, WORD, AdcPin<PIN, ADCI, CS>> for ADC<'d, ADCI>
impl<'d, ADCI, PIN, CS> OneShot<ADCI, u16, AdcPin<PIN, ADCI, CS>> for ADC<'d, ADCI>
where
WORD: From<u16>,
PIN: Channel<ADCI, ID = u8>,
ADCI: RegisterAccess,
CS: AdcCalScheme<ADCI>,
{
type Error = ();

fn read(&mut self, pin: &mut AdcPin<PIN, ADCI, CS>) -> nb::Result<WORD, Self::Error> {
fn read(&mut self, pin: &mut AdcPin<PIN, ADCI, CS>) -> nb::Result<u16, Self::Error> {
if self.attenuations[AdcPin::<PIN, ADCI>::channel() as usize] == None {
panic!(
"Channel {} is not configured reading!",
Expand Down Expand Up @@ -676,7 +675,7 @@ where
// Mark that no conversions are currently in progress
self.active_channel = None;

Ok(converted_value.into())
Ok(converted_value)
}
}

Expand Down
7 changes: 3 additions & 4 deletions esp-hal-common/src/analog/adc/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,16 +679,15 @@ impl AdcCalEfuse for ADC2 {
}
}

impl<'d, ADCI, WORD, PIN, CS> OneShot<ADCI, WORD, AdcPin<PIN, ADCI, CS>> for ADC<'d, ADCI>
impl<'d, ADCI, PIN, CS> OneShot<ADCI, u16, AdcPin<PIN, ADCI, CS>> for ADC<'d, ADCI>
where
WORD: From<u16>,
PIN: Channel<ADCI, ID = u8>,
ADCI: RegisterAccess,
CS: AdcCalScheme<ADCI>,
{
type Error = ();

fn read(&mut self, pin: &mut AdcPin<PIN, ADCI, CS>) -> nb::Result<WORD, Self::Error> {
fn read(&mut self, pin: &mut AdcPin<PIN, ADCI, CS>) -> nb::Result<u16, Self::Error> {
if self.attenuations[AdcPin::<PIN, ADCI>::channel() as usize] == None {
panic!(
"Channel {} is not configured reading!",
Expand Down Expand Up @@ -729,7 +728,7 @@ where
// Mark that no conversions are currently in progress
self.active_channel = None;

Ok(converted_value.into())
Ok(converted_value)
}
}

Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() -> ! {
let mut delay = Delay::new(&clocks);

loop {
let pin_value: u16 = nb::block!(adc1.read(&mut pin)).unwrap();
let pin_value = nb::block!(adc1.read(&mut pin)).unwrap();
println!("PIN2 ADC reading = {}", pin_value);
delay.delay_ms(1500u32);
}
Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/adc_cal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() -> ! {
let mut delay = Delay::new(&clocks);

loop {
let pin_value: u16 = nb::block!(adc1.read(&mut pin)).unwrap();
let pin_value = nb::block!(adc1.read(&mut pin)).unwrap();
let pin_value_mv = pin_value as u32 * atten.ref_mv() as u32 / 4096;
println!("PIN2 ADC reading = {pin_value} ({pin_value_mv} mV)");
delay.delay_ms(1500u32);
Expand Down