HPM SDK
HPMicro Software Development Kit
SDM driver APIs

SDM APIs. More...

Data Structures

struct  sdm_control_t
 
struct  sdm_channel_common_config_t
 
struct  sdm_comparator_config_t
 
struct  sdm_filter_config_t
 
struct  sdm_output_config_t
 

Macros

#define SAMPLING_MODE_MASK   (0x7U)
 
#define CHN_SAMPLING_MODE_SHIFT(ch)   ((ch) * 3U + SDM_CTRL_CHMD_SHIFT)
 
#define CHN_SAMPLING_MODE_MASK(ch)   (SAMPLING_MODE_MASK << CHN_SAMPLING_MODE_SHIFT(ch))
 
#define CH0_EN_MASK   (0x1U << SDM_CTRL_CH_EN_SHIFT)
 
#define CHN_EN_MASK(ch)   (CH0_EN_MASK << (ch))
 
#define CHN_ERR_MASK(ch)   (SDM_INT_EN_CH0ERR_MASK << (ch))
 
#define CHN_DRY_MASK(ch)   (SDM_INT_EN_CH0DRY_MASK << (ch))
 

Enumerations

enum  sdm_sampling_mode_t {
  sdm_sampling_rising_clk_edge = 0 , sdm_sampling_every_clk_edge = 1 , sdm_sampling_manchester_mode = 2 , sdm_sampling_falling_clk_edge = 3 ,
  sdm_sampling_rising_two_clk_edge = 4 , sdm_sampling_falling_two_clk_edge = 5
}
 
enum  sdm_filter_type_t { sdm_filter_sinc1 = 0 , sdm_filter_sinc2 = 1 , sdm_filter_sinc3 = 2 , sdm_filter_fast_sinc2 = 3 }
 
enum  sdm_comparator_event_t {
  sdm_comparator_no_event = 0 , sdm_comparator_event_out_high_threshold = SDM_CH_SCST_CMPH_MASK , sdm_comparator_event_out_low_threshold = SDM_CH_SCST_CMPL_MASK , sdm_comparator_event_hz = SDM_CH_SCST_HZ_MASK ,
  sdm_comparator_event_invalid_clk = SDM_CH_SCST_MF_MASK
}
 
enum  sdm_channel_int_status_mask_t {
  sdm_chn0_error_mask = SDM_INT_EN_CH0ERR_MASK , sdm_chn1_error_mask = SDM_INT_EN_CH1ERR_MASK , sdm_chn2_error_mask = SDM_INT_EN_CH2ERR_MASK , sdm_chn3_error_mask = SDM_INT_EN_CH3ERR_MASK ,
  sdm_chn0_data_ready_mask = SDM_INT_EN_CH0DRY_MASK , sdm_chn1_data_ready_mask = SDM_INT_EN_CH1DRY_MASK , sdm_chn2_data_ready_mask = SDM_INT_EN_CH2DRY_MASK , sdm_chn3_data_ready_mask = SDM_INT_EN_CH3DRY_MASK
}
 
enum  sdm_channel_enable_mask_t { sdm_chn0_enable_mask = 1U << SDM_CTRL_CH_EN_SHIFT , sdm_chn1_enable_mask = 1U << (SDM_CTRL_CH_EN_SHIFT + 1U) , sdm_chn2_enable_mask = 1U << (SDM_CTRL_CH_EN_SHIFT + 2U) , sdm_chn3_enable_mask = 1U << (SDM_CTRL_CH_EN_SHIFT + 3U) }
 

Functions

static void sdm_enable_module_interrupt (SDM_Type *ptr, bool enable)
 sdm enable module interrupt More...
 
static void sdm_enable_channel (SDM_Type *ptr, uint8_t ch_index, bool enable)
 sdm enable channel More...
 
static void sdm_enable_channel_filter (SDM_Type *ptr, uint8_t ch_index, bool enable)
 sdm enable channel sample data function More...
 
static void sdm_enable_channel_comparator (SDM_Type *ptr, uint8_t ch_index, bool enable)
 sdm enable channel amplitude detect function More...
 
static void sdm_enable_channel_by_mask (SDM_Type *ptr, uint32_t ch_mask)
 sdm enable channel by mask More...
 
