CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
结构体 | 宏定义 | 枚举 | 函数
ci130x_pdm.h 文件参考
#include "ci130x_system.h"
#include "ci_log.h"
#include <stdbool.h>
#include <math.h>

浏览源代码.

结构体

struct  pdm_adc_config_t
 PDM ADC配置 更多...
 
struct  pdm_alc_config_t
 PDM ALC设置结构体类型 更多...
 
struct  pdm_alc_use_config_t
 PDM简易版ALC配置 更多...
 

宏定义

#define USE_CI110X_ALC   0
 

枚举

enum  pdm_current_t {
  PDM_CURRENT_I = 0x80,
  PDM_CURRENT_2I = 0x40,
  PDM_CURRENT_4I = 0x20,
  PDM_CURRENT_8I = 0x10,
  PDM_CURRENT_16I = 0x08,
  PDM_CURRENT_32I = 0x04,
  PDM_CURRENT_64I = 0x02,
  PDM_CURRENT_128I = 0x01
}
 PDM预充电电流 更多...
 
enum  pdm_highpass_cut_off_t {
  PDM_HIGHPASS_CUT_OFF_20HZ = 0,
  PDM_HIGHPASS_CUT_OFF_245HZ = 1,
  PDM_HIGHPASS_CUT_OFF_612HZ = 2,
  PDM_HIGHPASS_CUT_OFF_1HZ = 3
}
 PDM高通滤波器截止频率设置 更多...
 
enum  pdm_alc_judge_t {
  PDM_ALC_JUDGE_BEFOR_HIGHPASS = 0,
  PDM_ALC_JUDGE_AFTER_HIGHPASS = 1
}
 PDM ALC判断信号选择 更多...
 
enum  pdm_alc_mode_t {
  PDM_ALC_MODE_NORMAL = 0,
  PDM_ALC_MODE_JACKWAY1 = 1,
  PDM_ALC_MODE_JACKWAY2 = 2,
  PDM_ALC_MODE_JACKWAY3 = 3
}
 PDM ALC模式设置 更多...
 
enum  pdm_use_alc_control_pgagain_t {
  PDM_WONT_USE_ALC_CONTROL_PGA_GAIN = 0,
  PDM_USE_ALC_CONTROL_PGA_GAIN
}
 PDM使用或者不适用PDM本身的ALC控制其模拟PGA的增益 更多...
 
enum  pdm_mode_t {
  PDM_MODE_MASTER = 3,
  PDM_MODE_SLAVE = 0
}
 PDM 主从模式设置 更多...
 
enum  pdm_frame_1_2len_t {
  PDM_FRAME_LEN_32BIT = 3,
  PDM_FRAME_LEN_24BIT = 2
}
 PDM数据窗口的宽度 更多...
 
enum  pdm_valid_word_len_t {
  PDM_VALID_LEN_32BIT = 3,
  PDM_VALID_LEN_24BIT = 2,
  PDM_VALID_LEN_20BIT = 1,
  PDM_VALID_LEN_16BIT = 0
}
 PDM有效数据宽度 更多...
 
enum  pdm_i2s_data_famat_t {
  PDM_I2S_DATA_FORMAT_PCM_MODE = 3,
  PDM_I2S_DATA_FORMAT_I2S_MODE = 2,
  PDM_I2S_DATA_FORMAT_LJ_MODE = 1,
  PDM_I2S_DATA_FORMAT_RJ_MODE = 0
}
 PDM数据格式 更多...
 
enum  pdm_input_mode_t {
  PDM_INPUT_MODE_DIFF = 1,
  PDM_INPUT_MODE_SINGGLE_ENDED = 2
}
 PDM MIC输入端查分或者单端模式设置 更多...
 
enum  pdm_mic_amplify_t {
  PDM_MIC_AMP_0dB = 0,
  PDM_MIC_AMP_6dB = 1,
  PDM_MIC_AMP_13dB = 2,
  PDM_MIC_AMP_20dB = 3
}
 PDM MIC增益配置 更多...
 
enum  pdm_samplerate_t {
  PDM_SAMPLERATE_96K = 0,
  PDM_SAMPLERATE_48K = 1,
  PDM_SAMPLERATE_44_1K = 2,
  PDM_SAMPLERATE_32K = 3,
  PDM_SAMPLERATE_24K = 4,
  PDM_SAMPLERATE_16K = 5,
  PDM_SAMPLERATE_12K = 6,
  PDM_SAMPLERATE_8K = 7
}
 PDM采样率设置 更多...
 
