HPM SDK
HPMicro Software Development Kit
HPM ADC driver APIs

ADC HAL driver APIs. More...

Data Structures

union  adc_base
 An ADC peripheral base address. More...
 
struct  adc_config_t
 ADC common configuration struct. More...
 
struct  adc_channel_config_t
 ADC channel configuration struct. More...
 
struct  adc_dma_config_t
 ADC DMA configuration struct. More...
 
struct  adc_prd_config_t
 ADC configuration struct for period mode. More...
 
struct  adc_seq_config_t
 ADC configuration struct for sequence mode. More...
 
struct  adc_pmt_config_t
 ADC trigger configuration struct for preempt mode. More...
 
struct  adc_type
 

Macros

#define ADCX_MODULE_ADC12   1
 use adc12 or adc16. More...
 
#define ADCX_MODULE_ADC16   2
 

Enumerations

enum  adc_module { adc_module_adc12 = 1 , adc_module_adc16 = 2 }
 

Functions

static void hpm_adc_init_default_config (adc_config_t *config)
 Get a default configuration for an ADC instance. More...
 
static void hpm_adc_init_channel_default_config (adc_channel_config_t *config)
 Get a default configuration for an ADC channel instance. More...
 
static hpm_stat_t hpm_adc_init (adc_config_t *config)
 Initialize an ADC instance. More...
 
static hpm_stat_t hpm_adc_channel_init (adc_channel_config_t *config)
 Initialize an ADC channel. More...
 
static hpm_stat_t hpm_adc_set_period_config (adc_prd_config_t *config)
 Configure the periodic mode for an ADC instance. More...
 
static hpm_stat_t hpm_adc_set_sequence_config (adc_seq_config_t *config)
 Configure the sequence mode for an ADC instance. More...
 
static hpm_stat_t hpm_adc_set_preempt_config (adc_pmt_config_t *config)
 Configure the preemption mode for an ADC instance. More...
 
static void hpm_adc_set_seq_stop_pos (adc_type *ptr, uint16_t stop_pos)
 Configure the stop position offset in the specified memory for DMA write operation for sequence mode. More...
 
static void hpm_adc_init_pmt_dma (adc_type *ptr, uint32_t addr)
 Configure the start address of DMA write operation for preemption mode. More...
 
static void hpm_adc_init_seq_dma (adc_dma_config_t *config)
 Configure the start address of DMA write operation for preemption mode. More...
 
static void hpm_adc_disable_busywait (adc_dma_config_t *config)
 Reset value of the WAIT_DIS bit. ADC blocks access to the associated peripheral bus until the ADC completes the conversion. More...
 
static void hpm_adc_enable_busywait (adc_dma_config_t *config)
 Set value of the WAIT_DIS bit. The ADC does not block access to the associated peripheral bus until the ADC has completed its conversion. More...
 
static uint32_t hpm_adc_get_status_flags (adc_type *ptr)
 Get ADC status flags. More...
 
static bool hpm_adc_get_conv_valid_status (adc_type *ptr, uint8_t ch)
 Get status flag of a conversion. More...
 
static void hpm_adc_clear_status_flags (adc_type *ptr, uint32_t mask)
 Clear status flags. More...
 
static void hpm_adc_enable_interrupts (adc_type *ptr, uint32_t mask)
 Enable interrupts. More...
 
static void hpm_adc_disable_interrupts (adc_type *ptr, uint32_t mask)
 Disable interrupts. More...
 
static hpm_stat_t hpm_adc_get_oneshot_result (adc_type *ptr, uint8_t ch, uint16_t *result)
 Get the result in oneshot mode. More...
 
static hpm_stat_t hpm_adc_get_prd_result (adc_type *ptr, uint8_t ch, uint16_t *result)
 Get the result in periodic mode. More...
 
static hpm_stat_t hpm_adc_trigger_seq_by_sw (adc_type *ptr)
 Do a software trigger for sequence mode. More...
 

Detailed Description

ADC HAL driver APIs.

Macro Definition Documentation

◆ ADCX_MODULE_ADC12

#define ADCX_MODULE_ADC12   1

#include <components/adc/hpm_adc.h>

