CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
宏定义 | 函数
ci130x_pdm.c 文件参考

CI130X inner pdm的驱动函数 更多...

#include "ci130x_pdm.h"
#include "ci130x_alc.h"
#include "ci130x_scu.h"
#include "ci130x_system.h"
#include "ci_log.h"
#include <stdlib.h>
#include <string.h>
#include "ci130x_core_eclic.h"
#include "romlib_runtime.h"

宏定义

#define PDMC_CI_ASSERT(x, msg)
 
#define USE_CI130X_OWN_ALC   1
 
#define METHOD_TO_CONTROL_GAIN_ATTACK   0
 
#define ALC_JACK_WAY   PDM_ALC_MODE_JACKWAY2
 
#define ALC_HOLD_TIME   PDM_ALC_HOLD_TIME_2MS
 
#define ALC_DECAY_TIME   PDM_ALC_DECAY_TIME_2MS
 
#define ALC_ATTACK_TIME   PDM_ALC_ATTACK_TIME_2MS
 
#define ALC_MODE   0
 
#define ALC_ZERO_CROSS   PDM_GATE_DISABLE
 
#define ALC_FAST_DECAY_87_5   PDM_GATE_DISABLE
 
#define ALC_NOISE_GATE   PDM_GATE_DISABLE
 
#define ALC_NOISE_GATE_SET   PDM_NOISE_GATE_THRE_45dB
 
#define ALC_INIT_PGA_GAIN   0x1f
 
#define ALC_SAMPLE_RATE   PDM_SAMPLERATE_16K
 
#define ALC_LOW_8_BIT_MAX_LEVEL   ((uint8_t)(PDM_ALC_LEVEL__6dB >> 0))
 
#define ALC_HOGH_8_BIT_MAX_LEVEL   ((uint8_t)(PDM_ALC_LEVEL__6dB >> 8))
 
#define ALC_LOW_8_BIT_MIN_LEVEL   ((uint8_t)(PDM_ALC_LEVEL__7_5dB >> 0))
 
#define ALC_HOGH_8_BIT_MIN_LEVEL   ((uint8_t)(PDM_ALC_LEVEL__7_5dB >> 8))
 
#define ALC_AGC_FUNC_SEL   ENABLE
 
#define ALC_PGA_MAX_GAIN   PDM_ALC_PGA_MAX_GAIN_28_5dB
 
#define ALC_PGA_MIN_GAIN   PDM_ALC_PGA_MIN_GAIN__18dB
 
#define ALC_JUDGE   (PDM_ALC_JUDGE_AFTER_HIGHPASS)
 
#define ALC_CONTROL_PGA_L   (PDM_GATE_ENABLE)
 
#define ALC_CONTROL_PGA_R   (PDM_GATE_ENABLE)
 
#define HPF_GATE   (!PDM_GATE_ENABLE)
 
#define HPF_CONFIG   (PDM_HIGHPASS_CUT_OFF_20HZ)
 

函数

void pdm_reset (void)
 当主频为168时,延时100us 更多...
 
void pdm_adc_mode_set (pdm_mode_t mode, pdm_frame_1_2len_t frame_Len, pdm_valid_word_len_t word_len, pdm_i2s_data_famat_t data_fram)
 PDM作为ADC的模式选择 更多...
 
void pdm_dac_mode_set (pdm_mode_t mode, pdm_frame_1_2len_t frame_Len, pdm_valid_word_len_t word_len, pdm_i2s_data_famat_t data_fram)
 PDM作为DAC的模式选择 更多...
 
void pdm_power_up (pdm_current_t current)
 PDM模块上电 更多...
 
void pdm_power_off (void)
 关闭PDM模块电源 更多...
 
void pdm_hightpass_config (pdm_gate_t gate, pdm_highpass_cut_off_t Hz)
 配置PDM模块的高通滤波器 更多...
 
void pdm_set_input_mode_left (pdm_input_mode_t mode)
 设置左通道的输入模式 更多...
 
void pdm_set_input_mode_right (pdm_input_mode_t mode)
 设置右通道的输入模式 更多...
 
void pdm_set_mic_gain_left (pdm_mic_amplify_t gain)
 设置左通道的MIC增益 更多...
 
void pdm_set_mic_gain_right (pdm_mic_amplify_t gain)
 设置右通道的MIC增益 更多...
 
void pdm_adc_enable (pdm_adc_config_t *ADC_Config)
 使能PDM中的ADC: 1.使用此函数之前先初始化PDM_ADC_Config_TypeDef结构体并填写参数; 2.ALCL_Gain和ALCR_Gain的上下限分别是28.5dB和-18dB,步长1.5。 更多...
 
void pdm_adc_dig_gain_set (pdm_cha_sel_t cha, int32_t gain)
 调节CODEC ADC的数字增益(197为0dB,加减1为加减0.5dB增益) 更多...
 
void pdm_adc_disable (pdm_cha_sel_t cha, pdm_gate_t EN)
 关闭PDM中的ADC 更多...
 
void pdm_dac_gain_set (int32_t l_gain, int32_t r_gain)
 配置PDM中的DAC增益,-39dB到7.5dB,步长1.5dB,真实为32档。 更多...
 
void pdm_dac_enable (void)
 使能PDM中的DAC(-39 – 7 dB) 更多...
 
void pdm_hpout_mute (void)
 
void pdm_hpout_mute_disable (void)
 
void pdm_dac_disable (pdm_cha_sel_t cha, pdm_gate_t EN)
 关闭DAC 更多...
 
void pdm_alc_judge_sel (pdm_alc_judge_t judge)
 ALC判断的信号来自高通滤波器之前,还是之后 更多...
 