enum  pdm_alc_hold_time_t {
  PDM_ALC_HOLD_TIME_0MS = 0,
  PDM_ALC_HOLD_TIME_2MS = 1,
  PDM_ALC_HOLD_TIME_4MS = 2,
  PDM_ALC_HOLD_TIME_8MS = 3,
  PDM_ALC_HOLD_TIME_16MS = 4,
  PDM_ALC_HOLD_TIME_32MS = 5,
  PDM_ALC_HOLD_TIME_64MS = 6,
  PDM_ALC_HOLD_TIME_128MS = 7,
  PDM_ALC_HOLD_TIME_256MS = 8,
  PDM_ALC_HOLD_TIME_512MS = 9,
  PDM_ALC_HOLD_TIME_1024mS = 10
}
 PDM ALC hold time设置 更多...
 
enum  pdm_alc_decay_time_t {
  PDM_ALC_DECAY_TIME_500US = 0,
  PDM_ALC_DECAY_TIME_1MS = 1,
  PDM_ALC_DECAY_TIME_2MS = 2,
  PDM_ALC_DECAY_TIME_4MS = 3,
  PDM_ALC_DECAY_TIME_8MS = 4,
  PDM_ALC_DECAY_TIME_16MS = 5,
  PDM_ALC_DECAY_TIME_32MS = 6,
  PDM_ALC_DECAY_TIME_64MS = 7,
  PDM_ALC_DECAY_TIME_128MS = 8,
  PDM_ALC_DECAY_TIME_256MS = 9,
  PDM_ALC_DECAY_TIME_512MS = 10
}
 PDM ALC decay time配置 更多...
 
enum  pdm_alc_attack_time_t {
  PDM_ALC_ATTACK_TIME_125US = 0,
  PDM_ALC_ATTACK_TIME_250US = 1,
  PDM_ALC_ATTACK_TIME_500US = 2,
  PDM_ALC_ATTACK_TIME_1MS = 3,
  PDM_ALC_ATTACK_TIME_2MS = 4,
  PDM_ALC_ATTACK_TIME_4MS = 5,
  PDM_ALC_ATTACK_TIME_8MS = 6,
  PDM_ALC_ATTACK_TIME_16MS = 7,
  PDM_ALC_ATTACK_TIME_32MS = 8,
  PDM_ALC_ATTACK_TIME_64MS = 9,
  PDM_ALC_ATTACK_TIME_128MS = 10
}
 PDM ALC attack time设置 更多...
 
enum  pdm_noise_gate_threshold_t {
  PDM_NOISE_GATE_THRE_39dB = 0,
  PDM_NOISE_GATE_THRE_45dB = 1,
  PDM_NOISE_GATE_THRE_51dB = 2,
  PDM_NOISE_GATE_THRE_57dB = 3
}
 PDM ALC noise gate门限 更多...
 
enum  pdm_gate_t {
  PDM_GATE_ENABLE = 1,
  PDM_GATE_DISABLE = 0
}
 PDM全局开关 更多...
 
enum  pdm_alc_pga_max_gain_t {
  PDM_ALC_PGA_MAX_GAIN__13_5dB = 0,
  PDM_ALC_PGA_MAX_GAIN__7_5dB = 1,
  PDM_ALC_PGA_MAX_GAIN__1_5dB = 2,
  PDM_ALC_PGA_MAX_GAIN_4_5dB = 3,
  PDM_ALC_PGA_MAX_GAIN_10_5dB = 4,
  PDM_ALC_PGA_MAX_GAIN_16_5dB = 5,
  PDM_ALC_PGA_MAX_GAIN_22_5dB = 6,
  PDM_ALC_PGA_MAX_GAIN_28_5dB = 7
}
 PDM ALC 最大增益设置 更多...
 