static void sdm_set_channel_sampling_mode (SDM_Type *ptr, uint8_t ch_index, sdm_sampling_mode_t mode)
 sdm set channel sampling mode More...
 
static void sdm_enable_channel_interrupt (SDM_Type *ptr, uint32_t mask)
 sdm enable channel interrupt More...
 
static uint32_t sdm_get_status (SDM_Type *ptr)
 sdm get status register value More...
 
static bool sdm_get_channel_data_ready_status (SDM_Type *ptr, uint8_t ch)
 get channel data ready status More...
 
static bool sdm_get_channel_data_error_status (SDM_Type *ptr, uint8_t ch)
 get channel error status More...
 
static void sdm_set_ch_fifo_threshold (SDM_Type *ptr, uint8_t ch, uint8_t threshold)
 sdm set channel's fifo threshold More...
 
static uint8_t sdm_get_ch_fifo_threshold (SDM_Type *ptr, uint8_t ch)
 sdm get channel fifo threshold More...
 
static uint32_t sdm_get_channel_filter_status (SDM_Type *ptr, uint8_t ch)
 sdm get channel filter status More...
 
static void sdm_clean_channel_filter_status (SDM_Type *ptr, uint8_t ch, uint32_t mask)
 sdm clean channel sample data status More...
 
static uint8_t sdm_get_channel_fifo_data_count (SDM_Type *ptr, uint8_t ch)
 sdm get channel data count in fifo More...
 
static int32_t sdm_get_channel_fifo_data (SDM_Type *ptr, uint8_t ch)
 sdm get channel filter output data in fifo More...
 
static uint8_t sdm_get_channel_clock_cycle_count (SDM_Type *ptr, uint8_t ch)
 sdm get channel input clock cycle count More...
 
static uint16_t sdm_get_channel_comparator_data (SDM_Type *ptr, uint8_t ch)
 sdm get channel comparator data More...
 
static void sdm_set_channel_comparator_high_threshold (SDM_Type *ptr, uint8_t ch, uint16_t value)
 sdm set channel comparator high threshold More...
 
static void sdm_set_channel_comparator_zero_crossing_threshold (SDM_Type *ptr, uint8_t ch, uint16_t value)
 sdm set channel comparator zero crossing threshold More...
 
static void sdm_set_channel_comparator_low_threshold (SDM_Type *ptr, uint8_t ch, uint16_t value)
 sdm set channel comparator low threshold More...
 
static uint32_t sdm_get_channel_comparator_status (SDM_Type *ptr, uint8_t ch)
 sdm get channel comparator status register value More...
 
static void sdm_clean_channel_comparator_status (SDM_Type *ptr, uint8_t ch, uint32_t mask)
 sdm clean channel amplitude detect status More...
 
void sdm_get_default_module_control (SDM_Type *ptr, sdm_control_t *control)
 sdm get default module control More...
 
void sdm_init_module (SDM_Type *ptr, sdm_control_t *control)
 sdm init module More...
 
void sdm_get_channel_common_setting (SDM_Type *ptr, sdm_channel_common_config_t *config)
 sdm get channel common setting More...
 
void sdm_config_channel_common_setting (SDM_Type *ptr, uint8_t ch_index, sdm_channel_common_config_t *config)
 sdm config channel's common setting More...
 
void sdm_get_channel_default_filter_config (SDM_Type *ptr, sdm_filter_config_t *filter_config)
 sdm get channel default filter config More...
 
void sdm_config_channel_filter (SDM_Type *ptr, uint8_t ch_index, sdm_filter_config_t *filter_config)
 sdm config channel filter More...
 
void sdm_get_channel_default_comparator_config (SDM_Type *ptr, sdm_comparator_config_t *cmp_config)
 sdm get channel default comparator config More...
 
void sdm_config_channel_comparator (SDM_Type *ptr, uint8_t ch_index, sdm_comparator_config_t *cmp_config)
 sdm config channel comparator More...
 
hpm_stat_t sdm_receive_one_filter_data (SDM_Type *ptr, uint8_t ch_index, bool using_fifo, int8_t *data, uint8_t data_len_in_bytes)
 sdm receive one filter data More...
 
