feat(ana_cmpr): supported etm in analog comparator example

This commit is contained in:
laokaiyao
2023-09-25 19:57:34 +08:00
parent bf2a5653a9
commit ff7a11e539
44 changed files with 796 additions and 267 deletions
+12 -1
View File
@@ -5,11 +5,22 @@
*/
#include "soc/ana_cmpr_periph.h"
#include "soc/ana_cmpr_struct.h"
const ana_cmpr_conn_t ana_cmpr_io_map[SOC_ANA_CMPR_NUM] = {
const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = {
[0] = {
.src_gpio = ANA_CMPR0_SRC_GPIO,
.ext_ref_gpio = ANA_CMPR0_EXT_REF_GPIO,
.intr_src = ETS_GPIO_INTR_SOURCE,
},
};
analog_cmpr_dev_t ANALOG_CMPR[SOC_ANA_CMPR_NUM] = {
[0] = {
.pad_comp_config = &GPIO_EXT.pad_comp_config,
.pad_comp_filter = &GPIO_EXT.pad_comp_filter,
.int_st = &GPIO_EXT.int_st,
.int_ena = &GPIO_EXT.int_ena,
.int_clr = &GPIO_EXT.int_clr,
},
};
@@ -483,6 +483,10 @@ config SOC_ANA_CMPR_NUM
int
default 1
config SOC_ANA_CMPR_INTR_SHARE_WITH_GPIO
bool
default y
config SOC_I2C_NUM
int
default 2
@@ -0,0 +1,36 @@
/**
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* NOTE: this file is created manually for compatibility */
#pragma once
#include <stdint.h>
#include "soc/gpio_ext_struct.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief The Analog Comparator Device struct
* @note The field in it are register pointers, which point to the physical address
* of the corresponding configuration register
* @note see 'ana_cmpr_periph.c' for the device instance
*/
typedef struct {
volatile gpio_pad_comp_config_reg_t *pad_comp_config;
volatile gpio_pad_comp_filter_reg_t *pad_comp_filter;
volatile gpio_ext_int_st_reg_t *int_st;
volatile gpio_ext_int_ena_reg_t *int_ena;
volatile gpio_ext_int_clr_reg_t *int_clr;
} analog_cmpr_dev_t;
extern analog_cmpr_dev_t ANALOG_CMPR[1];
#ifdef __cplusplus
}
#endif
@@ -305,15 +305,10 @@ 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");
@@ -220,7 +220,8 @@
#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)
#define SOC_ANA_CMPR_NUM (1U)
#define SOC_ANA_CMPR_INTR_SHARE_WITH_GPIO (1)
/*-------------------------- I2C CAPS ----------------------------------------*/
// ESP32-H2 has 2 I2C
@@ -44,7 +44,6 @@ 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 );
+1 -1
View File
@@ -7,7 +7,7 @@
#include "soc/ana_cmpr_periph.h"
#include "soc/ana_cmpr_struct.h"
const ana_cmpr_conn_t ana_cmpr_io_map[SOC_ANA_CMPR_NUM] = {
const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = {
[0] = {
.src_gpio = ANA_CMPR0_SRC_GPIO,
.ext_ref_gpio = ANA_CMPR0_EXT_REF_GPIO,
@@ -391,7 +391,7 @@ config SOC_ANA_CMPR_NUM
int
default 2
config SOC_ANA_CMPR_SUPPORT_MULTI_INTR
config SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE
bool
default y
@@ -399,10 +399,6 @@ config SOC_ANA_CMPR_SUPPORT_ETM
bool
default y
config SOC_ANA_CMPR_ETM_EVENTS_PER_UNIT
int
default 2
config SOC_I2C_NUM
int
default 2
@@ -413,7 +413,7 @@ typedef enum {
#define SOC_ANA_CMPR_CLKS {SOC_MOD_CLK_PLL_F80M, SOC_MOD_CLK_XTAL}
/**
* @brief Sigma Delta Modulator clock source
* @brief Analog Comparator clock source
*/
typedef enum {
ANA_CMPR_CLK_SRC_XTAL = SOC_MOD_CLK_XTAL, /*!< Select XTAL clock as the source clock */
@@ -221,10 +221,9 @@
#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 (2U)
#define SOC_ANA_CMPR_SUPPORT_MULTI_INTR (1)
#define SOC_ANA_CMPR_SUPPORT_ETM (1)
#define SOC_ANA_CMPR_ETM_EVENTS_PER_UNIT (2)
#define SOC_ANA_CMPR_NUM (2)
#define SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE (1) // Support positive/negative/any cross interrupt
#define SOC_ANA_CMPR_SUPPORT_ETM (1)
/*-------------------------- I2C CAPS ----------------------------------------*/
// ESP32-P4 has 2 I2Cs
+3 -3
View File
@@ -8,7 +8,7 @@
#include <stdint.h>
#include "soc/soc_caps.h"
#include "soc/periph_defs.h"
#include "soc/interrupts.h"
#if SOC_ANA_CMPR_SUPPORTED
#include "soc/ana_cmpr_channel.h"
#endif
@@ -22,9 +22,9 @@ typedef struct {
int src_gpio;
int ext_ref_gpio;
int intr_src;
} ana_cmpr_conn_t;
} ana_cmpr_periph_t;
extern const ana_cmpr_conn_t ana_cmpr_io_map[SOC_ANA_CMPR_NUM];
extern const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM];
#endif
#ifdef __cplusplus