|
|
@@ -75,6 +75,49 @@ typedef enum {
|
|
|
ADC_WIDTH_MAX,
|
|
|
} adc_bits_width_t;
|
|
|
|
|
|
+/**
|
|
|
+ * @brief ADC digital controller (DMA mode) work mode.
|
|
|
+ *
|
|
|
+ * @note The conversion mode affects the sampling frequency:
|
|
|
+ * SINGLE_UNIT_1: When the measurement is triggered, only ADC1 is sampled once.
|
|
|
+ * SINGLE_UNIT_2: When the measurement is triggered, only ADC2 is sampled once.
|
|
|
+ * BOTH_UNIT : When the measurement is triggered, ADC1 and ADC2 are sampled at the same time.
|
|
|
+ * ALTER_UNIT : When the measurement is triggered, ADC1 or ADC2 samples alternately.
|
|
|
+ */
|
|
|
+typedef enum {
|
|
|
+ ADC_CONV_SINGLE_UNIT_1 = 1, /*!< SAR ADC 1. */
|
|
|
+ ADC_CONV_SINGLE_UNIT_2 = 2, /*!< SAR ADC 2. */
|
|
|
+ ADC_CONV_BOTH_UNIT = 3, /*!< SAR ADC 1 and 2. */
|
|
|
+ ADC_CONV_ALTER_UNIT = 7, /*!< SAR ADC 1 and 2 alternative mode. */
|
|
|
+ ADC_CONV_UNIT_MAX,
|
|
|
+} adc_digi_convert_mode_t;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief ADC digital controller (DMA mode) conversion rules setting.
|
|
|
+ */
|
|
|
+typedef struct {
|
|
|
+ union {
|
|
|
+ struct {
|
|
|
+ uint8_t atten: 2; /*!< ADC sampling voltage attenuation configuration.
|
|
|
+ 0: input voltage * 1;
|
|
|
+ 1: input voltage * 1/1.34;
|
|
|
+ 2: input voltage * 1/2;
|
|
|
+ 3: input voltage * 1/3.6. */
|
|
|
+#ifdef CONFIG_IDF_TARGET_ESP32
|
|
|
+ uint8_t bit_width: 2; /*!< ADC resolution.
|
|
|
+- 0: 9 bit;
|
|
|
+- 1: 10 bit;
|
|
|
+- 2: 11 bit;
|
|
|
+- 3: 12 bit. */
|
|
|
+#elif CONFIG_IDF_TARGET_ESP32S2
|
|
|
+ uint8_t reserved: 2; /*!< reserved0 */
|
|
|
+#endif
|
|
|
+ uint8_t channel: 4; /*!< ADC channel index. */
|
|
|
+ };
|
|
|
+ uint8_t val;
|
|
|
+ };
|
|
|
+} adc_digi_pattern_table_t;
|
|
|
+
|
|
|
/**
|
|
|
* @brief ADC digital controller (DMA mode) output data format option.
|
|
|
*/
|
|
|
@@ -127,90 +170,12 @@ typedef struct {
|
|
|
uint32_t div_a; /*!<Division factor. Range: 0 ~ 63. */
|
|
|
} adc_digi_clk_t;
|
|
|
|
|
|
-/**
|
|
|
- * @brief ADC arbiter work mode option.
|
|
|
- *
|
|
|
- * @note ESP32S2: Only ADC2 support arbiter.
|
|
|
- */
|
|
|
-typedef enum {
|
|
|
- ADC_ARB_MODE_SHIELD,/*!<Force shield arbiter, Select the highest priority controller to work. */
|
|
|
- ADC_ARB_MODE_FIX, /*!<Fixed priority switch controller mode. */
|
|
|
- ADC_ARB_MODE_LOOP, /*!<Loop priority switch controller mode. Each controller has the same priority,
|
|
|
- and the arbiter will switch to the next controller after the measurement is completed. */
|
|
|
-} adc_arbiter_mode_t;
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief ADC arbiter work mode and priority setting.
|
|
|
- *
|
|
|
- * @note ESP32S2: Only ADC2 support arbiter.
|
|
|
- */
|
|
|
-typedef struct {
|
|
|
- adc_arbiter_mode_t mode; /*!<Refer to ``adc_arbiter_mode_t``. Note: only support ADC2. */
|
|
|
- uint8_t rtc_pri; /*!<RTC controller priority. Range: 0 ~ 2. */
|
|
|
- uint8_t dig_pri; /*!<Digital controller priority. Range: 0 ~ 2. */
|
|
|
- uint8_t pwdet_pri; /*!<Wi-Fi controller priority. Range: 0 ~ 2. */
|
|
|
-} adc_arbiter_t;
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief ADC arbiter default configuration.
|
|
|
- *
|
|
|
- * @note ESP32S2: Only ADC2 support arbiter.
|
|
|
- */
|
|
|
-#define ADC_ARBITER_CONFIG_DEFAULT() { \
|
|
|
- .mode = ADC_ARB_MODE_FIX, \
|
|
|
- .rtc_pri = 1, \
|
|
|
- .dig_pri = 0, \
|
|
|
- .pwdet_pri = 2, \
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief ADC digital controller (DMA mode) work mode.
|
|
|
- *
|
|
|
- * @note The conversion mode affects the sampling frequency:
|
|
|
- * SINGLE_UNIT_1: When the measurement is triggered, only ADC1 is sampled once.
|
|
|
- * SINGLE_UNIT_2: When the measurement is triggered, only ADC2 is sampled once.
|
|
|
- * BOTH_UNIT : When the measurement is triggered, ADC1 and ADC2 are sampled at the same time.
|
|
|
- * ALTER_UNIT : When the measurement is triggered, ADC1 or ADC2 samples alternately.
|
|
|
- */
|
|
|
-typedef enum {
|
|
|
- ADC_CONV_SINGLE_UNIT_1 = 1, /*!< SAR ADC 1. */
|
|
|
- ADC_CONV_SINGLE_UNIT_2 = 2, /*!< SAR ADC 2. */
|
|
|
- ADC_CONV_BOTH_UNIT = 3, /*!< SAR ADC 1 and 2. */
|
|
|
- ADC_CONV_ALTER_UNIT = 7, /*!< SAR ADC 1 and 2 alternative mode. */
|
|
|
- ADC_CONV_UNIT_MAX,
|
|
|
-} adc_digi_convert_mode_t;
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief ADC digital controller (DMA mode) conversion rules setting.
|
|
|
- */
|
|
|
-typedef struct {
|
|
|
- union {
|
|
|
- struct {
|
|
|
- uint8_t atten: 2; /*!< ADC sampling voltage attenuation configuration.
|
|
|
- 0: input voltage * 1;
|
|
|
- 1: input voltage * 1/1.34;
|
|
|
- 2: input voltage * 1/2;
|
|
|
- 3: input voltage * 1/3.6. */
|
|
|
- uint8_t reserved: 2; /*!< reserved0 */
|
|
|
- uint8_t channel: 4; /*!< ADC channel index. */
|
|
|
- };
|
|
|
- uint8_t val; /*!< Raw entry value */
|
|
|
- };
|
|
|
-} adc_digi_pattern_table_t;
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief ADC digital controller (DMA mode) interrupt type options.
|
|
|
- */
|
|
|
-typedef enum {
|
|
|
- ADC_DIGI_INTR_MASK_MONITOR = 0x1,
|
|
|
- ADC_DIGI_INTR_MASK_MEAS_DONE = 0x2,
|
|
|
- ADC_DIGI_INTR_MASK_ALL = 0x3,
|
|
|
-} adc_digi_intr_t;
|
|
|
+#endif //CONFIG_IDF_TARGET_ESP32S2
|
|
|
|
|
|
/**
|
|
|
* @brief ADC digital controller (DMA mode) configuration parameters.
|
|
|
*
|
|
|
- * Example setting: Use ADC1 channel0 to measure voltage, the sampling rate is required to be 1KHz:
|
|
|
+ * ESP32S2: Example setting: Use ADC1 channel0 to measure voltage, the sampling rate is required to be 1KHz:
|
|
|
* +---------------------+--------+--------+--------+
|
|
|
* | sample rate | 1KHz | 1KHz | 1KHz |
|
|
|
* +---------------------+--------+--------+--------+
|
|
|
@@ -225,7 +190,7 @@ typedef enum {
|
|
|
* | `trigger_meas_freq` | 1KHz | 1KHz | 2KHz |
|
|
|
* +---------------------+--------+--------+--------+
|
|
|
*
|
|
|
- * Explain the relationship between `conv_limit_num`, `dma_eof_num` and the number of DMA output:
|
|
|
+ * ESP32S2: Explain the relationship between `conv_limit_num`, `dma_eof_num` and the number of DMA output:
|
|
|
* +---------------------+--------+--------+--------+
|
|
|
* | conv_mode | single | both | alter |
|
|
|
* +---------------------+--------+--------+--------+
|
|
|
@@ -249,6 +214,7 @@ typedef struct {
|
|
|
adc_digi_pattern_table_t *adc2_pattern; /*!<Refer to ``adc1_pattern`` */
|
|
|
adc_digi_convert_mode_t conv_mode; /*!<ADC conversion mode for digital controller. See ``adc_digi_convert_mode_t``. */
|
|
|
adc_digi_output_format_t format; /*!<ADC output data format for digital controller. See ``adc_digi_output_format_t``. */
|
|
|
+#ifdef CONFIG_IDF_TARGET_ESP32S2
|
|
|
uint32_t interval; /*!<The number of interval clock cycles for the digital controller to trigger the measurement.
|
|
|
The unit is the divided clock. Range: 40 ~ 4095.
|
|
|
Expression: `trigger_meas_freq` = `controller_clk` / 2 / interval. Refer to ``adc_digi_clk_t``.
|
|
|
@@ -257,8 +223,56 @@ typedef struct {
|
|
|
uint32_t dma_eof_num; /*!<DMA eof num of adc digital controller.
|
|
|
If the number of measurements reaches `dma_eof_num`, then `dma_in_suc_eof` signal is generated in DMA.
|
|
|
Note: The converted data in the DMA in link buffer will be multiple of two bytes. */
|
|
|
+#endif
|
|
|
} adc_digi_config_t;
|
|
|
|
|
|
+#ifdef CONFIG_IDF_TARGET_ESP32S2
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief ADC arbiter work mode option.
|
|
|
+ *
|
|
|
+ * @note ESP32S2: Only ADC2 support arbiter.
|
|
|
+ */
|
|
|
+typedef enum {
|
|
|
+ ADC_ARB_MODE_SHIELD,/*!<Force shield arbiter, Select the highest priority controller to work. */
|
|
|
+ ADC_ARB_MODE_FIX, /*!<Fixed priority switch controller mode. */
|
|
|
+ ADC_ARB_MODE_LOOP, /*!<Loop priority switch controller mode. Each controller has the same priority,
|
|
|
+ and the arbiter will switch to the next controller after the measurement is completed. */
|
|
|
+} adc_arbiter_mode_t;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief ADC arbiter work mode and priority setting.
|
|
|
+ *
|
|
|
+ * @note ESP32S2: Only ADC2 support arbiter.
|
|
|
+ */
|
|
|
+typedef struct {
|
|
|
+ adc_arbiter_mode_t mode; /*!<Refer to ``adc_arbiter_mode_t``. Note: only support ADC2. */
|
|
|
+ uint8_t rtc_pri; /*!<RTC controller priority. Range: 0 ~ 2. */
|
|
|
+ uint8_t dig_pri; /*!<Digital controller priority. Range: 0 ~ 2. */
|
|
|
+ uint8_t pwdet_pri; /*!<Wi-Fi controller priority. Range: 0 ~ 2. */
|
|
|
+} adc_arbiter_t;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief ADC arbiter default configuration.
|
|
|
+ *
|
|
|
+ * @note ESP32S2: Only ADC2 support arbiter.
|
|
|
+ */
|
|
|
+#define ADC_ARBITER_CONFIG_DEFAULT() { \
|
|
|
+ .mode = ADC_ARB_MODE_FIX, \
|
|
|
+ .rtc_pri = 1, \
|
|
|
+ .dig_pri = 0, \
|
|
|
+ .pwdet_pri = 2, \
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief ADC digital controller (DMA mode) interrupt type options.
|
|
|
+ */
|
|
|
+typedef enum {
|
|
|
+ ADC_DIGI_INTR_MASK_MONITOR = 0x1,
|
|
|
+ ADC_DIGI_INTR_MASK_MEAS_DONE = 0x2,
|
|
|
+ ADC_DIGI_INTR_MASK_ALL = 0x3,
|
|
|
+} adc_digi_intr_t;
|
|
|
+
|
|
|
/**
|
|
|
* @brief ADC digital controller (DMA mode) filter index options.
|
|
|
*
|