enum  pdm_alc_pga_min_gain_t {
  PDM_ALC_PGA_MIN_GAIN__18dB = 0,
  PDM_ALC_PGA_MIN_GAIN__12dB = 1,
  PDM_ALC_PGA_MIN_GAIN__6dB = 2,
  PDM_ALC_PGA_MIN_GAIN_0dB = 3,
  PDM_ALC_PGA_MIN_GAIN_6dB = 4,
  PDM_ALC_PGA_MIN_GAIN_12dB = 5,
  PDM_ALC_PGA_MIN_GAIN_18dB = 6,
  PDM_ALC_PGA_MIN_GAIN_24dB = 7
}
 PDM ALC 最小增益设置 更多...
 
enum  pdm_alc_level_t {
  PDM_ALC_LEVEL_0dB = 0x7fff,
  PDM_ALC_LEVEL__0_5dB = 0x78d6,
  PDM_ALC_LEVEL__1dB = 0x7213,
  PDM_ALC_LEVEL__1_5dB = 0x6bb1,
  PDM_ALC_LEVEL__2dB = 0x65ab,
  PDM_ALC_LEVEL__2_5dB = 0x5ffb,
  PDM_ALC_LEVEL__3dB = 0x5a9d,
  PDM_ALC_LEVEL__3_5dB = 0x558b,
  PDM_ALC_LEVEL__4dB = 0x50c2,
  PDM_ALC_LEVEL__4_5dB = 0x4c3e,
  PDM_ALC_LEVEL__5dB = 0x47fa,
  PDM_ALC_LEVEL__5_5dB = 0x43f3,
  PDM_ALC_LEVEL__6dB = 0x4026,
  PDM_ALC_LEVEL__6_5dB = 0x3c8f,
  PDM_ALC_LEVEL__7dB = 0x392c,
  PDM_ALC_LEVEL__7_5dB = 0x35f9,
  PDM_ALC_LEVEL__8dB = 0x32f4,
  PDM_ALC_LEVEL__8_5dB = 0x301b,
  PDM_ALC_LEVEL__9dB = 0x2d6a,
  PDM_ALC_LEVEL__9_5dB = 0x2adf,
  PDM_ALC_LEVEL__10dB = 0x2879,
  PDM_ALC_LEVEL__10_5dB = 0x2636,
  PDM_ALC_LEVEL__11dB = 0x2412,
  PDM_ALC_LEVEL__11_5dB = 0x220e,
  PDM_ALC_LEVEL__12dB = 0x2026,
  PDM_ALC_LEVEL__12_5dB = 0x1e5a,
  PDM_ALC_LEVEL__13dB = 0x2026,
  PDM_ALC_LEVEL__13_5dB = 0x1b0d,
  PDM_ALC_LEVEL__14dB = 0x1989,
  PDM_ALC_LEVEL__14_5dB = 0x181c,
  PDM_ALC_LEVEL__15dB = 0x16c2,
  PDM_ALC_LEVEL__15_5dB = 0x157c,
  PDM_ALC_LEVEL__16dB = 0x1449,
  PDM_ALC_LEVEL__16_5dB = 0x1326,
  PDM_ALC_LEVEL__17dB = 0x1214,
  PDM_ALC_LEVEL__17_5dB = 0x1111,
  PDM_ALC_LEVEL__18dB = 0x101d,
  PDM_ALC_LEVEL__18_5dB = 0x0f36,
  PDM_ALC_LEVEL__19dB = 0x0e5c,
  PDM_ALC_LEVEL__19_5dB = 0x0d8e
}
 
enum  pdm_alc_cha_sel_t {
  PDM_ALC_CHA_R_ONLY = 0,
  PDM_ALC_CHA_L_ONLY,
  PDM_ALC_CHA_STEREO_ONLY,
  PDM_ALC_CHA_NONE
}
 PDM ALC通道选择 更多...
 
enum  pdm_cha_sel_t {
  PDM_LEFT_CHA = 0,
  PDM_RIGHT_CHA = 1
}
 inner CODEC通道设置 更多...
 

函数

void pdm_reset (void)
 当主频为168时,延时100us 更多...
 
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_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_disable (pdm_cha_sel_t cha, pdm_gate_t EN)
 关闭PDM中的ADC 更多...
 
void pdm_dac_enable (void)
 使能PDM中的DAC(-39 – 7 dB) 更多...
 
void pdm_dac_disable (pdm_cha_sel_t cha, pdm_gate_t EN)
 关闭DAC 更多...
 
