HPM SDK
HPMicro Software Development Kit
hpm_rdc_drv.h File Reference
#include "hpm_common.h"
#include "hpm_rdc_regs.h"
#include "hpm_soc_feature.h"

Go to the source code of this file.

Data Structures

struct  rdc_output_cfg
 Rdc output configuration. More...
 
struct  rdc_input_cfg
 Rdc input configuration. More...
 
struct  rdc_acc_cfg
 Accumulated configuration information. More...
 

Functions

RDC Control
void rdc_output_config (RDC_Type *ptr, rdc_output_cfg_t *cfg)
 Rdc output configuration, can be configured pwm output or dac output. More...
 
void rdc_input_config (RDC_Type *ptr, rdc_input_cfg_t *cfg)
 Rdc input configuration, configuration of adc signal source and calculation parameters. More...
 
static void rdc_set_acc_len (RDC_Type *ptr, uint8_t len)
 Configuration accumulate time, support on the fly change. More...
 
static void rdc_acc_enable (RDC_Type *ptr)
 Enable accumulate calculation function. More...
 
static void rdc_acc_disable (RDC_Type *ptr)
 Disable accumulate calculation function. More...
 
uint32_t rdc_get_acc_avl (RDC_Type *ptr, rdc_input_acc_chn_t chn)
 Get the accumulate value. More...
 
void rdc_output_trig_offset_config (RDC_Type *ptr, rdc_output_trig_chn_t chn, int32_t offset)
 Output trigger configuration Lead time for trigger out0 or out1 from center of low level , this is a signed value. More...
 
void rdc_output_trig_enable (RDC_Type *ptr, rdc_output_trig_chn_t chn)
 Enable output trigger configuration. More...
 
void rdc_output_trig_disable (RDC_Type *ptr, rdc_output_trig_chn_t chn)
 Disable rdc output trigger configuration. More...
 
static void rdc_sync_output_trig_adc_cfg (RDC_Type *ptr, rdc_sync_out_src_t sel)
 Select output synchornize signal. More...
 
static void rdc_exc_enable (RDC_Type *ptr)
 Enable rdc excite signal. More...
 
static void rdc_exc_disable (RDC_Type *ptr)
 Disable rdc excite signal. More...
 
static void rdc_output_trig_sw (RDC_Type *ptr)
 Software triggered excitation signal output. More...
 
int32_t rdc_get_i_maxval (RDC_Type *ptr)
 Get I-phase maximum. More...
 
static void rdc_clear_i_maxval (RDC_Type *ptr)
 Clear Maximum. More...
 
int32_t rdc_get_i_minval (RDC_Type *ptr)
 Get I-phase minimum. More...
 
static void rdc_clear_i_minval (RDC_Type *ptr)
 Clear I-phase minimum. More...
 
void rdc_set_acc_sync_delay (RDC_Type *ptr, rdc_input_acc_chn_t chn, uint32_t delay)
 Set Acc sync delay. More...
 
static uint32_t rdc_get_sync_output_delay (RDC_Type *ptr)
 Delay bettween the delyed trigger and the first pwm pulse in clock cycle. More...
 
int32_t rdc_get_q_maxval (RDC_Type *ptr)
 Get Q-phase maximum. More...
 
static void rdc_clear_q_maxval (RDC_Type *ptr)
 Clear Q-phase maxval. More...
 
int32_t rdc_get_q_minval (RDC_Type *ptr)
 Get Q-phase Minval. More...
 
static void rdc_clear_q_minval (RDC_Type *ptr)
 Clear Q-phase Minval. More...
 
void rdc_set_edge_detection_offset (RDC_Type *ptr, rdc_input_acc_chn_t chn, int32_t offset)
 The offset setting for edge detection of the i_channel or q_channel. More...
 
void rdc_set_acc_config (RDC_Type *ptr, rdc_acc_cfg_t *cfg)
 RDC set accumulate configuration. More...
 
static uint32_t rdc_get_rise_delay_i (RDC_Type *ptr)
 Get delay in clock cycle between excitation synchrnous signal and rising edge of i_channel data. More...
 
static uint32_t rdc_get_fall_delay_i (RDC_Type *ptr)
 Get delay in clock cycle between excitation synchrnous signal and fall edge of i_channel data. More...
 
static uint32_t rdc_get_sample_rise_i (RDC_Type *ptr)
 Get sample value on rising edge of rectify signal. More...
 
static uint32_t rdc_get_sample_fall_i (RDC_Type *ptr)
 Get sample value on falling edge of rectify signal. More...
 
static uint32_t rdc_get_acc_cnt_positive_i (RDC_Type *ptr)
 Get sample number during the positive of rectify signal. More...
 