hpm_stat_t sdm_receive_filter_data (SDM_Type *ptr, uint8_t ch_index, bool using_fifo, int8_t *data, uint32_t count, uint8_t data_len_in_bytes)
 sdm receive filter data More...
 

Detailed Description

SDM APIs.

Macro Definition Documentation

◆ CH0_EN_MASK

#define CH0_EN_MASK   (0x1U << SDM_CTRL_CH_EN_SHIFT)

◆ CHN_DRY_MASK

#define CHN_DRY_MASK (   ch)    (SDM_INT_EN_CH0DRY_MASK << (ch))

◆ CHN_EN_MASK

#define CHN_EN_MASK (   ch)    (CH0_EN_MASK << (ch))

◆ CHN_ERR_MASK

#define CHN_ERR_MASK (   ch)    (SDM_INT_EN_CH0ERR_MASK << (ch))

◆ CHN_SAMPLING_MODE_MASK

#define CHN_SAMPLING_MODE_MASK (   ch)    (SAMPLING_MODE_MASK << CHN_SAMPLING_MODE_SHIFT(ch))

◆ CHN_SAMPLING_MODE_SHIFT

#define CHN_SAMPLING_MODE_SHIFT (   ch)    ((ch) * 3U + SDM_CTRL_CHMD_SHIFT)

◆ SAMPLING_MODE_MASK

#define SAMPLING_MODE_MASK   (0x7U)

Enumeration Type Documentation

◆ sdm_channel_enable_mask_t

#include <drivers/inc/hpm_sdm_drv.h>

Enumerator
sdm_chn0_enable_mask 
sdm_chn1_enable_mask 
sdm_chn2_enable_mask 
sdm_chn3_enable_mask 

◆ sdm_channel_int_status_mask_t

#include <drivers/inc/hpm_sdm_drv.h>

Enumerator
sdm_chn0_error_mask 
sdm_chn1_error_mask 
sdm_chn2_error_mask 
sdm_chn3_error_mask 
sdm_chn0_data_ready_mask 
sdm_chn1_data_ready_mask 
sdm_chn2_data_ready_mask 
sdm_chn3_data_ready_mask 

◆ sdm_comparator_event_t

#include <drivers/inc/hpm_sdm_drv.h>

Enumerator
sdm_comparator_no_event 
sdm_comparator_event_out_high_threshold 
sdm_comparator_event_out_low_threshold 
sdm_comparator_event_hz 
sdm_comparator_event_invalid_clk 

◆ sdm_filter_type_t

#include <drivers/inc/hpm_sdm_drv.h>

Enumerator
sdm_filter_sinc1 
sdm_filter_sinc2 
sdm_filter_sinc3 
sdm_filter_fast_sinc2 

◆ sdm_sampling_mode_t

#include <drivers/inc/hpm_sdm_drv.h>

Enumerator
sdm_sampling_rising_clk_edge 
sdm_sampling_every_clk_edge 
sdm_sampling_manchester_mode 
sdm_sampling_falling_clk_edge 
sdm_sampling_rising_two_clk_edge 
sdm_sampling_falling_two_clk_edge 

Function Documentation

◆ sdm_clean_channel_comparator_status()

