mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-29 21:30:39 +00:00
Implement ADC trait based on metadata (#3911)
This commit is contained in:
parent
edcc63a6d0
commit
e579b1b1be
@ -32,7 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- PSRAM on ESP32-S2 (#3811)
|
||||
- WDT now allows configuring longer timeouts (#3816)
|
||||
- `ADC2` now cannot be used simultaneously with `radio` on ESP32 (#3876)
|
||||
- Switched GPIO32 and GPIO33 ADC channel numbers (#3908)
|
||||
- Switched GPIO32 and GPIO33 ADC channel numbers (#3908, #3911)
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -397,36 +397,6 @@ impl<ADC1> Adc<'_, ADC1, crate::Blocking> {
|
||||
}
|
||||
}
|
||||
|
||||
mod adc_implementation {
|
||||
crate::analog::adc::impl_adc_interface! {
|
||||
ADC1 [
|
||||
(GPIO36<'_>, 0), // Alt. name: SENSOR_VP
|
||||
(GPIO37<'_>, 1), // Alt. name: SENSOR_CAPP
|
||||
(GPIO38<'_>, 2), // Alt. name: SENSOR_CAPN
|
||||
(GPIO39<'_>, 3), // Alt. name: SENSOR_VN
|
||||
(GPIO32<'_>, 4), // Alt. name: 32K_XP
|
||||
(GPIO33<'_>, 5), // Alt. name: 32K_XN
|
||||
(GPIO34<'_>, 6), // Alt. name: VDET_1
|
||||
(GPIO35<'_>, 7), // Alt. name: VDET_2
|
||||
]
|
||||
}
|
||||
|
||||
crate::analog::adc::impl_adc_interface! {
|
||||
ADC2 [
|
||||
(GPIO4<'_>, 0),
|
||||
(GPIO0<'_>, 1),
|
||||
(GPIO2<'_>, 2),
|
||||
(GPIO15<'_>, 3), // Alt. name: MTDO
|
||||
(GPIO13<'_>, 4), // Alt. name: MTCK
|
||||
(GPIO12<'_>, 5), // Alt. name: MTDI
|
||||
(GPIO14<'_>, 6), // Alt. name: MTMS
|
||||
(GPIO27<'_>, 7),
|
||||
(GPIO25<'_>, 8),
|
||||
(GPIO26<'_>, 9),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ADC2<'_> {
|
||||
fn drop(&mut self) {
|
||||
release_adc2(private::Internal);
|
||||
|
@ -242,16 +242,10 @@ trait AdcCalEfuse {
|
||||
fn cal_code(atten: Attenuation) -> Option<u16>;
|
||||
}
|
||||
|
||||
macro_rules! impl_adc_interface {
|
||||
($adc:ident [
|
||||
$( ($pin:ident<'_>, $channel:expr) ,)+
|
||||
]) => {
|
||||
$(
|
||||
impl $crate::analog::adc::AdcChannel for $crate::peripherals::$pin<'_> {
|
||||
const CHANNEL: u8 = $channel;
|
||||
}
|
||||
)+
|
||||
}
|
||||
for_each_analog_function! {
|
||||
(($ch_name:ident, ADCn_CHm, $adc:literal, $ch:literal), $gpio:ident) => {
|
||||
impl $crate::analog::adc::AdcChannel for $crate::peripherals::$gpio<'_> {
|
||||
const CHANNEL: u8 = $ch;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use impl_adc_interface;
|
||||
|
@ -449,66 +449,6 @@ impl super::AdcCalEfuse for crate::peripherals::ADC2<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(esp32c2)]
|
||||
mod adc_implementation {
|
||||
crate::analog::adc::impl_adc_interface! {
|
||||
ADC1 [
|
||||
(GPIO0<'_>, 0),
|
||||
(GPIO1<'_>, 1),
|
||||
(GPIO2<'_>, 2),
|
||||
(GPIO3<'_>, 3),
|
||||
(GPIO4<'_>, 4),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(esp32c3)]
|
||||
mod adc_implementation {
|
||||
crate::analog::adc::impl_adc_interface! {
|
||||
ADC1 [
|
||||
(GPIO0<'_>, 0),
|
||||
(GPIO1<'_>, 1),
|
||||
(GPIO2<'_>, 2),
|
||||
(GPIO3<'_>, 3),
|
||||
(GPIO4<'_>, 4),
|
||||
]
|
||||
}
|
||||
|
||||
crate::analog::adc::impl_adc_interface! {
|
||||
ADC2 [
|
||||
(GPIO5<'_>, 0),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(esp32c6)]
|
||||
mod adc_implementation {
|
||||
crate::analog::adc::impl_adc_interface! {
|
||||
ADC1 [
|
||||
(GPIO0<'_>, 0),
|
||||
(GPIO1<'_>, 1),
|
||||
(GPIO2<'_>, 2),
|
||||
(GPIO3<'_>, 3),
|
||||
(GPIO4<'_>, 4),
|
||||
(GPIO5<'_>, 5),
|
||||
(GPIO6<'_>, 6),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(esp32h2)]
|
||||
mod adc_implementation {
|
||||
crate::analog::adc::impl_adc_interface! {
|
||||
ADC1 [
|
||||
(GPIO1<'_>, 0),
|
||||
(GPIO2<'_>, 1),
|
||||
(GPIO3<'_>, 2),
|
||||
(GPIO4<'_>, 3),
|
||||
(GPIO5<'_>, 4),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, ADCI> Adc<'d, ADCI, Async>
|
||||
where
|
||||
ADCI: RegisterAccess + 'd,
|
||||
|
@ -518,35 +518,3 @@ impl super::AdcCalEfuse for crate::peripherals::ADC2<'_> {
|
||||
Efuse::rtc_calib_cal_code(2, atten)
|
||||
}
|
||||
}
|
||||
|
||||
mod adc_implementation {
|
||||
crate::analog::adc::impl_adc_interface! {
|
||||
ADC1 [
|
||||
(GPIO1<'_>, 0),
|
||||
(GPIO2<'_>, 1),
|
||||
(GPIO3<'_>, 2),
|
||||
(GPIO4<'_>, 3),
|
||||
(GPIO5<'_>, 4),
|
||||
(GPIO6<'_>, 5),
|
||||
(GPIO7<'_>, 6),
|
||||
(GPIO8<'_>, 7),
|
||||
(GPIO9<'_>, 8),
|
||||
(GPIO10<'_>, 9),
|
||||
]
|
||||
}
|
||||
|
||||
crate::analog::adc::impl_adc_interface! {
|
||||
ADC2 [
|
||||
(GPIO11<'_>, 0),
|
||||
(GPIO12<'_>, 1),
|
||||
(GPIO13<'_>, 2),
|
||||
(GPIO14<'_>, 3),
|
||||
(GPIO15<'_>, 4),
|
||||
(GPIO16<'_>, 5),
|
||||
(GPIO17<'_>, 6),
|
||||
(GPIO18<'_>, 7),
|
||||
(GPIO19<'_>, 8),
|
||||
(GPIO20<'_>, 9),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user