void pdm_alc_disable (pdm_cha_sel_t cha, float ALC_Gain)
 
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_dac_gain_set (int32_t l_gain, int32_t r_gain)
 配置PDM中的DAC增益,-39dB到7.5dB,步长1.5dB,真实为32档。 更多...
 
void pdm_left_alc_pro_mode_config (pdm_alc_config_t *ALC_Type)
 
void pdm_right_alc_pro_mode_config (pdm_alc_config_t *ALC_Type)
 
void pdm_left_alc_enable (pdm_gate_t gate, pdm_use_alc_control_pgagain_t is_alc_ctr_pga)
 
void pdm_right_alc_enable (pdm_gate_t gate, pdm_use_alc_control_pgagain_t is_alc_ctr_pga)
 
void pdm_noise_gate_set (pdm_cha_sel_t cha, pdm_noise_gate_threshold_t Threshold, pdm_gate_t gate)
 
void pdm_zero_cross_set (pdm_cha_sel_t cha, pdm_gate_t gate)
 
void pdm_87_5_fast_decrement_set (pdm_cha_sel_t cha, pdm_gate_t gate)
 
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的增益 更多...
 
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配置左通道 更多...
 
void pdm_adc_dig_gain_set_left (uint8_t gain)
 
void pdm_adc_dig_gain_set_right (uint8_t gain)
 
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增益 更多...
 
uint8_t pdm_get_alc_gain_left (void)
 
uint8_t pdm_get_alc_gain_right (void)
 
void pdm_pga_gain_config_via_reg43_53 (pdm_cha_sel_t cha, uint32_t gain)
 
void pdm_pga_gain_config_via_reg43_53_db (pdm_cha_sel_t cha, float gain_db)
 
void pdm_pga_gain_config_via_reg27_28_db (pdm_cha_sel_t cha, float gain_db)
 
void pdm_hpout_mute (void)
 
void pdm_hpout_mute_disable (void)
 
void pdm_set_sample_rate (pdm_samplerate_t samplerate)
 
void pdm_left_mic_reinit (void)
 
void pdm_right_mic_reinit (void)
 

宏定义说明

◆ USE_CI110X_ALC

#define USE_CI110X_ALC   0

枚举类型说明

◆ pdm_alc_judge_t

PDM ALC判断信号选择

枚举值
PDM_ALC_JUDGE_BEFOR_HIGHPASS 

ALC的判断信号来自高通滤波器之前(同时也是数字增益之前)

PDM_ALC_JUDGE_AFTER_HIGHPASS 

ALC的判断信号来自高通滤波器之后(同时也是数字增益之后)

◆ pdm_alc_mode_t

PDM ALC模式设置

枚举值
PDM_ALC_MODE_NORMAL 

ALC normal模式

PDM_ALC_MODE_JACKWAY1 

ALC 模式为jackway1

PDM_ALC_MODE_JACKWAY2 

ALC 模式为jackway2

PDM_ALC_MODE_JACKWAY3 

ALC 模式为jackway3

◆ pdm_current_t

PDM预充电电流

枚举值
PDM_CURRENT_I 
PDM_CURRENT_2I 
PDM_CURRENT_4I 
PDM_CURRENT_8I 
PDM_CURRENT_16I 
PDM_CURRENT_32I 
PDM_CURRENT_64I 
PDM_CURRENT_128I 

◆ pdm_highpass_cut_off_t

PDM高通滤波器截止频率设置

枚举值
PDM_HIGHPASS_CUT_OFF_20HZ 

PDM高通滤波器截止频率设置为20Hz

PDM_HIGHPASS_CUT_OFF_245HZ 

PDM高通滤波器截止频率设置为245Hz

PDM_HIGHPASS_CUT_OFF_612HZ 

PDM高通滤波器截止频率设置为612Hz

PDM_HIGHPASS_CUT_OFF_1HZ 

PDM高通滤波器截止频率设置为1Hz

◆ pdm_use_alc_control_pgagain_t

PDM使用或者不适用PDM本身的ALC控制其模拟PGA的增益

枚举值
PDM_WONT_USE_ALC_CONTROL_PGA_GAIN 

不使用ALC控制PGA增益

PDM_USE_ALC_CONTROL_PGA_GAIN 

使用ALC控制PGA增益