static uint32_t rdc_get_acc_cnt_negative_i (RDC_Type *ptr)
 Get sample number during the negtive of rectify signal. More...
 
static uint32_t rdc_get_sign_cnt_poitive_i (RDC_Type *ptr)
 Get Negative sample counter during positive rectify signal. More...
 
static uint32_t rdc_get_sign_cnt_negative_i (RDC_Type *ptr)
 Get Positive sample counter during negative rectify signal. More...
 
static uint32_t rdc_get_rise_delay_q (RDC_Type *ptr)
 Get delay in clock cycle between excitation synchrnous signal and rising edge of q_channel data. More...
 
static uint32_t rdc_get_fall_delay_q (RDC_Type *ptr)
 Get delay in clock cycle between excitation synchrnous signal and falling edge of q_channel data. More...
 
static uint32_t rdc_get_sample_rise_q (RDC_Type *ptr)
 Get q channel sample value on rising edge of rectify signal. More...
 
static uint32_t rdc_get_sample_fall_q (RDC_Type *ptr)
 Get q channel sample value on falling edge of rectify signal. More...
 
static uint32_t rdc_get_acc_cnt_positive_q (RDC_Type *ptr)
 Get q channel sample number during the positive of rectify signal. More...
 
static uint32_t rdc_get_acc_cnt_negative_q (RDC_Type *ptr)
 Get q channel sample number during the negtive of rectify signal. More...
 
static uint32_t rdc_get_sign_cnt_poitive_q (RDC_Type *ptr)
 Get q channel negative sample counter during positive rectify signal. More...
 
static uint32_t rdc_get_sign_cnt_negative_q (RDC_Type *ptr)
 Get q channel sample number during the negtive of rectify signal. More...
 
static void rdc_interrupt_config (RDC_Type *ptr, uint32_t status)
 Enables configured interrupts. More...
 
static void rdc_interrupt_reset_config (RDC_Type *ptr, uint32_t status)
 Clear interrupts configured. More...
 
static void rdc_interrupt_enable (RDC_Type *ptr)
 Enable rdc interrupt. More...
 
static void rdc_interrupt_disable (RDC_Type *ptr)
 Disable rdc interrupt. More...
 
static void rdc_interrupt_clear_flag_bits (RDC_Type *ptr, uint32_t mask)
 Clear interrupt flag bits. More...
 
static uint32_t get_interrupt_status (RDC_Type *ptr)
 Get the interrupt status object. More...
 

Initialization and Deinitialization

enum  rdc_output_precision {
  rdc_output_precision_4_point = 0 , rdc_output_precision_8_point = 1 , rdc_output_precision_16_point = 2 , rdc_output_precision_32_point = 3 ,
  rdc_output_precision_64_point = 4 , rdc_output_precision_128_point = 5 , rdc_output_precision_256_point = 6 , rdc_output_precision_512_point = 7 ,
  rdc_output_precision_1024_point = 8
}
 Rdc output precision, use n points to form an excitation signal period. More...
 
enum  rdc_output_pwm_period {
  rdc_output_pwm_period_1_sample = 0 , rdc_output_pwm_period_2_sample , rdc_output_pwm_period_3_sample , rdc_output_pwm_period_4_sample ,
  rdc_output_pwm_period_5_sample , rdc_output_pwm_period_6_sample , rdc_output_pwm_period_7_sample , rdc_output_pwm_period_8_sample ,
  rdc_output_pwm_period_9_sample , rdc_output_pwm_period_10_sample , rdc_output_pwm_period_11_sample , rdc_output_pwm_period_12_sample ,
  rdc_output_pwm_period_13_sample , rdc_output_pwm_period_14_sample , rdc_output_pwm_period_15_sample , rdc_output_pwm_period_16_sample
}
 Pwm output period in samples. More...
 
enum  rdc_output_mode { rdc_output_dac , rdc_output_pwm }
 Rdc output mode. More...
 
enum  rdc_sync_out_src {
  rdc_sync_out_exc_0_ph = RDC_SYNC_OUT_CTRL_SYNC_OUT_SEL_SET(0) , rdc_sync_out_exc_90_ph = RDC_SYNC_OUT_CTRL_SYNC_OUT_SEL_SET(1) , rdc_sync_out_exc_180_ph = RDC_SYNC_OUT_CTRL_SYNC_OUT_SEL_SET(2) , rdc_sync_out_exc_270_ph = RDC_SYNC_OUT_CTRL_SYNC_OUT_SEL_SET(3) ,
  rdc_sync_out_max = RDC_SYNC_OUT_CTRL_MAX2TRIG_EN_MASK , rdc_sync_out_min = RDC_SYNC_OUT_CTRL_MIN2TRIG_EN_MASK
}
 Synchronize output trig adc position. More...
 