static void sdm_clean_channel_comparator_status ( SDM_Type ptr,
uint8_t  ch,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm clean channel amplitude detect status

Parameters
ptrSDM base address
chchannel index
uint32_tmask status mask value

◆ sdm_clean_channel_filter_status()

static void sdm_clean_channel_filter_status ( SDM_Type ptr,
uint8_t  ch,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm clean channel sample data status

Parameters
ptrSDM base address
chchannel index
uint32_tmask status mask value

◆ sdm_config_channel_common_setting()

void sdm_config_channel_common_setting ( SDM_Type ptr,
uint8_t  ch_index,
sdm_channel_common_config_t config 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm config channel's common setting

Parameters
ptrSDM base address
ch_indexchannel index
configsdm_channel_common_config_t

◆ sdm_config_channel_comparator()

void sdm_config_channel_comparator ( SDM_Type ptr,
uint8_t  ch_index,
sdm_comparator_config_t cmp_config 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm config channel comparator

Parameters
ptrSDM base address
ch_indexchannel index
cmp_configsdm_comparator_config_t

◆ sdm_config_channel_filter()

void sdm_config_channel_filter ( SDM_Type ptr,
uint8_t  ch_index,
sdm_filter_config_t filter_config 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm config channel filter

Parameters
ptrSDM base address
ch_indexchannel index
filter_configsdm_filter_config_t

◆ sdm_enable_channel()

static void sdm_enable_channel ( SDM_Type ptr,
uint8_t  ch_index,
bool  enable 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm enable channel

Parameters
ptrSDM base address
ch_indexchannel index
enabletrue for enable, false for disable

◆ sdm_enable_channel_by_mask()

static void sdm_enable_channel_by_mask ( SDM_Type ptr,
uint32_t  ch_mask 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm enable channel by mask

Note
ch_mask supports bitwise or operation, this API could enable multiple channels at the same time
Parameters
ptrSDM base address
ch_masksdm_channel_enable_mask_t

◆ sdm_enable_channel_comparator()

static void sdm_enable_channel_comparator ( SDM_Type ptr,
uint8_t  ch_index,
bool  enable 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm enable channel amplitude detect function

Parameters
ptrSDM base address
ch_indexchannel index
enabletrue for enable, false for disable

◆ sdm_enable_channel_filter()

static void sdm_enable_channel_filter ( SDM_Type ptr,
uint8_t  ch_index,
bool  enable 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm enable channel sample data function

Parameters
ptrSDM base address
ch_indexchannel index
enabletrue for enable, false for disable

◆ sdm_enable_channel_interrupt()

static void sdm_enable_channel_interrupt ( SDM_Type ptr,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm enable channel interrupt

Parameters
ptrSDM base address
masksdm_channel_int_status_mask_t, support bitwise or operation

◆ sdm_enable_module_interrupt()

static void sdm_enable_module_interrupt ( SDM_Type ptr,
bool  enable 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm enable module interrupt

Parameters
ptrSDM base address
enabletrue for enable, false for disable

◆ sdm_get_ch_fifo_threshold()

static uint8_t sdm_get_ch_fifo_threshold ( SDM_Type ptr,
uint8_t  ch 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel fifo threshold

Parameters
ptrSDM base address
chchannel index
Returns
uint8_t fifo threshold value

◆ sdm_get_channel_clock_cycle_count()

static uint8_t sdm_get_channel_clock_cycle_count ( SDM_Type ptr,
uint8_t  ch 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel input clock cycle count

Parameters
ptrSDM base address
chchannel index
Returns
uint8_t clock cycle count

◆ sdm_get_channel_common_setting()

void sdm_get_channel_common_setting ( SDM_Type ptr,
sdm_channel_common_config_t config 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel common setting

Parameters
ptrSDM base address
configsdm_channel_common_config_t

◆ sdm_get_channel_comparator_data()

static uint16_t sdm_get_channel_comparator_data ( SDM_Type ptr,
uint8_t  ch 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel comparator data

Parameters
ptrSDM base address
chchannel index
Returns
uint16_t comparator data

◆ sdm_get_channel_comparator_status()

static uint32_t sdm_get_channel_comparator_status ( SDM_Type ptr,
uint8_t  ch 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel comparator status register value

Parameters
ptrSDM base address
chchannel index
Returns
uint32_t channel comparator status register value

◆ sdm_get_channel_data_error_status()

static bool sdm_get_channel_data_error_status ( SDM_Type ptr,
uint8_t  ch 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

get channel error status

Parameters
ptrSDM base address
chchannel
Returns
true error occur
false no error

◆ sdm_get_channel_data_ready_status()

static bool sdm_get_channel_data_ready_status ( SDM_Type ptr,
uint8_t  ch 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

get channel data ready status

Parameters
ptrSDM base address
chchannel
Returns
true data ready
false not ready

◆ sdm_get_channel_default_comparator_config()

void sdm_get_channel_default_comparator_config ( SDM_Type ptr,
sdm_comparator_config_t cmp_config 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel default comparator config

Parameters
ptrSDM base address
cmp_configsdm_comparator_config_t

< 1-32, when 32, write 0 into bitfield

◆ sdm_get_channel_default_filter_config()

void sdm_get_channel_default_filter_config ( SDM_Type ptr,
sdm_filter_config_t filter_config 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel default filter config

Parameters
ptrSDM base address
filter_configsdm_filter_config_t

< 1- 256

◆ sdm_get_channel_fifo_data()

static int32_t sdm_get_channel_fifo_data ( SDM_Type ptr,
uint8_t  ch 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel filter output data in fifo

Parameters
ptrSDM base address
chchannel index
Returns
int32_t data

◆ sdm_get_channel_fifo_data_count()

static uint8_t sdm_get_channel_fifo_data_count ( SDM_Type ptr,
uint8_t  ch 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel data count in fifo

Parameters
ptrSDM base address
chchannel index
Returns
uint8_t data count

◆ sdm_get_channel_filter_status()

static uint32_t sdm_get_channel_filter_status ( SDM_Type ptr,
uint8_t  ch 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm get channel filter status

Parameters
ptrSDM base address
chchannel index
Returns
uint32_t channel filter status register value

◆ sdm_get_default_module_control()

void sdm_get_default_module_control ( SDM_Type ptr,
sdm_control_t control 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm get default module control

Parameters
ptrSDM base address
controlsdm_control_t

< configure clk sync for all channels

< configure data sync for all channels

◆ sdm_get_status()

static uint32_t sdm_get_status ( SDM_Type ptr)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm get status register value

Parameters
ptrSDM base address
Returns
uint32_t sdm status register value

◆ sdm_init_module()

void sdm_init_module ( SDM_Type ptr,
sdm_control_t control 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm init module

Parameters
ptrSDM base address
controlsdm_control_t

◆ sdm_receive_filter_data()

hpm_stat_t sdm_receive_filter_data ( SDM_Type ptr,
uint8_t  ch_index,
bool  using_fifo,
int8_t *  data,
uint32_t  count,
uint8_t  data_len_in_bytes 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm receive filter data

Parameters
ptrSDM base address
ch_indexchannel index
using_fifotrue for getting data from fifo, false for getting data from register
datadata buff
countdata count
data_len_in_bytesoutput data len in bytes
Return values
hpm_stat_tstatus_success only if it succeeds

◆ sdm_receive_one_filter_data()

hpm_stat_t sdm_receive_one_filter_data ( SDM_Type ptr,
uint8_t  ch_index,
bool  using_fifo,
int8_t *  data,
uint8_t  data_len_in_bytes 
)

#include <drivers/inc/hpm_sdm_drv.h>

sdm receive one filter data

Parameters
ptrSDM base address
ch_indexchannel index
using_fifotrue for getting data from fifo, false for getting data from register
datadata buff
data_len_in_bytesoutput data len in bytes
Return values
hpm_stat_tstatus_success only if it succeeds

◆ sdm_set_ch_fifo_threshold()

static void sdm_set_ch_fifo_threshold ( SDM_Type ptr,
uint8_t  ch,
uint8_t  threshold 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm set channel's fifo threshold

Parameters
ptrSDM base address
chchannel index
thresholdthreshold value

◆ sdm_set_channel_comparator_high_threshold()

static void sdm_set_channel_comparator_high_threshold ( SDM_Type ptr,
uint8_t  ch,
uint16_t  value 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm set channel comparator high threshold

Parameters
ptrSDM base address
chchannel index
valuehigh threshold value

◆ sdm_set_channel_comparator_low_threshold()

static void sdm_set_channel_comparator_low_threshold ( SDM_Type ptr,
uint8_t  ch,
uint16_t  value 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm set channel comparator low threshold

Parameters
ptrSDM base address
chchannel index
valuelow threshold value

◆ sdm_set_channel_comparator_zero_crossing_threshold()

static void sdm_set_channel_comparator_zero_crossing_threshold ( SDM_Type ptr,
uint8_t  ch,
uint16_t  value 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm set channel comparator zero crossing threshold

Parameters
ptrSDM base address
chchannel index
valuezero crossing threshold value

◆ sdm_set_channel_sampling_mode()

static void sdm_set_channel_sampling_mode ( SDM_Type ptr,
uint8_t  ch_index,
sdm_sampling_mode_t  mode 
)
inlinestatic

#include <drivers/inc/hpm_sdm_drv.h>

sdm set channel sampling mode

Parameters
ptrSDM base address
ch_indexchannel index
modesdm_sampling_mode_t