CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
ci130x_pdm.h
浏览该文件的文档.
1 
10 #ifndef __PDM_H
11 #define __PDM_H
12 
13 #include "ci130x_system.h"
14 #include "ci_log.h"
15 #include <stdbool.h>
16 #include <math.h>
17 
18 
19 #define USE_CI110X_ALC 0
20 
21 #ifdef __cplusplus
22  extern "C" {
23 #endif
24 
25 
26 
31 typedef enum
32 {
33  PDM_CURRENT_I = 0x80,
41 
43 
44 
49 typedef enum
50 {
60 
61 
66 typedef enum
67 {
73 
74 
79 typedef enum
80 {
90 
91 
96 typedef enum
97 {
103 
104 
105 
118 typedef enum
119 {
124 }pdm_mode_t;
125 
126 
131 typedef enum
132 {
138 
139 
144 typedef enum
145 {
155 
156 
161 typedef enum
162 {
172 
173 
178 typedef enum
179 {
185 
186 
191 typedef enum
192 {
202 
203 
208 typedef enum
209 {
227 
228 
233 typedef enum
234 {
258 
259 
264 typedef enum
265 {
289 
290 
295 typedef enum
296 {
320 
321 
326 typedef enum
327 {
337 
338 
343 typedef enum
344 {
349 }pdm_gate_t;
350 
351 
352 
357 typedef enum
358 {
376 
377 
378 
383 typedef enum
384 {
402 
403 
404 typedef enum
405 {
447 
448 
453 typedef struct
454 {
464  float pga_gain_l;
466  float pga_gain_r;
468 
469 
474 typedef struct
475 {
491  float pga_gain;
497 
498 
499 
504 typedef enum
505 {
515 
516 
521 typedef struct
522 {
552  uint16_t digt_gain;
554 
555 
560 typedef enum
561 {
567 
568 
569 void pdm_reset(void);
570 void pdm_power_up(pdm_current_t current);
571 void pdm_power_off(void);
573 void pdm_adc_enable(pdm_adc_config_t *ADC_Config);
575 void pdm_dac_enable(void);
577 void pdm_alc_disable(pdm_cha_sel_t cha,float ALC_Gain);
579  pdm_valid_word_len_t word_len,pdm_i2s_data_famat_t data_fram);
581  pdm_valid_word_len_t word_len,pdm_i2s_data_famat_t data_fram);
582 void pdm_dac_gain_set(int32_t l_gain, int32_t r_gain);
591 void pdm_pga_gain_config_via_reg27_28(pdm_cha_sel_t cha,uint32_t gain);
596 void pdm_adc_dig_gain_set_left(uint8_t gain);
597 void pdm_adc_dig_gain_set_right(uint8_t gain);
602 uint8_t pdm_get_alc_gain_left(void);
603 uint8_t pdm_get_alc_gain_right(void);
604 void pdm_pga_gain_config_via_reg43_53(pdm_cha_sel_t cha,uint32_t gain);
605 void pdm_pga_gain_config_via_reg43_53_db(pdm_cha_sel_t cha,float gain_db);
606 void pdm_pga_gain_config_via_reg27_28_db(pdm_cha_sel_t cha,float gain_db);
607 void pdm_hpout_mute(void);
608 void pdm_hpout_mute_disable(void);
609 void pdm_set_sample_rate(pdm_samplerate_t samplerate);
610 
611 
612 void pdm_left_mic_reinit(void);
613 void pdm_right_mic_reinit(void);
619 #ifdef __cplusplus
620 }
621 #endif
622 
623 #endif
624 /***************** (C) COPYRIGHT Chipintelli Technology Co., Ltd. *****END OF FILE****/
625 
sdklog输出组件 这个文件用于定义sdk日志打印组件,log打印等级 参考Andriod Logcat 提供了多个打印函数, ...
ALC decay time 8ms
Definition: ci130x_pdm.h:275
Definition: ci130x_pdm.h:441
ALC hold time 512ms
Definition: ci130x_pdm.h:254
Definition: ci130x_pdm.h:434
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的模式选择
Definition: ci130x_pdm.c:94
Definition: ci130x_pdm.h:429
pdm_alc_hold_time_t
PDM ALC hold time设置
Definition: ci130x_pdm.h:233
pdm_input_mode_t codec_adc_input_mode_r
ADC R 输入模式选择
Definition: ci130x_pdm.h:458
ALC设置PGA的增益下限为-12dB
Definition: ci130x_pdm.h:388
Definition: ci130x_pdm.h:422
void pdm_alc_judge_sel(pdm_alc_judge_t judge)
ALC判断的信号来自高通滤波器之前,还是之后
Definition: ci130x_pdm.c:459
pdm_alc_pga_max_gain_t max_pga_gain
ALC设置PGA的上限设置
Definition: ci130x_pdm.h:483
Definition: ci130x_pdm.h:39
ALC decay time 500us
Definition: ci130x_pdm.h:267
inner codec的数据格式为右对齐格式
Definition: ci130x_pdm.h:170
pdm_alc_attack_time_t
PDM ALC attack time设置
Definition: ci130x_pdm.h:295
ALC attack time 125us
Definition: ci130x_pdm.h:298
pdm_alc_pga_min_gain_t alc_mingain
ALC设置PGA增益下限设置
Definition: ci130x_pdm.h:526
采样率为96K
Definition: ci130x_pdm.h:211
pdm_noise_gate_threshold_t
PDM ALC noise gate门限
Definition: ci130x_pdm.h:326
Definition: ci130x_pdm.h:430
采样率为12K
Definition: ci130x_pdm.h:223
Definition: ci130x_pdm.h:443
ALC设置PGA的增益上限为-13.5dB
Definition: ci130x_pdm.h:360
ALC噪声门限57dB
Definition: ci130x_pdm.h:335
ALC设置PGA的增益下限为6dB
Definition: ci130x_pdm.h:394
pdm_frame_1_2len_t
PDM数据窗口的宽度
Definition: ci130x_pdm.h:131
PDM简易版ALC配置
Definition: ci130x_pdm.h:521
Definition: ci130x_pdm.h:421
ALC右通道
Definition: ci130x_pdm.h:509
Definition: ci130x_pdm.h:409
ALC两个通道
Definition: ci130x_pdm.h:511
Definition: ci130x_pdm.h:35
pdm_samplerate_t samplerate
ALC采样率设置
Definition: ci130x_pdm.h:487
pdm_alc_mode_t
PDM ALC模式设置
Definition: ci130x_pdm.h:79
ALC设置PGA的增益上限为28.5dB
Definition: ci130x_pdm.h:374
void pdm_set_input_mode_right(pdm_input_mode_t mode)
设置右通道的输入模式
Definition: ci130x_pdm.c:179
pdm_mode_t
PDM 主从模式设置
Definition: ci130x_pdm.h:118
void pdm_alc_disable(pdm_cha_sel_t cha, float ALC_Gain)
void pdm_zero_cross_set(pdm_cha_sel_t cha, pdm_gate_t gate)
pdm_mic_amplify_t pdm_get_mic_gain(pdm_cha_sel_t cha)
获取PDM MIC增益的大小
Definition: ci130x_pdm.c:518
pdm_alc_level_t min_level
ALC min level设置
Definition: ci130x_pdm.h:495
ALC decay time 2ms
Definition: ci130x_pdm.h:271
ALC设置PGA的增益上限为22.5dB
Definition: ci130x_pdm.h:372
ALC的判断信号来自高通滤波器之前(同时也是数字增益之前)
Definition: ci130x_pdm.h:69
ALC hold time 2ms
Definition: ci130x_pdm.h:238
Definition: ci130x_pdm.h:424
输入为单端输入模式
Definition: ci130x_pdm.h:183
pdm_alc_attack_time_t attacktime
ALC attack time设置
Definition: ci130x_pdm.h:481
pdm_alc_hold_time_t hold_time
ALC hold time设置
Definition: ci130x_pdm.h:542
ALC decay time 4ms
Definition: ci130x_pdm.h:273
ALC左通道
Definition: ci130x_pdm.h:507
pdm_input_mode_t
PDM MIC输入端查分或者单端模式设置
Definition: ci130x_pdm.h:178
pdm_alc_decay_time_t
PDM ALC decay time配置
Definition: ci130x_pdm.h:264
CODEC ALC左通道
Definition: ci130x_pdm.h:563
有效数据宽度为20bit
Definition: ci130x_pdm.h:151
pdm_gate_t zero_cross
过零检测开关
Definition: ci130x_pdm.h:548
void pdm_dac_gain_set(int32_t l_gain, int32_t r_gain)
配置PDM中的DAC增益,-39dB到7.5dB,步长1.5dB,真实为32档。
Definition: ci130x_pdm.c:342
void pdm_hpout_mute(void)
Definition: ci130x_pdm.c:399
void pdm_alc_left_config(pdm_alc_use_config_t *ALC_str)
PDM ALC配置左通道
Definition: ci130x_pdm.c:577
void pdm_alc_right_config(pdm_alc_use_config_t *ALC_str)
PDM ALC配置左通道
Definition: ci130x_pdm.c:681
void pdm_power_up(pdm_current_t current)
PDM模块上电
Definition: ci130x_pdm.c:116
ALC decay time 32ms
Definition: ci130x_pdm.h:279
void pdm_pga_gain_config_via_reg43_53(pdm_cha_sel_t cha, uint32_t gain)
使用ALC控制PGA增益
Definition: ci130x_pdm.h:101
ALC attack time 128ms
Definition: ci130x_pdm.h:318
pdm_gate_t noise_gate
noise gate 开关
Definition: ci130x_pdm.h:544
ALC attack time 500us
Definition: ci130x_pdm.h:302
Definition: ci130x_pdm.h:36
Definition: ci130x_pdm.h:445
pdm_alc_level_t max_level
ALC max level设置
Definition: ci130x_pdm.h:493
ALC attack time 4ms
Definition: ci130x_pdm.h:308
PDM高通滤波器截止频率设置为20Hz
Definition: ci130x_pdm.h:52
ALC attack time 32ms
Definition: ci130x_pdm.h:314
Definition: ci130x_pdm.h:437
Definition: ci130x_pdm.h:438
pdm_gate_t
PDM全局开关
Definition: ci130x_pdm.h:343
Definition: ci130x_pdm.h:433
pdm_input_mode_t codec_adc_input_mode_l
ADC L 输入模式选择
Definition: ci130x_pdm.h:456
pdm_alc_pga_max_gain_t
PDM ALC 最大增益设置
Definition: ci130x_pdm.h:357
Definition: ci130x_pdm.h:412
Definition: ci130x_pdm.h:417
Definition: ci130x_pdm.h:423
pdm_mic_amplify_t codec_adc_mic_amp_r
MIC R 增益设置
Definition: ci130x_pdm.h:462
数据窗口宽度为32bit
Definition: ci130x_pdm.h:134
ALC 模式为jackway1
Definition: ci130x_pdm.h:84
PDM ADC配置
Definition: ci130x_pdm.h:453
pdm_valid_word_len_t
PDM有效数据宽度
Definition: ci130x_pdm.h:144
pdm_alc_attack_time_t attack_time
ALC attack time设置
Definition: ci130x_pdm.h:538
Definition: ci130x_pdm.h:439
pdm_gate_t alc_gate
ALC开关
Definition: ci130x_pdm.h:536
Definition: ci130x_pdm.h:415
pdm_noise_gate_threshold_t noise_gate_threshold
噪声门限阈值
Definition: ci130x_pdm.h:550
Definition: ci130x_pdm.h:410
MIC增益为20dB
Definition: ci130x_pdm.h:200
void pdm_right_alc_pro_mode_config(pdm_alc_config_t *ALC_Type)
采样率为24K
Definition: ci130x_pdm.h:219
pdm_alc_pga_min_gain_t min_pga_gain
ALC设置PGA的下限设置
Definition: ci130x_pdm.h:485
void pdm_set_sample_rate(pdm_samplerate_t samplerate)
void pdm_pga_gain_config_via_reg43_53_db(pdm_cha_sel_t cha, float gain_db)
Definition: ci130x_pdm.h:431
Definition: ci130x_pdm.h:407
Definition: ci130x_pdm.h:408
pdm_mic_amplify_t codec_adc_mic_amp_l
MIC L 增益设置
Definition: ci130x_pdm.h:460
MIC增益为6dB
Definition: ci130x_pdm.h:196
pdm_alc_cha_sel_t
PDM ALC通道选择
Definition: ci130x_pdm.h:504
Definition: ci130x_pdm.h:419
ALC normal模式
Definition: ci130x_pdm.h:82
MIC增益为0dB
Definition: ci130x_pdm.h:194
CODEC ALC右通道
Definition: ci130x_pdm.h:565
Definition: ci130x_pdm.h:406
pdm_alc_judge_t
PDM ALC判断信号选择
Definition: ci130x_pdm.h:66
ALC attack time 16ms
Definition: ci130x_pdm.h:312
采样率为44.1K
Definition: ci130x_pdm.h:215
ALC decay time 512ms
Definition: ci130x_pdm.h:287
采样率为16K
Definition: ci130x_pdm.h:221
Definition: ci130x_pdm.h:427
Definition: ci130x_pdm.h:426
void pdm_pga_gain_config_via_reg27_28_db(pdm_cha_sel_t cha, float gain_db)
Definition: ci130x_pdm.c:496
PDM高通滤波器截止频率设置为245Hz
Definition: ci130x_pdm.h:54
inner codec的数据格式为左对齐格式,slave模式下不支持
Definition: ci130x_pdm.h:168
ALC decay time 64ms
Definition: ci130x_pdm.h:281
Definition: ci130x_pdm.h:418
Definition: ci130x_pdm.h:33
ALC attack time 64ms
Definition: ci130x_pdm.h:316
数据窗口宽度为24bit
Definition: ci130x_pdm.h:136
void pdm_set_mic_gain_left(pdm_mic_amplify_t gain)
设置左通道的MIC增益
Definition: ci130x_pdm.c:191
Definition: ci130x_pdm.h:432
pdm_mic_amplify_t
PDM MIC增益配置
Definition: ci130x_pdm.h:191
ALC hold time 8ms
Definition: ci130x_pdm.h:242
ALC关闭
Definition: ci130x_pdm.h:513
ALC hold time 1024ms
Definition: ci130x_pdm.h:256
Definition: ci130x_pdm.h:416
uint8_t pdm_get_alc_gain_left(void)
void pdm_left_alc_enable(pdm_gate_t gate, pdm_use_alc_control_pgagain_t is_alc_ctr_pga)
ALC设置PGA的增益下限为0dB
Definition: ci130x_pdm.h:392
void pdm_set_mic_gain(pdm_cha_sel_t cha, pdm_mic_amplify_t gain)
向PDM MIC增益控制寄存器写值
Definition: ci130x_pdm.c:547
void pdm_adc_dig_gain_set_left(uint8_t gain)
pdm_current_t
PDM预充电电流
Definition: ci130x_pdm.h:31
ALC设置PGA的增益上限为4.5dB
Definition: ci130x_pdm.h:366
PDM高通滤波器截止频率设置为612Hz
Definition: ci130x_pdm.h:56
void pdm_left_alc_pro_mode_config(pdm_alc_config_t *ALC_Type)
pdm_alc_pga_min_gain_t
PDM ALC 最小增益设置
Definition: ci130x_pdm.h:383
void pdm_power_off(void)
关闭PDM模块电源
Definition: ci130x_pdm.c:132
ALC hold time 4ms
Definition: ci130x_pdm.h:240
ALC attack time 250us
Definition: ci130x_pdm.h:300
void pdm_reset(void)
当主频为168时,延时100us
Definition: ci130x_pdm.c:53
Definition: ci130x_pdm.h:444
pdm_alc_decay_time_t decaytime
ALC decay time设置
Definition: ci130x_pdm.h:479
ALC设置PGA的增益下限为-6dB
Definition: ci130x_pdm.h:390
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。
Definition: ci130x_pdm.c:219
ALC设置PGA的增益上限为16.5dB
Definition: ci130x_pdm.h:370
Definition: ci130x_pdm.h:34
采样率为48K
Definition: ci130x_pdm.h:213
Definition: ci130x_pdm.h:40
pdm_alc_decay_time_t decay_time
ALC decay time设置
Definition: ci130x_pdm.h:540
chip级定义
ALC设置PGA的增益下限为18dB
Definition: ci130x_pdm.h:398
Definition: ci130x_pdm.h:436
ALC hold time 32ms
Definition: ci130x_pdm.h:246
ALC噪声门限39dB
Definition: ci130x_pdm.h:329
ALC hold time 0
Definition: ci130x_pdm.h:236
pdm_use_alc_control_pgagain_t
PDM使用或者不适用PDM本身的ALC控制其模拟PGA的增益
Definition: ci130x_pdm.h:96
pdm_samplerate_t
PDM采样率设置
Definition: ci130x_pdm.h:208
ALC attack time 1ms
Definition: ci130x_pdm.h:304
Definition: ci130x_pdm.h:38
有效数据宽度为32bit
Definition: ci130x_pdm.h:147
ALC设置PGA的增益下限为24dB
Definition: ci130x_pdm.h:400
pdm_alc_level_t
Definition: ci130x_pdm.h:404
ALC 模式为jackway2
Definition: ci130x_pdm.h:86
Definition: ci130x_pdm.h:425
ALC decay time 16ms
Definition: ci130x_pdm.h:277
float pga_gain_r
不使能ALC的情况下,PGA R 的固定增益
Definition: ci130x_pdm.h:466
uint8_t pdm_get_alc_gain_right(void)
ALC设置PGA的增益上限为-1.5dB
Definition: ci130x_pdm.h:364
有效数据宽度为16bit
Definition: ci130x_pdm.h:153
ALC噪声门限45dB
Definition: ci130x_pdm.h:331
pdm_gate_t fast_decrece_87_5
过顶保护开关
Definition: ci130x_pdm.h:546
pdm_alc_pga_max_gain_t alc_maxgain
ALC设置PGA增益上限设置
Definition: ci130x_pdm.h:524
PDM主模式
Definition: ci130x_pdm.h:121
void pdm_set_mic_gain_right(pdm_mic_amplify_t gain)
设置右通道的MIC增益
Definition: ci130x_pdm.c:204
void pdm_right_alc_enable(pdm_gate_t gate, pdm_use_alc_control_pgagain_t is_alc_ctr_pga)
Definition: ci130x_pdm.h:435
ALC设置PGA的增益上限为-7.5dB
Definition: ci130x_pdm.h:362
PDM高通滤波器截止频率设置为1Hz
Definition: ci130x_pdm.h:58
Definition: ci130x_pdm.h:37
ALC噪声门限51dB
Definition: ci130x_pdm.h:333
pdm_samplerate_t sample_rate
ALC ALC的采样率设置
Definition: ci130x_pdm.h:532
pdm_cha_sel_t
inner CODEC通道设置
Definition: ci130x_pdm.h:560
inner codec的数据格式为标准I2S格式
Definition: ci130x_pdm.h:166
打开PDM
Definition: ci130x_pdm.h:346
关闭PDM
Definition: ci130x_pdm.h:348
PDM ALC设置结构体类型
Definition: ci130x_pdm.h:474
输入为差分输入模式
Definition: ci130x_pdm.h:181
void pdm_87_5_fast_decrement_set(pdm_cha_sel_t cha, pdm_gate_t gate)
ALC hold time 128ms
Definition: ci130x_pdm.h:250
Definition: ci130x_pdm.h:428
void pdm_noise_gate_set(pdm_cha_sel_t cha, pdm_noise_gate_threshold_t Threshold, pdm_gate_t gate)
采样率为8K
Definition: ci130x_pdm.h:225
Definition: ci130x_pdm.h:440
uint16_t digt_gain
基本的数字增益
Definition: ci130x_pdm.h:552
ALC设置PGA的增益下限为-18dB
Definition: ci130x_pdm.h:386
void pdm_hightpass_config(pdm_gate_t gate, pdm_highpass_cut_off_t Hz)
配置PDM模块的高通滤波器
Definition: ci130x_pdm.c:147
Definition: ci130x_pdm.h:411
void pdm_pga_gain_config_via_reg27_28(pdm_cha_sel_t cha, uint32_t gain)
向PDM reg27 reg28寄存器写PGA的增益
Definition: ci130x_pdm.c:474
pdm_alc_mode_t alcmode
ALC模式设置
Definition: ci130x_pdm.h:489
ALC decay time 1ms
Definition: ci130x_pdm.h:269
Definition: ci130x_pdm.h:420
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的模式选择
Definition: ci130x_pdm.c:69
ALC attack time 2ms
Definition: ci130x_pdm.h:306
void pdm_dac_disable(pdm_cha_sel_t cha, pdm_gate_t EN)
关闭DAC
Definition: ci130x_pdm.c:421
pdm_alc_hold_time_t holdtime
ALC hold time设置
Definition: ci130x_pdm.h:477
ALC设置PGA的增益上限为10.5dB
Definition: ci130x_pdm.h:368
void pdm_set_input_mode_left(pdm_input_mode_t mode)
设置左通道的输入模式
Definition: ci130x_pdm.c:167
采样率为32K
Definition: ci130x_pdm.h:217
Definition: ci130x_pdm.h:442
MIC增益为13dB
Definition: ci130x_pdm.h:198
inner codec的数据格式为PCM格式
Definition: ci130x_pdm.h:164
Definition: ci130x_pdm.h:413
void pdm_adc_disable(pdm_cha_sel_t cha, pdm_gate_t EN)
关闭PDM中的ADC
Definition: ci130x_pdm.c:305
ALC的判断信号来自高通滤波器之后(同时也是数字增益之后)
Definition: ci130x_pdm.h:71
ALC hold time 256ms
Definition: ci130x_pdm.h:252
void pdm_hpout_mute_disable(void)
Definition: ci130x_pdm.c:407
void pdm_left_mic_reinit(void)
Definition: ci130x_pdm.c:929
ALC设置PGA的增益下限为12dB
Definition: ci130x_pdm.h:396
void pdm_dac_enable(void)
使能PDM中的DAC(-39 – 7 dB)
Definition: ci130x_pdm.c:379
void pdm_right_mic_reinit(void)
Definition: ci130x_pdm.c:940
PDM从模式
Definition: ci130x_pdm.h:123
pdm_highpass_cut_off_t
PDM高通滤波器截止频率设置
Definition: ci130x_pdm.h:49
float pga_gain_l
不使能ALC的情况下,PGA L 的固定增益
Definition: ci130x_pdm.h:464
ALC hold time 16ms
Definition: ci130x_pdm.h:244
pdm_gate_t use_ci130x_alc
使用CI130X的ALC控制PDM还是使用其本身的ALC控制
Definition: ci130x_pdm.h:534
Definition: ci130x_pdm.h:414
ALC hold time 64ms
Definition: ci130x_pdm.h:248
ALC 模式为jackway3
Definition: ci130x_pdm.h:88
void pdm_adc_dig_gain_set_right(uint8_t gain)
ALC decay time 256ms
Definition: ci130x_pdm.h:285
有效数据宽度为24bit
Definition: ci130x_pdm.h:149
ALC attack time 8ms
Definition: ci130x_pdm.h:310
float pga_gain
不使能ALC的情况下,PGA的增益设置
Definition: ci130x_pdm.h:491
不使用ALC控制PGA增益
Definition: ci130x_pdm.h:99
pdm_i2s_data_famat_t
PDM数据格式
Definition: ci130x_pdm.h:161
ALC decay time 128ms
Definition: ci130x_pdm.h:283