@@ -414,3 +414,59 @@ macro_rules! impl_adc_interface {
414414}
415415
416416pub use impl_adc_interface;
417+
418+ pub mod implementation {
419+ //! Analog to digital (ADC) conversion support.
420+ //!
421+ //! This module provides functions for reading analog values from two
422+ //! analog to digital converters available on the ESP32: `ADC1` and `ADC2`.
423+ //!
424+ //! The following pins can be configured for analog readout:
425+ //!
426+ //! | Channel | ADC1 | ADC2 |
427+ //! |---------|----------------------|---------------|
428+ //! | 0 | GPIO36 (SENSOR_VP) | GPIO4 |
429+ //! | 1 | GPIO37 (SENSOR_CAPP) | GPIO0 |
430+ //! | 2 | GPIO38 (SENSOR_CAPN) | GPIO2 |
431+ //! | 3 | GPIO39 (SENSOR_VN) | GPIO15 (MTDO) |
432+ //! | 4 | GPIO33 (32K_XP) | GPIO13 (MTCK) |
433+ //! | 5 | GPIO32 (32K_XN) | GPIO12 (MTDI) |
434+ //! | 6 | GPIO34 (VDET_1) | GPIO14 (MTMS) |
435+ //! | 7 | GPIO35 (VDET_2) | GPIO27 |
436+ //! | 8 | | GPIO25 |
437+ //! | 9 | | GPIO26 |
438+
439+ use embedded_hal:: adc:: Channel ;
440+
441+ use super :: impl_adc_interface;
442+ pub use crate :: analog:: { adc:: * , ADC1 , ADC2 } ;
443+ use crate :: gpio:: * ;
444+
445+ impl_adc_interface ! {
446+ ADC1 [
447+ ( Gpio36 , 0 ) , // Alt. name: SENSOR_VP
448+ ( Gpio37 , 1 ) , // Alt. name: SENSOR_CAPP
449+ ( Gpio38 , 2 ) , // Alt. name: SENSOR_CAPN
450+ ( Gpio39 , 3 ) , // Alt. name: SENSOR_VN
451+ ( Gpio33 , 4 ) , // Alt. name: 32K_XP
452+ ( Gpio32 , 5 ) , // Alt. name: 32K_XN
453+ ( Gpio34 , 6 ) , // Alt. name: VDET_1
454+ ( Gpio35 , 7 ) , // Alt. name: VDET_2
455+ ]
456+ }
457+
458+ impl_adc_interface ! {
459+ ADC2 [
460+ ( Gpio4 , 0 ) ,
461+ ( Gpio0 , 1 ) ,
462+ ( Gpio2 , 2 ) ,
463+ ( Gpio15 , 3 ) , // Alt. name: MTDO
464+ ( Gpio13 , 4 ) , // Alt. name: MTCK
465+ ( Gpio12 , 5 ) , // Alt. name: MTDI
466+ ( Gpio14 , 6 ) , // Alt. name: MTMS
467+ ( Gpio27 , 7 ) ,
468+ ( Gpio25 , 8 ) ,
469+ ( Gpio26 , 9 ) ,
470+ ]
471+ }
472+ }
0 commit comments