CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
ci130x_scu.h
浏览该文件的文档.
1 
11 #ifndef CI130X_SCU_H
12 #define CI130X_SCU_H
13 
14 #include "ci130x_system.h"
15 #include "sdk_default_config.h"
16 #include <stdbool.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 // 注意,为了使CODE在多种采样率下都能得到整数倍分频,驱动中会自动对主频做一些调整(+/-4092MHz以内),所以实际运行频率肯能与这里配置的频率有差异。
23 // 准确频率可以通过调用 "dpmu_get_pll_frequency()" 函数获取。
24 
31 #if USE_EXTERNAL_CRYSTAL_OSC
32 #define MAIN_FREQUENCY 240000000
33 #else
34 #define MAIN_FREQUENCY 200000000
35 #endif
36 
37 #define SRC_FREQUENCY_NORMAL 12288000U
43 #define SRC_FREQUENCY_LOWPOWER 12288000U
44 
49 typedef enum
50 {
56 
68 typedef enum
69 {
70  NMI_IRQ_IWGD = 0x1,
71  NMI_IRQ_WWGD = 0x2,
72  NMI_IRQ_EXT0 = 0x3,
73  NMI_IRQ_EXT1 = 0x4,
79  NMI_IRQ_PA = 0xA,
80  NMI_IRQ_PB = 0xB,
81  NMI_IRQ_PC = 0xC,
82  NMI_IRQ_VDT = 0xC,
84  NMI_IRQ_ADC = 0xF,
85 }Nmi_Irq_t;
86 
91 typedef enum
92 {
104  ROM_GATE = 11,
106 
110 typedef enum
111 {
119 
123 typedef enum
124 {
128 
132 typedef enum
133 {
134 /***-----PAD-----****************----analgo--****----1st-----****---2nd-----****----3rd----****----4th----****----5th----****----6th----****/
135  PA0 = 0,
136  PA1 = 1,
141  PA2 = 6,
142  PA3 = 7,
143  PA4 = 8,
144  PA5 = 9,
145  PA6 = 10,
146  PA7 = 11,
147  PB0 = 12,
148  PB1 = 13,
149  PB2 = 14,
150  PB3 = 15,
151  PB4 = 16,
152  PB5 = 17,
153  PB6 = 18,
154  PB7 = 19,
155  PC0 = 20,
157  TEST_EN_PAD = 22,
158  SPI0_D0_PAD = 23,
160  SPI0_D3_PAD = 25,
161  PC1 = 26,
162  PC2 = 27,
163  PC3 = 28,
164  PC4 = 29,
165  PC5 = 30,
166  PD0 = 31,
167  PD1 = 32,
168  PD2 = 33,
169  PD3 = 34,
170  PD4 = 35,
171  PD5 = 36,
172 }PinPad_Name;
173 
178 typedef enum
179 {
181  IISNum0 = 0,
188 }IISNumx;
189 
194 typedef enum
195 {
197  IIS_SLAVE = 1,
201 
206 typedef enum
207 {
212 
217 typedef enum
218 {
223 
228 typedef enum
229 {
236 }DmaInt_Sel_t;
237 
242 typedef enum
243 {
249 
254 typedef enum
255 {
265 
270 typedef enum
271 {
281 
286 typedef enum
287 {
293 
298 typedef enum
299 {
309 
314 typedef enum
315 {
322 }IIS_Mclk_t;
323 
328 typedef enum
329 {
345 
350 typedef enum
351 {
361 
366 typedef enum
367 {
377 
382 typedef enum
383 {
389 
394 typedef enum
395 {
401 
406 typedef struct
407 {
409  uint32_t source_div;
411 
416 typedef struct
417 {
423 
428 typedef struct
429 {
438 
442 void scu_unlock_system_config(void);
443 
447 void scu_unlock_reset_config(void);
448 
452 void scu_unlock_clk_config(void);
453 
457 void scu_lock_system_config(void);
458 
462 void scu_lock_clk_config(void);
463 
467 void scu_lock_reset_config(void);
468 
477 int32_t scu_set_device_gate(uint32_t device_base, int32_t gate);
478 
486 int32_t scu_set_device_reset(uint32_t device_base);
487 
495 int32_t scu_set_device_reset_release(uint32_t device_base);
496 
502 int32_t scu_get_system_reset_state(void);
503 
513 
521 int32_t scu_clear_ext_int_state(Ext_Num num);
522 
531 void scu_set_ext_filter_config(Ext_Num num,FunctionalState cmd,uint32_t param);
532 
540 int8_t scu_para_en_disable(uint32_t device_base);
541 
549 int8_t scu_para_en_enable(uint32_t device_base);
550 
564 int32_t scu_set_div_parameter(uint32_t device_base,uint32_t div_num);
565 
570 void scu_spiflash_no_boot_set(void);
571 
576 void scu_run_in_flash(void);
577 
582 void scu_run_not_in_flash(void);
583 
590 void scu_set_dma_mode(DmaInt_Sel_t channel);
591 
599 
605 
613 
621 
630 
639 
647 
655 void scu_iis_clk_config(IISNumx device, IIS_Clk_Source_t clk_source);
656 
665 
673 
681 
691 
697 void scu_rc_trim_en(bool en);
698 
703 void scu_rc_trim_state_clear(void);
704 
710 uint8_t scu_get_rc_trim_state(void);
711 
717 uint8_t scu_get_rc_trim_c_value(void);
718 
724 uint8_t scu_get_rc_trim_f_value(void);
725 
730 void scu_set_wwdg_halt();
731 
736 void scu_clean_wwdg_halt();
737 
747 
753 void scu_nmi_irq_cfg(Nmi_Irq_t irq);
754 
759 void dsu_init(unsigned int addr);
760 
761 #ifdef __cplusplus
762 }
763 #endif
764 
765 #endif /*CI130X_SCU_H*/
766 
767 /***************** (C) COPYRIGHT Chipintelli Technology Co., Ltd. *****END OF FILE****/
IIS 时钟源 SRC配置结构体
Definition: ci130x_scu.h:406
Definition: ci130x_scu.h:96
CODEC DA
Definition: ci130x_scu.h:399
Definition: ci130x_scu.h:125
Definition: ci130x_scu.h:114
IIS2的编号
Definition: ci130x_scu.h:187
Definition: ci130x_scu.h:163
Definition: ci130x_scu.h:169
codec dac输出数据来源于PAD_IN
Definition: ci130x_scu.h:355
过采样率192
Definition: ci130x_scu.h:275
Definition: ci130x_scu.h:160
Definition: ci130x_scu.h:113
codec dac输出数据来源于CODEC_ADC
Definition: ci130x_scu.h:357
来源于 SRC1
Definition: ci130x_scu.h:303
uint8_t scu_get_rc_trim_state(void)
获取RC trim状态设置
Definition: ci130x_scu.c:1025
IIS_Mode_Sel_t
IIS主从模式选择
Definition: ci130x_scu.h:194
int32_t scu_set_div_parameter(uint32_t device_base, uint32_t div_num)
设置外设时钟分频
Definition: ci130x_scu.c:553
Definition: ci130x_scu.h:104
Definition: ci130x_scu.h:152
输出
Definition: ci130x_scu.h:385
IIS_Clk_Source_t clk_cfg
Definition: ci130x_scu.h:434
void scu_rc_trim_state_clear(void)
清除RC trim的状态
Definition: ci130x_scu.c:1048
PLL倍频后的时钟
Definition: ci130x_scu.h:247
Definition: ci130x_scu.h:103
输入
Definition: ci130x_scu.h:387
ADIOResue_MODE
IO模拟数字功能选择
Definition: ci130x_scu.h:123
来源于 PAD IN
Definition: ci130x_scu.h:263
IIS_Mclk_Config_t mclk_cfg
Definition: ci130x_scu.h:433
void dsu_init(unsigned int addr)
启动NPU模块.
Definition: ci130x_dsu.c:20
Definition: ci130x_scu.h:145
Ext_Num
Definition: ci130x_system.h:89
DmaInt_Sel_t
DMA 中断 channel 选择
Definition: ci130x_scu.h:228
IIS_Sck_Lrck_Wid_t
IIS SCK和LRCK的频率关系比值
Definition: ci130x_scu.h:286
IIS_Mclk_Mode_t mclk_mode
Definition: ci130x_scu.h:435
SCK/LRCK=64
Definition: ci130x_scu.h:291
Definition: ci130x_scu.h:144
void scu_iis_src_config(IIS_Src_Config_t *config, IIS_Mclk_Source_t src)
设置IIS MCLK 时钟来源 SRC 时钟(0、1、2)的分频
Definition: ci130x_scu.c:720
codec dac输出数据来源于IIS1_TX
Definition: ci130x_scu.h:353
Definition: ci130x_scu.h:75
Definition: ci130x_scu.h:146
CODEC AD
Definition: ci130x_scu.h:397
int32_t scu_set_device_gate(uint32_t device_base, int32_t gate)
设置外设时钟开关
Definition: ci130x_scu.c:118
codec_da_sck_in
Definition: ci130x_scu.h:341
来源于 SRC0
Definition: ci130x_scu.h:301
Definition: ci130x_scu.h:138
PLL倍频前的时钟
Definition: ci130x_scu.h:245
void scu_sel_dtrflash_clk(Dtr_Clk_Sel_t clk)
设置DTR控制器时钟来源
Definition: ci130x_scu.c:693
Codec_Channel_t
CODEC AD/DA 选择
Definition: ci130x_scu.h:394
Definition: ci130x_scu.h:79
int32_t scu_set_ext_wakeup_int(Ext_Num num, FunctionalState cmd)
设置外部事件中断唤醒
Definition: ci130x_scu.c:229
void scu_iis_codec_dac_data_config(Codec_Dac_Data_Sel_t src)
设置 codec dac IIS 输出数据来源
Definition: ci130x_scu.c:919
IIS_Mclk_Fs_t fs
Definition: ci130x_scu.h:420
Definition: ci130x_scu.h:126
IIS 时钟配置结构体
Definition: ci130x_scu.h:428
pdm_sck_in
Definition: ci130x_scu.h:343
codec_ad_sck_in
Definition: ci130x_scu.h:339
来源于 SRC2
Definition: ci130x_scu.h:305
void scu_set_dma_mode(DmaInt_Sel_t channel)
设置 DMA chanel 中断开启
Definition: ci130x_scu.c:652
来源于 PAD IN
Definition: ci130x_scu.h:307
Definition: ci130x_scu.h:170
过采样率256
Definition: ci130x_scu.h:277
void scu_lock_reset_config(void)
锁定复位寄存器
Definition: ci130x_scu.c:81
Definition: ci130x_scu.h:101
int32_t scu_clear_ext_int_state(Ext_Num num)
清除外部事件中断唤醒状态
Definition: ci130x_scu.c:269
IIS_Mclk_t mclk
Definition: ci130x_scu.h:418
Definition: ci130x_scu.h:149
void scu_iis_clk_config(IISNumx device, IIS_Clk_Source_t clk_source)
设置IIS(0、1、2)时钟参数
Definition: ci130x_scu.c:792
Definition: ci130x_scu.h:164
IIS_Src_Source_t
MCLK 时钟源SRC的 来源选择
Definition: ci130x_scu.h:254
Definition: ci130x_scu.h:112
Definition: ci130x_scu.h:139
void scu_run_in_flash(void)
设置程序在FLASH中运行
Definition: ci130x_scu.c:673
void scu_unlock_reset_config(void)
解锁复位相关寄存器
Definition: ci130x_scu.c:65
IIS pad sdo输出数据来源于CODEC_ADC
Definition: ci130x_scu.h:373
IOResue_FUNCTION
IO复用功能选择
Definition: ci130x_scu.h:110
MCLK0
Definition: ci130x_scu.h:317
Sys_Clk_Gate_t
系统时钟选择
Definition: ci130x_scu.h:91
IIS做SLAVE
Definition: ci130x_scu.h:197
来源于 INTERNAL RC
Definition: ci130x_scu.h:261
Definition: ci130x_scu.h:150
Pad_IIS_Data_Sel_t
IIS pad sdo输出数据来源选择
Definition: ci130x_scu.h:366
Definition: ci130x_scu.h:116
Definition: ci130x_scu.h:167
Definition: ci130x_scu.h:72
Definition: ci130x_scu.h:137
void scu_iis_mclk_Config(IIS_Mclk_Config_t *config)
设置IIS MCLK(0、1、2) 时钟参数
Definition: ci130x_scu.c:763
IIS_Mclk_Source_t
MCLK 时钟来源选择
Definition: ci130x_scu.h:298
IIS_Mclk_Mode_t
IIS MCLK 输入/输出
Definition: ci130x_scu.h:206
IIS_Clk_Source_t
IIS SCK/LRCK输出来源
Definition: ci130x_scu.h:328
void scu_run_not_in_flash(void)
设置程序不在FLASH中运行
Definition: ci130x_scu.c:684
int32_t scu_get_system_reset_state(void)
获取系统复位状态
Definition: ci130x_scu.c:1004
Definition: ci130x_scu.h:162
正常模式
Definition: ci130x_scu.h:54
void scu_wait_pll_lock_state()
等待 PLL 处于 LOCK 状态
Definition: ci130x_scu.c:711
IISNumx device_select
Definition: ci130x_scu.h:430
Definition: ci130x_scu.h:100
来源于 IPCORE
Definition: ci130x_scu.h:257
Definition: ci130x_scu.h:155
Definition: ci130x_scu.h:219
Definition: ci130x_scu.h:220
只打开DMA channel 0的中断
Definition: ci130x_scu.h:231
MCLK1
Definition: ci130x_scu.h:319
Definition: ci130x_scu.h:153
IIS MCLK配置结构体
Definition: ci130x_scu.h:416
Definition: ci130x_scu.h:141
Definition: ci130x_scu.h:97
Definition: ci130x_scu.h:94
Definition: ci130x_scu.h:151
Codec_Dac_Data_Sel_t
codec dac 输出数据来源选择
Definition: ci130x_scu.h:350
void scu_iis_pad_clk_config(IIS_Clk_Source_t clk_source, IIS_Clk_Mode_t mode)
设置 IIS PAD CLK 时钟参数
Definition: ci130x_scu.c:818
Definition: ci130x_scu.h:115
Definition: ci130x_scu.h:70
PAD输入的SCK/LRCK
Definition: ci130x_scu.h:337
IIS1_RX的编号
Definition: ci130x_scu.h:183
Definition: ci130x_scu.h:81
int8_t scu_para_en_enable(uint32_t device_base)
配置外设分频参数之后需将CLK_DIV_PARAM_EN_CFG寄存器相应位置1
Definition: ci130x_scu.c:500
uint8_t scu_get_rc_trim_c_value(void)
获取RC trim的粗调值
Definition: ci130x_scu.c:1032
Definition: ci130x_scu.h:77
void scu_lock_system_config(void)
锁定系统控制寄存器
Definition: ci130x_scu.c:71
Definition: ci130x_scu.h:148
Definition: ci130x_scu.h:156
int32_t scu_set_device_reset_release(uint32_t device_base)
配置外设复位释放
Definition: ci130x_scu.c:393
codec dac输出数据来源于PDM
Definition: ci130x_scu.h:359
PinPad_Name
IO复用列表,左至右依次为第1功能 ~ 第6功能,用"---"表示无第几复用功能
Definition: ci130x_scu.h:132
IIS_Mode_Sel_t model_sel
Definition: ci130x_scu.h:431
Definition: ci130x_scu.h:165
Definition: ci130x_scu.h:168
Definition: ci130x_scu.h:142
Definition: ci130x_scu.h:154
void scu_iis_pad_mclk_config(IIS_Mclk_Source_t src, IIS_Clk_Mode_t mode)
设置IIS PAD MCLK时钟参数
Definition: ci130x_scu.c:845
uint8_t scu_get_rc_trim_f_value(void)
获取RC trim的细调值
Definition: ci130x_scu.c:1040
chip级定义
Definition: ci130x_scu.h:98
Definition: ci130x_scu.h:147
Definition: ci130x_scu.h:71
int32_t scu_set_system_clk_gate(Sys_Clk_Gate_t base, FunctionalState gate)
设置系统时钟开关
Definition: ci130x_scu.c:86
SCK/LRCK=32
Definition: ci130x_scu.h:289
void scu_lock_clk_config(void)
锁定时钟相关寄存器
Definition: ci130x_scu.c:76
Definition: ci130x_scu.h:84
IIS_Src_Config_t src_cfg
Definition: ci130x_scu.h:432
Definition: ci130x_scu.h:157
Definition: ci130x_scu.h:135
Definition: ci130x_scu.h:80
Definition: ci130x_scu.h:210
Definition: ci130x_scu.h:83
void scu_iis_pdm_mclk_config(IIS_Mclk_Source_t src)
设置 PDM MCLK 时钟参数
Definition: ci130x_scu.c:898
Nmi_Irq_t
nmi中断选择
Definition: ci130x_scu.h:68
int8_t scu_para_en_disable(uint32_t device_base)
配置外设分频参数之前需将CLK_DIV_PARAM_EN_CFG寄存器相应位置0
Definition: ci130x_scu.c:447
IIS_Clk_Mode_t
IIS 输入输出选择
Definition: ci130x_scu.h:382
FunctionalState
Definition: ci130x_system.h:86
Definition: ci130x_scu.h:208
void scu_iis_codec_mclk_config(Codec_Channel_t channel, IIS_Mclk_Source_t src)
设置CODEC MCLK 时钟参数
Definition: ci130x_scu.c:873
IIS pad sdo输出数据来源于IIS1_TX
Definition: ci130x_scu.h:371
void iis_clk_config(IIS_Clk_ConfigTypedef *config)
IIS时钟配置。 master模式时,配置iis的sck和lrck来源,codec和pdm的mclk来源,iis pad输出的mclk和sck lrck...
Definition: ci130x_scu.c:945
IIS0的编号
Definition: ci130x_scu.h:181
void scu_nmi_irq_cfg(Nmi_Irq_t irq)
nmi中断使能
Definition: ci130x_scu.c:1053
Definition: ci130x_scu.h:143
IIS_Mclk_t
MCLK 选择
Definition: ci130x_scu.h:314
uint32_t source_div
Definition: ci130x_scu.h:409
MCLK2
Definition: ci130x_scu.h:321
MCLK1产生的SCK/LRCK
Definition: ci130x_scu.h:333
Definition: ci130x_scu.h:73
Definition: ci130x_scu.h:93
Definition: ci130x_scu.h:102
IIS_Src_Source_t source
Definition: ci130x_scu.h:408
IIS_Mclk_Fs_t
IIS MCLK 过采样率选择
Definition: ci130x_scu.h:270
Definition: ci130x_scu.h:171
Definition: ci130x_scu.h:166
Definition: ci130x_scu.h:78
IIS_SckLrck_Mode_t clk_mode
Definition: ci130x_scu.h:436
void scu_iis_pad_data_config(Pad_IIS_Data_Sel_t src)
设置 pad IIS输出数据来源选择
Definition: ci130x_scu.c:931
void scu_rc_trim_en(bool en)
RC trim使能
Definition: ci130x_scu.c:1019
来源于 EXT_OSC
Definition: ci130x_scu.h:259
IISNumx
IIS号选择
Definition: ci130x_scu.h:178
Definition: ci130x_scu.h:158
IIS_Mclk_Source_t src
Definition: ci130x_scu.h:419
Definition: ci130x_scu.h:221
void scu_spiflash_no_boot_set(void)
配置QSPI0 非boot 模式
Definition: ci130x_scu.c:641
Definition: ci130x_scu.h:140
过采样率384
Definition: ci130x_scu.h:279
void scu_set_wwdg_halt()
设置watchdog计数和复位受到CPU HALTED信号控制
Definition: ci130x_scu.c:191
Definition: ci130x_scu.h:95
IIS_SckLrck_Mode_t
IIS SCK和LRCK 输入/输出
Definition: ci130x_scu.h:217
Definition: ci130x_scu.h:161
sdk配置文件
Qspi_Mode_t
QSPI0控制器模式
Definition: ci130x_scu.h:49
过采样率128
Definition: ci130x_scu.h:273
Definition: ci130x_scu.h:76
IIS_Sck_Lrck_Wid_t sck_lrck
Definition: ci130x_scu.h:421
void scu_clean_wwdg_halt()
设置watchdog计数和复位不受CPU HALTED信号控制
Definition: ci130x_scu.c:210
只打开DMA channel 1的中断
Definition: ci130x_scu.h:233
Definition: ci130x_scu.h:159
int32_t scu_set_device_reset(uint32_t device_base)
配置外设复位
Definition: ci130x_scu.c:339
Definition: ci130x_scu.h:136
IIS做MASTER
Definition: ci130x_scu.h:199
Dtr_Clk_Sel_t
DTRFLASH时钟来源选择
Definition: ci130x_scu.h:242
BOOT模式
Definition: ci130x_scu.h:52
打开DMA 两个channel 中断
Definition: ci130x_scu.h:235
IIS pad sdo输出数据来源于PDM
Definition: ci130x_scu.h:375
void scu_unlock_system_config(void)
解锁系统控制寄存器
Definition: ci130x_scu.c:53
MCLK0产生的SCK/LRCK
Definition: ci130x_scu.h:331
Definition: ci130x_scu.h:117
MCLK2产生的SCK/LRCK
Definition: ci130x_scu.h:335
Definition: ci130x_scu.h:99
void scu_set_ext_filter_config(Ext_Num num, FunctionalState cmd, uint32_t param)
设置pad输入信号(外部事件)滤波
Definition: ci130x_scu.c:295
Definition: ci130x_scu.h:209
void scu_unlock_clk_config(void)
解锁时钟相关寄存器
Definition: ci130x_scu.c:59
IIS1_TX的编号
Definition: ci130x_scu.h:185
Definition: ci130x_scu.h:82
IIS pad sdo输出数据来源于IIS0_TX
Definition: ci130x_scu.h:369
Definition: ci130x_scu.h:74