void pdm_pga_gain_config_via_reg27_28 (pdm_cha_sel_t cha, uint32_t gain)
 向PDM reg27 reg28寄存器写PGA的增益 更多...
 
void pdm_pga_gain_config_via_reg27_28_db (pdm_cha_sel_t cha, float gain_db)
 
pdm_mic_amplify_t pdm_get_mic_gain (pdm_cha_sel_t cha)
 获取PDM MIC增益的大小 更多...
 
void pdm_set_mic_gain (pdm_cha_sel_t cha, pdm_mic_amplify_t gain)
 向PDM MIC增益控制寄存器写值 更多...
 
void pdm_alc_left_config (pdm_alc_use_config_t *ALC_str)
 PDM ALC配置左通道 更多...
 
void pdm_alc_right_config (pdm_alc_use_config_t *ALC_str)
 PDM ALC配置左通道 更多...
 
static void pdm_alc_init_config (void)
 ALC的默认配置 更多...
 
static void pdm_adc_init_config (void)
 
static void pdm_aux_alc_init_config (void)
 
int pdm_init (void)
 
void pdm_left_mic_reinit (void)
 
void pdm_right_mic_reinit (void)
 

详细描述

CI130X inner pdm的驱动函数

版本
0.1
日期
2019-03-29

宏定义说明

◆ ALC_AGC_FUNC_SEL

#define ALC_AGC_FUNC_SEL   ENABLE

◆ ALC_ATTACK_TIME

#define ALC_ATTACK_TIME   PDM_ALC_ATTACK_TIME_2MS

◆ ALC_CONTROL_PGA_L

#define ALC_CONTROL_PGA_L   (PDM_GATE_ENABLE)

◆ ALC_CONTROL_PGA_R

#define ALC_CONTROL_PGA_R   (PDM_GATE_ENABLE)

◆ ALC_DECAY_TIME

#define ALC_DECAY_TIME   PDM_ALC_DECAY_TIME_2MS

◆ ALC_FAST_DECAY_87_5

#define ALC_FAST_DECAY_87_5   PDM_GATE_DISABLE

◆ ALC_HOGH_8_BIT_MAX_LEVEL

#define ALC_HOGH_8_BIT_MAX_LEVEL   ((uint8_t)(PDM_ALC_LEVEL__6dB >> 8))

◆ ALC_HOGH_8_BIT_MIN_LEVEL

#define ALC_HOGH_8_BIT_MIN_LEVEL   ((uint8_t)(PDM_ALC_LEVEL__7_5dB >> 8))

◆ ALC_HOLD_TIME

#define ALC_HOLD_TIME   PDM_ALC_HOLD_TIME_2MS

◆ ALC_INIT_PGA_GAIN

#define ALC_INIT_PGA_GAIN   0x1f

◆ ALC_JACK_WAY

#define ALC_JACK_WAY   PDM_ALC_MODE_JACKWAY2

◆ ALC_JUDGE

#define ALC_JUDGE   (PDM_ALC_JUDGE_AFTER_HIGHPASS)

◆ ALC_LOW_8_BIT_MAX_LEVEL

#define ALC_LOW_8_BIT_MAX_LEVEL   ((uint8_t)(PDM_ALC_LEVEL__6dB >> 0))

◆ ALC_LOW_8_BIT_MIN_LEVEL

#define ALC_LOW_8_BIT_MIN_LEVEL   ((uint8_t)(PDM_ALC_LEVEL__7_5dB >> 0))

◆ ALC_MODE

#define ALC_MODE   0

◆ ALC_NOISE_GATE

#define ALC_NOISE_GATE   PDM_GATE_DISABLE

◆ ALC_NOISE_GATE_SET

#define ALC_NOISE_GATE_SET   PDM_NOISE_GATE_THRE_45dB

◆ ALC_PGA_MAX_GAIN

#define ALC_PGA_MAX_GAIN   PDM_ALC_PGA_MAX_GAIN_28_5dB

◆ ALC_PGA_MIN_GAIN

#define ALC_PGA_MIN_GAIN   PDM_ALC_PGA_MIN_GAIN__18dB

◆ ALC_SAMPLE_RATE

#define ALC_SAMPLE_RATE   PDM_SAMPLERATE_16K

◆ ALC_ZERO_CROSS

#define ALC_ZERO_CROSS   PDM_GATE_DISABLE

◆ HPF_CONFIG

#define HPF_CONFIG   (PDM_HIGHPASS_CUT_OFF_20HZ)

◆ HPF_GATE

#define HPF_GATE   (!PDM_GATE_ENABLE)

◆ METHOD_TO_CONTROL_GAIN_ATTACK

#define METHOD_TO_CONTROL_GAIN_ATTACK   0

◆ PDMC_CI_ASSERT

#define PDMC_CI_ASSERT (   x,
  msg 
)
值:
if( ( x ) == 0 ) \
{ \
mprintf("%s",msg); \
mprintf("PDMC Line:%d\n",__LINE__); \
while(1) asm volatile ("ebreak"); \
}

◆ USE_CI130X_OWN_ALC

#define USE_CI130X_OWN_ALC   1

函数说明

◆ pdm_adc_dig_gain_set()

void pdm_adc_dig_gain_set ( pdm_cha_sel_t  cha,
int32_t  gain 
)

调节CODEC ADC的数字增益(197为0dB,加减1为加减0.5dB增益)

参数
gain左声道增益大小

◆ pdm_adc_init_config()

static void pdm_adc_init_config ( void  )
static

◆ pdm_alc_init_config()

static void pdm_alc_init_config ( void  )
static

ALC的默认配置

◆ pdm_aux_alc_init_config()

static void pdm_aux_alc_init_config ( void  )
static

◆ pdm_init()

int pdm_init ( void  )