12 #include "hpm_acmp_regs.h"
31 #define ACMP_HYST_LEVEL_0 (0U)
32 #define ACMP_HYST_LEVEL_1 (1U)
33 #define ACMP_HYST_LEVEL_2 (2U)
34 #define ACMP_HYST_LEVEL_3 (3U)
39 #define ACMP_INPUT_DAC_OUT (0U)
40 #define ACMP_INPUT_ANALOG_1 (1U)
41 #define ACMP_INPUT_ANALOG_2 (2U)
42 #define ACMP_INPUT_ANALOG_3 (3U)
43 #define ACMP_INPUT_ANALOG_4 (4U)
44 #define ACMP_INPUT_ANALOG_5 (5U)
45 #define ACMP_INPUT_ANALOG_6 (6U)
46 #define ACMP_INPUT_ANALOG_7 (7U)
51 #define ACMP_FILTER_MODE_BYPASS (0U)
52 #define ACMP_FILTER_MODE_CHANGE_IMMEDIATELY (4U)
53 #define ACMP_FILTER_MODE_CHANGE_AFTER_FILTER (5U)
54 #define ACMP_FILTER_MODE_STABLE_LOW (6U)
55 #define ACMP_FILTER_MODE_STABLE_HIGH (7U)
60 #define ACMP_EVENT_RISING_EDGE (1U)
61 #define ACMP_EVENT_FALLING_EDGE (2U)
66 #define ACMP_CAP_SEL_LEVEL_0 (0U)
67 #define ACMP_CAP_SEL_LEVEL_1 (1U)
68 #define ACMP_CAP_SEL_LEVEL_2 (2U)
69 #define ACMP_CAP_SEL_LEVEL_3 (3U)
106 #if defined(HPM_IP_FEATURE_ACMP_HAS_CAP_SEL) && HPM_IP_FEATURE_ACMP_HAS_CAP_SEL
116 static inline void acmp_channel_config_cap_selection(
ACMP_Type *ptr, uint8_t ch, uint32_t level)
118 ptr->
CHANNEL[ch].
DACCFG = (ptr->
CHANNEL[ch].
DACCFG & ~ACMP_CHANNEL_DACCFG_CAP_SEL_MASK) | ACMP_CHANNEL_DACCFG_CAP_SEL_SET(level);
161 uint32_t mask,
bool enable)
164 | (enable ? mask : 0);
180 uint32_t mask,
bool enable)
183 | (enable ? mask : 0);
#define ACMP_CHANNEL_CFG_CMPEN_MASK
Definition: hpm_acmp_regs.h:71
#define ACMP_CHANNEL_CFG_FLTLEN_SET(x)
Definition: hpm_acmp_regs.h:189
#define ACMP_CHANNEL_CFG_SYNCEN_MASK
Definition: hpm_acmp_regs.h:177
#define ACMP_CHANNEL_CFG_FLTBYPS_MASK
Definition: hpm_acmp_regs.h:126
#define ACMP_CHANNEL_CFG_FLTMODE_MASK
Definition: hpm_acmp_regs.h:165
#define ACMP_CHANNEL_CFG_FLTMODE_SET(x)
Definition: hpm_acmp_regs.h:167
#define ACMP_CHANNEL_CFG_CMPOEN_MASK
Definition: hpm_acmp_regs.h:114
#define ACMP_CHANNEL_CFG_WINEN_SET(x)
Definition: hpm_acmp_regs.h:140
#define ACMP_CHANNEL_DACCFG_DACCFG_SET(x)
Definition: hpm_acmp_regs.h:200
#define ACMP_CHANNEL_CFG_DACEN_MASK
Definition: hpm_acmp_regs.h:47
#define ACMP_CHANNEL_CFG_HPMODE_SET(x)
Definition: hpm_acmp_regs.h:61
#define ACMP_CHANNEL_CFG_CMPEN_SET(x)
Definition: hpm_acmp_regs.h:73
#define ACMP_CHANNEL_CFG_SYNCEN_SET(x)
Definition: hpm_acmp_regs.h:179
#define ACMP_CHANNEL_CFG_OPOL_MASK
Definition: hpm_acmp_regs.h:150
#define ACMP_CHANNEL_CFG_DACEN_SET(x)
Definition: hpm_acmp_regs.h:49
#define ACMP_CHANNEL_CFG_HYST_MASK
Definition: hpm_acmp_regs.h:35
#define ACMP_CHANNEL_CFG_HPMODE_MASK
Definition: hpm_acmp_regs.h:59
#define ACMP_CHANNEL_CFG_OPOL_SET(x)
Definition: hpm_acmp_regs.h:152
#define ACMP_CHANNEL_CFG_FLTBYPS_SET(x)
Definition: hpm_acmp_regs.h:128
#define ACMP_CHANNEL_CFG_CMPOEN_SET(x)
Definition: hpm_acmp_regs.h:116
#define ACMP_CHANNEL_CFG_WINEN_MASK
Definition: hpm_acmp_regs.h:138
#define ACMP_CHANNEL_CFG_FLTLEN_MASK
Definition: hpm_acmp_regs.h:187
#define ACMP_CHANNEL_DACCFG_DACCFG_MASK
Definition: hpm_acmp_regs.h:198
#define ACMP_CHANNEL_CFG_HYST_SET(x)
Definition: hpm_acmp_regs.h:37
static uint32_t acmp_channel_get_status(ACMP_Type *ptr, uint8_t ch)
ACMP channel get status.
Definition: hpm_acmp_drv.h:143
static void acmp_channel_enable_cmp_window_mode(ACMP_Type *ptr, uint8_t ch, bool enable)
ACMP channel enable comparator window mode.
Definition: hpm_acmp_drv.h:283
struct acmp_channel_config acmp_channel_config_t
ACMP channel config.
static void acmp_channel_clear_status(ACMP_Type *ptr, uint8_t ch, uint32_t mask)
ACMP channel clear status.
Definition: hpm_acmp_drv.h:131
static void acmp_channel_set_hyst(ACMP_Type *ptr, uint8_t ch, uint8_t level)
ACMP channel enable hysteresis level.
Definition: hpm_acmp_drv.h:223
static void acmp_channel_enable_sync(ACMP_Type *ptr, uint8_t ch, bool enable)
ACMP channel enable comparator output sync with clock.
Definition: hpm_acmp_drv.h:326
static void acmp_channel_set_filter_mode(ACMP_Type *ptr, uint8_t ch, uint8_t filter)
ACMP channel set comparator output filter mode.
Definition: hpm_acmp_drv.h:311
static void acmp_channel_enable_cmp(ACMP_Type *ptr, uint8_t ch, bool enable)
ACMP channel enable comparator.
Definition: hpm_acmp_drv.h:238
static void acmp_channel_config_dac(ACMP_Type *ptr, uint8_t ch, uint32_t value)
ACMP channel config DAC output value.
Definition: hpm_acmp_drv.h:101
static void acmp_channel_enable_irq(ACMP_Type *ptr, uint8_t ch, uint32_t mask, bool enable)
ACMP channel enable IRQ.
Definition: hpm_acmp_drv.h:179
static void acmp_channel_enable_hpmode(ACMP_Type *ptr, uint8_t ch, bool enable)
ACMP channel enable high performance mode.
Definition: hpm_acmp_drv.h:210
static void acmp_channel_dma_request_enable(ACMP_Type *ptr, uint8_t ch, uint32_t mask, bool enable)
ACMP channel enable DMA request.
Definition: hpm_acmp_drv.h:160
static void acmp_channel_cmp_output_bypass_filter(ACMP_Type *ptr, uint8_t ch, bool enable)
ACMP channel bypass comparator output filter.
Definition: hpm_acmp_drv.h:268
hpm_stat_t acmp_channel_config(ACMP_Type *ptr, uint8_t ch, acmp_channel_config_t *config, bool enable)
ADC channel config.
Definition: hpm_acmp_drv.c:10
static void acmp_channel_set_filter_length(ACMP_Type *ptr, uint8_t ch, uint16_t filter_length)
ACMP channel set comparator output filter length.
Definition: hpm_acmp_drv.h:339
static void acmp_channel_enable_cmp_output(ACMP_Type *ptr, uint8_t ch, bool enable)
ACMP channel enable comparator output.
Definition: hpm_acmp_drv.h:253
static void acmp_channel_enable_dac(ACMP_Type *ptr, uint8_t ch, bool enable)
ACMP channel enable DAC.
Definition: hpm_acmp_drv.h:195
static void acmp_channel_invert_output(ACMP_Type *ptr, uint8_t ch, bool enable)
ACMP channel invert comparator output.
Definition: hpm_acmp_drv.h:298
void acmp_channel_get_default_config(ACMP_Type *ptr, acmp_channel_config_t *config)
ADC channel get default config setting.
Definition: hpm_acmp_drv.c:32
uint32_t hpm_stat_t
Definition: hpm_common.h:123
Definition: hpm_acmp_regs.h:12
struct ACMP_Type::@290 CHANNEL[2]
__RW uint32_t DACCFG
Definition: hpm_acmp_regs.h:15
__RW uint32_t IRQEN
Definition: hpm_acmp_regs.h:18
__RW uint32_t SR
Definition: hpm_acmp_regs.h:17
__RW uint32_t CFG
Definition: hpm_acmp_regs.h:14
__RW uint32_t DMAEN
Definition: hpm_acmp_regs.h:19
ACMP channel config.
Definition: hpm_acmp_drv.h:75
bool invert_output
Definition: hpm_acmp_drv.h:82
bool enable_clock_sync
Definition: hpm_acmp_drv.h:83
uint8_t minus_input
Definition: hpm_acmp_drv.h:77
bool enable_dac
Definition: hpm_acmp_drv.h:85
uint8_t filter_mode
Definition: hpm_acmp_drv.h:78
uint8_t hyst_level
Definition: hpm_acmp_drv.h:79
uint16_t filter_length
Definition: hpm_acmp_drv.h:87
bool enable_hpmode
Definition: hpm_acmp_drv.h:86
bool enable_cmp_output
Definition: hpm_acmp_drv.h:80
uint8_t plus_input
Definition: hpm_acmp_drv.h:76
bool enable_window_mode
Definition: hpm_acmp_drv.h:81
bool bypass_filter
Definition: hpm_acmp_drv.h:84