mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
Merge branch 'feature/analog_comparator_h2' into 'master'
Introduce the Analog Comparator driver Closes IDF-6817 See merge request espressif/esp-idf!22355
This commit is contained in:
14
components/soc/esp32h2/ana_cmpr_periph.c
Normal file
14
components/soc/esp32h2/ana_cmpr_periph.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ana_cmpr_periph.h"
|
||||
|
||||
const ana_cmpr_conn_t ana_cmpr_io_map[SOC_ANA_CMPR_NUM] = {
|
||||
[0] = {
|
||||
.src_gpio = ANA_CMPR0_SRC_GPIO,
|
||||
.ext_ref_gpio = ANA_CMPR0_EXT_REF_GPIO,
|
||||
},
|
||||
};
|
@@ -7,6 +7,10 @@ config SOC_ADC_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_ANA_CMPR_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_DEDICATED_GPIO_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
@@ -427,6 +431,10 @@ config SOC_DEDIC_PERIPH_ALWAYS_ENABLE
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_ANA_CMPR_NUM
|
||||
int
|
||||
default 1
|
||||
|
||||
config SOC_I2C_NUM
|
||||
int
|
||||
default 2
|
||||
|
10
components/soc/esp32h2/include/soc/ana_cmpr_channel.h
Normal file
10
components/soc/esp32h2/include/soc/ana_cmpr_channel.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define ANA_CMPR0_EXT_REF_GPIO 10 /*!< The GPIO that can be used as external reference voltage */
|
||||
#define ANA_CMPR0_SRC_GPIO 11 /*!< The GPIO that used for inputting the source signal to compare */
|
@@ -330,6 +330,22 @@ typedef enum {
|
||||
SDM_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F48M, /*!< Select PLL_F48M as the default clock choice */
|
||||
} soc_periph_sdm_clk_src_t;
|
||||
|
||||
///////////////////////////////////////////////////Analog Comparator////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief Array initializer for all supported clock sources of Analog Comparator
|
||||
*/
|
||||
#define SOC_ANA_CMPR_CLKS {SOC_MOD_CLK_PLL_F48M, SOC_MOD_CLK_XTAL}
|
||||
|
||||
/**
|
||||
* @brief Sigma Delta Modulator clock source
|
||||
*/
|
||||
typedef enum {
|
||||
ANA_CMPR_CLK_SRC_XTAL = SOC_MOD_CLK_XTAL, /*!< Select XTAL clock as the source clock */
|
||||
ANA_CMPR_CLK_SRC_PLL_F48M = SOC_MOD_CLK_PLL_F48M, /*!< Select PLL_F48M clock as the source clock */
|
||||
ANA_CMPR_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F48M, /*!< Select PLL_F48M as the default clock choice */
|
||||
} soc_periph_ana_cmpr_clk_src_t;
|
||||
|
||||
//////////////////////////////////////////////////GPIO Glitch Filter////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
@@ -75,8 +75,8 @@ typedef union {
|
||||
*/
|
||||
uint32_t xpd_comp:1;
|
||||
/** mode_comp : R/W; bitpos: [1]; default: 0;
|
||||
* 1 to enable external reference from PAD[0]. 0 to enable internal reference,
|
||||
* meanwhile PAD[0] can be used as a regular GPIO.
|
||||
* 1 to enable external reference from PAD[10]. 0 to enable internal reference,
|
||||
* meanwhile PAD[10] can be used as a regular GPIO.
|
||||
*/
|
||||
uint32_t mode_comp:1;
|
||||
/** dref_comp : R/W; bitpos: [4:2]; default: 0;
|
||||
@@ -305,10 +305,15 @@ typedef struct {
|
||||
volatile gpio_ext_version_reg_t version;
|
||||
} gpio_ext_dev_t;
|
||||
|
||||
// analog comparator is a stand alone peripheral, but it is connected to GPIO
|
||||
// so we rename it to analog_cmpr_dev_t from user's perspective
|
||||
typedef gpio_ext_dev_t analog_cmpr_dev_t;
|
||||
|
||||
extern gpio_sd_dev_t SDM;
|
||||
extern gpio_glitch_filter_dev_t GLITCH_FILTER;
|
||||
extern gpio_etm_dev_t GPIO_ETM;
|
||||
extern gpio_ext_dev_t GPIO_EXT;
|
||||
extern analog_cmpr_dev_t ANALOG_CMPR;
|
||||
|
||||
#ifndef __cplusplus
|
||||
_Static_assert(sizeof(gpio_ext_dev_t) == 0x100, "Invalid size of gpio_ext_dev_t structure");
|
||||
|
@@ -26,6 +26,7 @@
|
||||
|
||||
/*-------------------------- COMMON CAPS ---------------------------------------*/
|
||||
#define SOC_ADC_SUPPORTED 1
|
||||
#define SOC_ANA_CMPR_SUPPORTED 1
|
||||
#define SOC_DEDICATED_GPIO_SUPPORTED 1
|
||||
#define SOC_UART_SUPPORTED 1
|
||||
#define SOC_GDMA_SUPPORTED 1
|
||||
@@ -198,6 +199,9 @@
|
||||
#define SOC_DEDIC_GPIO_IN_CHANNELS_NUM (8) /*!< 8 inward channels on each CPU core */
|
||||
#define SOC_DEDIC_PERIPH_ALWAYS_ENABLE (1) /*!< The dedicated GPIO (a.k.a. fast GPIO) is featured by some customized CPU instructions, which is always enabled */
|
||||
|
||||
/*------------------------- Analog Comparator CAPS ---------------------------*/
|
||||
#define SOC_ANA_CMPR_NUM (1U)
|
||||
|
||||
/*-------------------------- I2C CAPS ----------------------------------------*/
|
||||
// ESP32-H2 has 2 I2C
|
||||
#define SOC_I2C_NUM (2U)
|
||||
|
@@ -44,6 +44,7 @@ PROVIDE ( HMAC = 0x6008D000 );
|
||||
PROVIDE ( IO_MUX = 0x60090000 );
|
||||
PROVIDE ( GPIO = 0x60091000 );
|
||||
PROVIDE ( GPIO_EXT = 0x60091f00 );
|
||||
PROVIDE ( ANALOG_CMPR = 0x60091f00 );
|
||||
PROVIDE ( SDM = 0x60091f00 );
|
||||
PROVIDE ( GLITCH_FILTER = 0x60091f30 );
|
||||
PROVIDE ( GPIO_ETM = 0x60091f60 );
|
||||
|
Reference in New Issue
Block a user