use adc12 or adc16.

◆ ADCX_MODULE_ADC16

#define ADCX_MODULE_ADC16   2

Enumeration Type Documentation

◆ adc_module

enum adc_module

#include <components/adc/hpm_adc.h>

Enumerator
adc_module_adc12 
adc_module_adc16 

Function Documentation

◆ hpm_adc_channel_init()

static hpm_stat_t hpm_adc_channel_init ( adc_channel_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Initialize an ADC channel.

Parameters
[in]configA pointer to the configuration struct of "adc_config_t".
Return values
status_successInitialize an ADC instance successfully.
status_invalid_argumentInitialize an ADC instance unsuccessfully because of passing one or more invalid arguments.

◆ hpm_adc_clear_status_flags()

static void hpm_adc_clear_status_flags ( adc_type ptr,
uint32_t  mask 
)
inlinestatic

#include <components/adc/hpm_adc.h>

Clear status flags.

Only the specified flags can be cleared by writing INT_STS register.

Parameters
[in]ptrAn ADC peripheral base address.
[in]maskMask value for flags to be cleared. Refer to "adc12_irq_event_t". Refer to "adc16_irq_event_t".

◆ hpm_adc_disable_busywait()

static void hpm_adc_disable_busywait ( adc_dma_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Reset value of the WAIT_DIS bit. ADC blocks access to the associated peripheral bus until the ADC completes the conversion.

Parameters
[in]configA pointer to configuration struct of "adc_dma_config_t".

◆ hpm_adc_disable_interrupts()

static void hpm_adc_disable_interrupts ( adc_type ptr,
uint32_t  mask 
)
inlinestatic

#include <components/adc/hpm_adc.h>

Disable interrupts.

Parameters
[in]ptrAn ADC peripheral base address.
[in]maskMask value for interrupt events. Refer to "adc12_irq_event_t".Refer to "adc16_irq_event_t".

◆ hpm_adc_enable_busywait()

static void hpm_adc_enable_busywait ( adc_dma_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Set value of the WAIT_DIS bit. The ADC does not block access to the associated peripheral bus until the ADC has completed its conversion.

Parameters
[in]configA pointer to configuration struct of "adc_dma_config_t".

◆ hpm_adc_enable_interrupts()

static void hpm_adc_enable_interrupts ( adc_type ptr,
uint32_t  mask 
)
inlinestatic

#include <components/adc/hpm_adc.h>

Enable interrupts.

Parameters
[in]ptrAn ADC peripheral base address.
[in]maskMask value for interrupt events. Refer to "adc12_irq_event_t".Refer to "adc16_irq_event_t".

◆ hpm_adc_get_conv_valid_status()

static bool hpm_adc_get_conv_valid_status ( adc_type ptr,
uint8_t  ch 
)
inlinestatic

#include <components/adc/hpm_adc.h>

Get status flag of a conversion.

This status flag is only used when wait_dis is set to disable.

Parameters
[in]ptrAn ADC peripheral base address.
[in]chAn ADC peripheral channel.
Return values
StatusIt means the current conversion is valid.

◆ hpm_adc_get_oneshot_result()

static hpm_stat_t hpm_adc_get_oneshot_result ( adc_type ptr,
uint8_t  ch,
uint16_t *  result 
)
inlinestatic

#include <components/adc/hpm_adc.h>

Get the result in oneshot mode.

Parameters
[in]ptrAn ADC peripheral base address.
[in]chAn ADC peripheral channel.
[out]resultThe result of an ADC12 conversion.
Return values
status_successGet the result of an ADC12 conversion in oneshot mode successfully.
status_invalid_argumentGet the result of an ADC12 conversion in oneshot mode unsuccessfully because of passing invalid arguments.

◆ hpm_adc_get_prd_result()

static hpm_stat_t hpm_adc_get_prd_result ( adc_type ptr,
uint8_t  ch,
uint16_t *  result 
)
inlinestatic

#include <components/adc/hpm_adc.h>

Get the result in periodic mode.

Parameters
[in]ptrAn ADC12 peripheral base address.
[in]chAn ADC12 peripheral channel.
[out]resultThe result of an ADC12 conversion.
Return values
status_successGet the result of an ADC12 conversion in periodic mode successfully.
status_invalid_argumentGet the result of an ADC12 conversion in periodic mode unsuccessfully because of passing invalid arguments.

◆ hpm_adc_get_status_flags()

static uint32_t hpm_adc_get_status_flags ( adc_type ptr)
inlinestatic

#include <components/adc/hpm_adc.h>

Get ADC status flags.

This function gets all ADC status flags.

Parameters
[in]ptrAn ADC peripheral base address.
Return values
StatusThe ADC interrupt status flags.

◆ hpm_adc_init()

static hpm_stat_t hpm_adc_init ( adc_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Initialize an ADC instance.

Parameters
[in]configA pointer to the configuration struct of "adc_config_t".
Return values
status_successInitialize an ADC instance successfully.
status_invalid_argumentInitialize an ADC instance unsuccessfully because of passing one or more invalid arguments.

◆ hpm_adc_init_channel_default_config()

static void hpm_adc_init_channel_default_config ( adc_channel_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Get a default configuration for an ADC channel instance.

Parameters
[out]configA pointer to the configuration struct of "adc_channel_config_t".

◆ hpm_adc_init_default_config()

static void hpm_adc_init_default_config ( adc_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Get a default configuration for an ADC instance.

Parameters
[out]configA pointer to the configuration struct of "adc_config_t".

◆ hpm_adc_init_pmt_dma()

static void hpm_adc_init_pmt_dma ( adc_type ptr,
uint32_t  addr 
)
inlinestatic

#include <components/adc/hpm_adc.h>

Configure the start address of DMA write operation for preemption mode.

Parameters
[in]ptrAn ADC peripheral base address.
[in]addrThe start address of DMA write operation.

◆ hpm_adc_init_seq_dma()

static void hpm_adc_init_seq_dma ( adc_dma_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Configure the start address of DMA write operation for preemption mode.

Parameters
[in]configA pointer to configuration struct of "adc_dma_config_t".

◆ hpm_adc_set_period_config()

static hpm_stat_t hpm_adc_set_period_config ( adc_prd_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Configure the periodic mode for an ADC instance.

Parameters
[in]configA pointer to the configuration struct of "adc_prd_config_t".
Return values
status_successConfigure the periodic mode for an ADC instance successfully.
status_invalid_argumentConfigure the periodic mode for an ADC instance unsuccessfully because of passing one or more invalid arguments.

◆ hpm_adc_set_preempt_config()

static hpm_stat_t hpm_adc_set_preempt_config ( adc_pmt_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Configure the preemption mode for an ADC instance.

Parameters
[in]configa pointer to configuration struct of "adc_pmt_config_t".
Return values
status_successConfigure the preemption mode for an ADC instance successfully.
status_invalid_argumentConfigure the preemption mode for an ADC instance unsuccessfully because of passing one or more invalid arguments.

◆ hpm_adc_set_seq_stop_pos()

static void hpm_adc_set_seq_stop_pos ( adc_type ptr,
uint16_t  stop_pos 
)
inlinestatic

#include <components/adc/hpm_adc.h>

Configure the stop position offset in the specified memory for DMA write operation for sequence mode.

Parameters
[in]ptrAn ADC peripheral base address.
[in]stop_posThe stop position offset.

◆ hpm_adc_set_sequence_config()

static hpm_stat_t hpm_adc_set_sequence_config ( adc_seq_config_t config)
inlinestatic

#include <components/adc/hpm_adc.h>

Configure the sequence mode for an ADC instance.

Parameters
[in]configA pointer to configuration struct of "adc_seq_config_t".
Return values
status_successConfigure the sequence mode for an ADC instance successfully.
status_invalid_argumentConfigure the sequence mode for an ADC instance unsuccessfully because of passing one or more invalid arguments.

◆ hpm_adc_trigger_seq_by_sw()

static hpm_stat_t hpm_adc_trigger_seq_by_sw ( adc_type ptr)
inlinestatic

#include <components/adc/hpm_adc.h>

Do a software trigger for sequence mode.

Parameters
[in]ptrAn adc peripheral base address.