enum  rdc_rectify_signal {
  rdc_rectify_signal_exc_0_ph = 0 , rdc_rectify_signal_exc_90_ph = 1 , rdc_rectify_signal_exc_180_ph = 2 , rdc_rectify_signal_exc_270_ph = 3 ,
  rdc_rectify_signal_external = 4 , rdc_rectify_signal_external_invert = 5
}
 Select reference point of rectify signal. More...
 
enum  rdc_acc_stamp_time { rdc_acc_stamp_end_of_acc = 0 , rdc_acc_stamp_start_of_acc = 1 , rdc_acc_stamp_center_of_acc = 2 }
 Time stamp selection for accumulation. More...
 
enum  rdc_output_trig_chn { trigger_out_0 = 0 , trigger_out_1 = 1 }
 Rdc trigger out channel 0 or channel 1. More...
 
enum  rdc_input_acc_chn { rdc_acc_chn_i = 0 , rdc_acc_chn_q = 1 }
 Rdc input channel. More...
 
enum  rdc_input_max_min_value_source { rdc_value_at_adc = 0 , rdc_value_at_iir = 1 }
 
enum  rdc_interrupt_stat {
  acc_vld_i_stat = RDC_INT_EN_ACC_VLD_I_EN_MASK , acc_vld_q_stat = RDC_INT_EN_ACC_VLD_Q_EN_MASK , rising_delay_i_stat = RDC_INT_EN_RISING_DELAY_I_EN_MASK , falling_delay_i_stat = RDC_INT_EN_FALLING_DELAY_I_EN_MASK ,
  rising_delay_q_stat = RDC_INT_EN_RISING_DELAY_Q_EN_MASK , falling_delay_q_stat = RDC_INT_EN_FALLING_DELAY_Q_EN_MASK , sample_rising_i_stat = RDC_INT_EN_SAMPLE_RISING_I_EN_MASK , sample_falling_i_stat = RDC_INT_EN_SAMPLE_FALLING_I_EN_MASK ,
  sample_rising_q_stat = RDC_INT_EN_SAMPLE_RISING_Q_EN_MASK , sample_falling_q_stat = RDC_INT_EN_SAMPLE_FALLING_Q_EN_MASK , acc_vld_i_ovh_stat = RDC_INT_EN_ACC_VLD_I_OVH_EN_MASK , acc_vld_q_ovh_stat = RDC_INT_EN_ACC_VLD_Q_OVH_EN_MASK ,
  acc_vld_i_ovl_stat = RDC_INT_EN_ACC_VLD_I_OVL_EN_MASK , acc_vld_q_ovl_stat = RDC_INT_EN_ACC_VLD_Q_OVL_EN_MASK , acc_amp_ovh_stat = RDC_INT_EN_ACC_AMP_OVH_EN_MASK , acc_amp_ovl_stat = RDC_INT_EN_ACC_AMP_OVL_EN_MASK
}
 Rdc status flags. More...
 
typedef enum rdc_output_precision rdc_output_precision_t
 Rdc output precision, use n points to form an excitation signal period. More...
 
typedef enum rdc_output_pwm_period rdc_output_pwm_period_t
 Pwm output period in samples. More...
 
typedef enum rdc_output_mode rdc_output_mode_t
 Rdc output mode. More...
 
typedef enum rdc_sync_out_src rdc_sync_out_src_t
 Synchronize output trig adc position. More...
 
typedef enum rdc_rectify_signal rdc_rectify_signal_t
 Select reference point of rectify signal. More...
 
typedef enum rdc_acc_stamp_time rdc_acc_stamp_time_t
 Time stamp selection for accumulation. More...
 
typedef enum rdc_output_trig_chn rdc_output_trig_chn_t
 Rdc trigger out channel 0 or channel 1. More...
 
typedef enum rdc_input_acc_chn rdc_input_acc_chn_t
 Rdc input channel. More...
 
typedef enum rdc_input_max_min_value_source rdc_input_max_min_value_source_t
 
typedef enum rdc_interrupt_stat rdc_interrupt_stat_t
 Rdc status flags. More...
 
typedef struct rdc_output_cfg rdc_output_cfg_t
 Rdc output configuration. More...
 
typedef struct rdc_input_cfg rdc_input_cfg_t
 Rdc input configuration. More...
 
typedef struct rdc_acc_cfg rdc_acc_cfg_t
 Accumulated configuration information. More...