8 #ifndef HPM_ADC16_DRV_H
9 #define HPM_ADC16_DRV_H
13 #include "hpm_soc_feature.h"
23 #if defined (ADC16_SOC_TEMP_CH_EN) && ADC16_SOC_TEMP_CH_EN
24 #define ADC16_IS_CHANNEL_INVALID(CH) (CH > ADC16_SOC_MAX_CH_NUM && CH != ADC16_SOC_TEMP_CH_NUM)
26 #define ADC16_IS_CHANNEL_INVALID(CH) (CH > ADC16_SOC_MAX_CH_NUM)
30 #define ADC16_IS_CHANNEL_SAMPLE_CYCLE_INVALID(CYC) (CYC == 0)
33 #define ADC16_IS_TRIG_CH_INVLAID(CH) (CH > ADC_SOC_MAX_TRIG_CH_NUM)
36 #define ADC16_IS_TRIG_LEN_INVLAID(TRIG_LEN) (TRIG_LEN > ADC_SOC_MAX_TRIG_CH_LEN)
39 #define ADC16_IS_SEQ_LEN_INVLAID(LEN) ((LEN == 0) || (LEN > ADC_SOC_SEQ_MAX_LEN))
42 #define ADC16_IS_SEQ_DMA_BUFF_LEN_INVLAID(LEN) ((LEN == 0) || (LEN > ADC_SOC_SEQ_MAX_DMA_BUFF_LEN_IN_4BYTES))
45 #define ADC16_IS_PMT_DMA_BUFF_LEN_INVLAID(LEN) ((LEN == 0) || (LEN > ADC_SOC_PMT_MAX_DMA_BUFF_LEN_IN_4BYTES))
154 #if defined(ADC_SOC_IP_VERSION) && (ADC_SOC_IP_VERSION < 2)
161 uint32_t cycle_bit :1;
174 #if defined(ADC_SOC_IP_VERSION) && (ADC_SOC_IP_VERSION < 2)
182 uint32_t cycle_bit :1;
293 #if defined (ADC_SOC_BUSMODE_ENABLE_CTRL_SUPPORT) && ADC_SOC_BUSMODE_ENABLE_CTRL_SUPPORT
299 void adc16_enable_oneshot_mode(
ADC16_Type *ptr);
306 void adc16_disable_oneshot_mode(
ADC16_Type *ptr);
584 #if defined(ADC16_SOC_TEMP_CH_EN) && ADC16_SOC_TEMP_CH_EN
590 void adc16_enable_temp_sensor(
ADC16_Type *ptr);
597 void adc16_disable_temp_sensor(
ADC16_Type *ptr);
#define ADC_SOC_SEQ_MAX_LEN
Definition: hpm_soc_feature.h:94
#define ADC_SOC_MAX_TRIG_CH_LEN
Definition: hpm_soc_feature.h:96
adc16_clock_divider_t
Define ADC16 Clock Divider.
Definition: hpm_adc16_drv.h:64
adc16_conversion_mode_t
Define ADC16 conversion modes.
Definition: hpm_adc16_drv.h:56
hpm_stat_t adc16_get_oneshot_result(ADC16_Type *ptr, uint8_t ch, uint16_t *result)
Get the result in oneshot mode.
Definition: hpm_adc16_drv.c:421
static void adc16_enable_busywait(ADC16_Type *ptr)
Set value of the WAIT_DIS bit. ADC blocks access to the associated peripheral bus until the ADC compl...
Definition: hpm_adc16_drv.h:433
hpm_stat_t adc16_trigger_seq_by_sw(ADC16_Type *ptr)
Trigger ADC conversions by software in sequence mode.
Definition: hpm_adc16_drv.c:327
static void adc16_enable_motor(ADC16_Type *ptr)
enable the transmission of adc data to the motor sensor unit.
Definition: hpm_adc16_drv.h:605
static bool adc16_is_nonblocking_mode(ADC16_Type *ptr)
Judge whether the current setting is none-blocking mode or not.
Definition: hpm_adc16_drv.h:469
hpm_stat_t adc16_init(ADC16_Type *ptr, adc16_config_t *config)
Initialize an ADC16 instance.
Definition: hpm_adc16_drv.c:155
static uint32_t adc16_get_status_flags(ADC16_Type *ptr)
Get all ADC16 status flags.
Definition: hpm_adc16_drv.h:409
static void adc16_set_blocking_read(ADC16_Type *ptr)
Set blocking read in oneshot mode.
Definition: hpm_adc16_drv.h:455
adc16_resolution_t
Define ADC16 resolutions.
Definition: hpm_adc16_drv.h:48
static bool adc16_get_conv_valid_status(ADC16_Type *ptr, uint8_t ch)
Get the status of a conversion validity.
Definition: hpm_adc16_drv.h:483
hpm_stat_t adc16_set_pmt_queue_enable(ADC16_Type *ptr, uint8_t trig_ch, bool enable)
Set the queue enable control.
Definition: hpm_adc16_drv.c:402
static void adc16_enable_interrupts(ADC16_Type *ptr, uint32_t mask)
Enable interrupts.
Definition: hpm_adc16_drv.h:515
void adc16_get_default_config(adc16_config_t *config)
Get a default configuration for an ADC16 instance.
Definition: hpm_adc16_drv.c:11
hpm_stat_t adc16_get_prd_result(ADC16_Type *ptr, uint8_t ch, uint16_t *result)
Get the result in the period mode.
Definition: hpm_adc16_drv.c:443
void adc16_get_channel_default_config(adc16_channel_config_t *config)
Get a default configuration for an ADC16 Channel.
Definition: hpm_adc16_drv.c:23
hpm_stat_t adc16_set_seq_config(ADC16_Type *ptr, adc16_seq_config_t *config)
Configure the sequence mode for an ADC16 instance.
Definition: hpm_adc16_drv.c:338
static void adc16_init_pmt_dma(ADC16_Type *ptr, uint32_t addr)
Configure the start address of DMA write operation for the preemption mode.
Definition: hpm_adc16_drv.h:379
static void adc16_set_seq_stop_pos(ADC16_Type *ptr, uint16_t stop_pos)
Configure the stop position offset in the specified memory of DMA write operation for the sequence mo...
Definition: hpm_adc16_drv.h:367
static void adc16_disable_interrupts(ADC16_Type *ptr, uint32_t mask)
Disable interrupts.
Definition: hpm_adc16_drv.h:526
hpm_stat_t adc16_get_channel_threshold(ADC16_Type *ptr, uint8_t ch, adc16_channel_threshold_t *config)
Get thresholds of an ADC16 channel.
Definition: hpm_adc16_drv.c:234
adc16_irq_event_t
Define ADC16 irq events.
Definition: hpm_adc16_drv.h:84
hpm_stat_t adc16_deinit(ADC16_Type *ptr)
De-initialize an ADC16 instance.
Definition: hpm_adc16_drv.c:147
hpm_stat_t adc16_trigger_pmt_by_sw(ADC16_Type *ptr, uint8_t trig_ch)
Trigger ADC conversions by software in preemption mode.
Definition: hpm_adc16_drv.c:365
hpm_stat_t adc16_init_channel(ADC16_Type *ptr, adc16_channel_config_t *config)
Initialize an ADC16 channel.
Definition: hpm_adc16_drv.c:205
hpm_stat_t adc16_set_prd_config(ADC16_Type *ptr, adc16_prd_config_t *config)
Configure the the period mode for an ADC16 instance.
Definition: hpm_adc16_drv.c:304
static void adc16_set_nonblocking_read(ADC16_Type *ptr)
Set nonblocking read in oneshot mode.
Definition: hpm_adc16_drv.h:444
static void adc16_clear_status_flags(ADC16_Type *ptr, uint32_t mask)
Clear the status flags.
Definition: hpm_adc16_drv.h:497
hpm_stat_t adc16_set_pmt_config(ADC16_Type *ptr, adc16_pmt_config_t *config)
Configure the preemption mode for an ADC16 instance.
Definition: hpm_adc16_drv.c:372
static void adc16_disable_busywait(ADC16_Type *ptr)
Set value of the WAIT_DIS bit. The ADC does not block access to the associated peripheral bus until t...
Definition: hpm_adc16_drv.h:421
hpm_stat_t adc16_init_seq_dma(ADC16_Type *ptr, adc16_dma_config_t *config)
Configure the start address of DMA write operation for the sequence mode.
Definition: hpm_adc16_drv.c:260
@ adc16_clock_divider_9
Definition: hpm_adc16_drv.h:73
@ adc16_clock_divider_4
Definition: hpm_adc16_drv.h:68
@ adc16_clock_divider_3
Definition: hpm_adc16_drv.h:67
@ adc16_clock_divider_7
Definition: hpm_adc16_drv.h:71
@ adc16_clock_divider_1
Definition: hpm_adc16_drv.h:65
@ adc16_clock_divider_10
Definition: hpm_adc16_drv.h:74
@ adc16_clock_divider_13
Definition: hpm_adc16_drv.h:77
@ adc16_clock_divider_15
Definition: hpm_adc16_drv.h:79
@ adc16_clock_divider_12
Definition: hpm_adc16_drv.h:76
@ adc16_clock_divider_8
Definition: hpm_adc16_drv.h:72
@ adc16_clock_divider_6
Definition: hpm_adc16_drv.h:70
@ adc16_clock_divider_5
Definition: hpm_adc16_drv.h:69
@ adc16_clock_divider_11
Definition: hpm_adc16_drv.h:75
@ adc16_clock_divider_14
Definition: hpm_adc16_drv.h:78
@ adc16_clock_divider_2
Definition: hpm_adc16_drv.h:66
@ adc16_clock_divider_16
Definition: hpm_adc16_drv.h:80
@ adc16_conv_mode_preemption
Definition: hpm_adc16_drv.h:60
@ adc16_conv_mode_period
Definition: hpm_adc16_drv.h:58
@ adc16_conv_mode_sequence
Definition: hpm_adc16_drv.h:59
@ adc16_conv_mode_oneshot
Definition: hpm_adc16_drv.h:57
@ adc16_res_8_bits
Definition: hpm_adc16_drv.h:49
@ adc16_res_12_bits
Definition: hpm_adc16_drv.h:51
@ adc16_res_16_bits
Definition: hpm_adc16_drv.h:52
@ adc16_res_10_bits
Definition: hpm_adc16_drv.h:50
@ adc16_event_seq_sw_conflict
Definition: hpm_adc16_drv.h:98
@ adc16_event_dma_fifo_full
Definition: hpm_adc16_drv.h:113
@ adc16_event_trig_hw_conflict
Definition: hpm_adc16_drv.h:92
@ adc16_event_seq_dma_abort
Definition: hpm_adc16_drv.h:104
@ adc16_event_seq_single_complete
Definition: hpm_adc16_drv.h:110
@ adc16_event_seq_full_complete
Definition: hpm_adc16_drv.h:107
@ adc16_event_seq_hw_conflict
Definition: hpm_adc16_drv.h:101
@ adc16_event_read_conflict
Definition: hpm_adc16_drv.h:95
@ adc16_event_trig_sw_conflict
Definition: hpm_adc16_drv.h:89
@ adc16_event_trig_complete
Definition: hpm_adc16_drv.h:86
uint32_t hpm_stat_t
Definition: hpm_common.h:119
#define ADC16_INT_STS_SEQ_CMPT_MASK
Definition: hpm_adc16_regs.h:630
#define ADC16_SEQ_DMA_CFG_STOP_POS_SET(x)
Definition: hpm_adc16_regs.h:335
#define ADC16_TRG_DMA_ADDR_TRG_DMA_ADDR_MASK
Definition: hpm_adc16_regs.h:161
#define ADC16_BUF_CFG0_WAIT_DIS_MASK
Definition: hpm_adc16_regs.h:229
#define ADC16_INT_STS_READ_CFLCT_MASK
Definition: hpm_adc16_regs.h:591
#define ADC16_INT_STS_TRIG_CMPT_MASK
Definition: hpm_adc16_regs.h:563
#define ADC16_INT_STS_SEQ_SW_CFLCT_MASK
Definition: hpm_adc16_regs.h:601
#define ADC16_ANA_CTRL0_MOTO_EN_MASK
Definition: hpm_adc16_regs.h:800
#define ADC16_INT_STS_SEQ_HW_CFLCT_MASK
Definition: hpm_adc16_regs.h:610
#define ADC16_INT_STS_DMA_FIFO_FULL_MASK
Definition: hpm_adc16_regs.h:650
#define ADC16_BUF_CFG0_WAIT_DIS_GET(x)
Definition: hpm_adc16_regs.h:232
#define ADC16_BUF_CFG0_WAIT_DIS_SET(x)
Definition: hpm_adc16_regs.h:231
#define ADC16_BUS_RESULT_VALID_GET(x)
Definition: hpm_adc16_regs.h:200
#define ADC16_SEQ_DMA_CFG_STOP_POS_MASK
Definition: hpm_adc16_regs.h:333
#define ADC16_INT_STS_TRIG_HW_CFLCT_MASK
Definition: hpm_adc16_regs.h:581
#define ADC16_INT_STS_TRIG_SW_CFLCT_MASK
Definition: hpm_adc16_regs.h:572
#define ADC16_INT_STS_SEQ_DMAABT_MASK
Definition: hpm_adc16_regs.h:620
#define ADC16_INT_STS_SEQ_CVC_MASK
Definition: hpm_adc16_regs.h:640
Definition: hpm_adc16_regs.h:12
__RW uint32_t ANA_CTRL0
Definition: hpm_adc16_regs.h:43
__RW uint32_t BUF_CFG0
Definition: hpm_adc16_regs.h:19
__RW uint32_t TRG_DMA_ADDR
Definition: hpm_adc16_regs.h:14
__RW uint32_t INT_EN
Definition: hpm_adc16_regs.h:41
__RW uint32_t SEQ_DMA_CFG
Definition: hpm_adc16_regs.h:24
__RW uint32_t INT_STS
Definition: hpm_adc16_regs.h:40
__R uint32_t BUS_RESULT[16]
Definition: hpm_adc16_regs.h:17
ADC16 channel configuration struct.
Definition: hpm_adc16_drv.h:129
uint32_t sample_cycle
Definition: hpm_adc16_drv.h:135
bool wdog_int_en
Definition: hpm_adc16_drv.h:133
uint8_t ch
Definition: hpm_adc16_drv.h:130
uint16_t thshdh
Definition: hpm_adc16_drv.h:131
uint16_t thshdl
Definition: hpm_adc16_drv.h:132
uint8_t sample_cycle_shift
Definition: hpm_adc16_drv.h:134
ADC16 channel configuration struct.
Definition: hpm_adc16_drv.h:139
uint16_t thshdl
Definition: hpm_adc16_drv.h:142
uint8_t ch
Definition: hpm_adc16_drv.h:140
uint16_t thshdh
Definition: hpm_adc16_drv.h:141
ADC16 common configuration struct.
Definition: hpm_adc16_drv.h:117
bool sel_sync_ahb
Definition: hpm_adc16_drv.h:124
uint8_t res
Definition: hpm_adc16_drv.h:118
bool adc_ahb_en
Definition: hpm_adc16_drv.h:125
uint16_t conv_duration
Definition: hpm_adc16_drv.h:121
bool wait_dis
Definition: hpm_adc16_drv.h:123
bool port3_realtime
Definition: hpm_adc16_drv.h:122
uint8_t conv_mode
Definition: hpm_adc16_drv.h:119
uint32_t adc_clk_div
Definition: hpm_adc16_drv.h:120
ADC16 DMA configuration struct.
Definition: hpm_adc16_drv.h:146
uint32_t buff_len_in_4bytes
Definition: hpm_adc16_drv.h:148
uint32_t stop_pos
Definition: hpm_adc16_drv.h:149
bool stop_en
Definition: hpm_adc16_drv.h:150
uint32_t * start_addr
Definition: hpm_adc16_drv.h:147
ADC16 trigger configuration struct for the preemption mode.
Definition: hpm_adc16_drv.h:219
uint8_t trig_len
Definition: hpm_adc16_drv.h:223
uint8_t trig_ch
Definition: hpm_adc16_drv.h:222
ADC16 DMA configuration struct for the preemption mode.
Definition: hpm_adc16_drv.h:185
uint32_t cycle_bit
Definition: hpm_adc16_drv.h:191
uint32_t adc_ch
Definition: hpm_adc16_drv.h:188
uint32_t trig_ch
Definition: hpm_adc16_drv.h:189
uint32_t seq_num
Definition: hpm_adc16_drv.h:190
uint32_t result
Definition: hpm_adc16_drv.h:186
ADC16 configuration struct for the period mode.
Definition: hpm_adc16_drv.h:196
uint8_t prescale
Definition: hpm_adc16_drv.h:198
uint8_t ch
Definition: hpm_adc16_drv.h:197
uint8_t period_count
Definition: hpm_adc16_drv.h:199
ADC16 configuration struct for the sequence mode.
Definition: hpm_adc16_drv.h:209
bool hw_trig_en
Definition: hpm_adc16_drv.h:214
bool sw_trig_en
Definition: hpm_adc16_drv.h:213
bool cont_en
Definition: hpm_adc16_drv.h:212
uint8_t seq_len
Definition: hpm_adc16_drv.h:215
bool restart_en
Definition: hpm_adc16_drv.h:211
ADC16 DMA configuration struct for the sequence mode.
Definition: hpm_adc16_drv.h:164
uint32_t adc_ch
Definition: hpm_adc16_drv.h:167
uint32_t result
Definition: hpm_adc16_drv.h:165
uint32_t cycle_bit
Definition: hpm_adc16_drv.h:169
uint32_t seq_num
Definition: hpm_adc16_drv.h:166
ADC16 queue configuration struct for the sequence mode.
Definition: hpm_adc16_drv.h:203
bool seq_int_en
Definition: hpm_adc16_drv.h:204
uint8_t ch
Definition: hpm_adc16_drv.h:205