CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
ci130x_uart.h
浏览该文件的文档.
1 
11 #ifndef __UART_H
12 #define __UART_H
13 
14 #include <stdio.h>
15 #include <ci130x_system.h>
16 
17 #ifdef __cplusplus
18  extern "C" {
19 #endif
20 
28 #define UART0_DMA_ADDR 0x61000000
29 #define UART1_DMA_ADDR 0x62000000
30 #define UART2_DMA_ADDR 0x63000000
35 typedef enum
36 {
42 
46 typedef enum
47 {
48  UART_CTS = 0,
49  UART_DSR = 1,
50  UART_DCD = 2,
51  UART_RI = 3,
52  UART_BUSY = 4,
53  UART_RXFF = 5,
54  UART_RXFE = 6,
55  UART_TXFF = 7,
56  UART_TXFE = 8,
57  UART_EOC = 9,
58  UART_EDF = 10,
60 
64 typedef enum
65 {
77  UART_BaudRate1M = 1000000,
78  UART_BaudRate2M = 2000000,
79  UART_BaudRate3M = 3000000,
81 
82 
86 typedef enum
87 {
93 
97 typedef enum
98 {
103 
107 typedef enum
108 {
112 }UART_Parity;
113 
117 typedef enum
118 {
119  UART_Byte = 1,
120  UART_Word = 0,
122 
126 typedef enum
127 {
132  UART_RTS = 11,
133  UART_DTR = 10,
134  UART_RXE = 9,
135  UART_TXE = 8,
137  UART_NCED = 1,
139 
143 typedef enum
144 {
153 
157 typedef enum
158 {
171  UART_AllInt = 12,
172 }UART_IntMask;
173 
177 typedef enum
178 {
181 }UART_TXRXDMA;
182 
183 
184 void UartPollingSenddata(UART_TypeDef* UARTx, char ch);
186 void UARTPollingConfig(UART_TypeDef* UARTx, UART_BaudRate uartbaudrate);
189 void UARTDMAConfig(UART_TypeDef* UARTx, UART_BaudRate uartbaudrate);
190 int UART_MaskIntState(UART_TypeDef* UARTx,UART_IntMask intmask);
191 void UART_IntClear(UART_TypeDef* UARTx,UART_IntMask intmask);
192 unsigned char UART_RXDATA(UART_TypeDef* UARTx);
193 int UART_ERRORSTATE(UART_TypeDef* UARTx,UART_ERRORFLAG uarterrorflag);
194 void UART_TXDATAConfig(UART_TypeDef* UARTx,unsigned int val);
195 int UART_FLAGSTAT(UART_TypeDef* UARTx,UART_FLAGStatus uartflag);
196 int UART_BAUDRATEConfig(UART_TypeDef* UARTx,UART_BaudRate uartbaudrate);
197 void UART_FIFOClear(UART_TypeDef* UARTx);
198 int UART_LCRConfig(UART_TypeDef* UARTx,UART_WordLength wordlength,\
199  UART_StopBits uartstopbits,UART_Parity uartparity);
200 int UART_TXFIFOByteWordConfig(UART_TypeDef* UARTx,UART_ByteWord uarttxfifobit);
201 void UART_EN(UART_TypeDef* UARTx,FunctionalState cmd);
202 void UART_CRConfig(UART_TypeDef* UARTx,UART_CRBitCtrl crbitctrl,FunctionalState cmd);
203 void UART_RXFIFOConfig(UART_TypeDef* UARTx,UART_FIFOLevel fifoleve);
204 void UART_TXFIFOConfig(UART_TypeDef* UARTx,UART_FIFOLevel fifoleve);
205 int UART_RawIntState(UART_TypeDef* UARTx,UART_IntMask intmask);
206 void UART_TXRXDMAConfig(UART_TypeDef* UARTx,UART_TXRXDMA uartdma);
207 void UART_TimeoutConfig(UART_TypeDef* UARTx,unsigned short time);
208 void UartPollingSenddone(UART_TypeDef* UARTx);
210 void UartSetCLKBaseBaudrate(UART_TypeDef *UARTx,UART_BaudRate uartbaudrate);
211 
216 #ifdef __cplusplus
217 }
218 #endif
219 
220 #endif /*__UART_H*/
Definition: ci130x_uart.h:79
Definition: ci130x_uart.h:149
Definition: ci130x_uart.h:52
Definition: ci130x_uart.h:180
Definition: ci130x_uart.h:134
Definition: ci130x_uart.h:170
void UART_TXFIFOConfig(UART_TypeDef *UARTx, UART_FIFOLevel fifoleve)
UART 发送FIFO 触发深度选择
Definition: ci130x_uart.c:218
Definition: ci130x_uart.h:145
Definition: ci130x_uart.h:57
Definition: ci130x_uart.h:128
Definition: ci130x_uart.h:111
Definition: ci130x_uart.h:68
void UART_CRConfig(UART_TypeDef *UARTx, UART_CRBitCtrl crbitctrl, FunctionalState cmd)
UART 信号使能控制
Definition: ci130x_uart.c:188
Definition: ci130x_uart.h:77
UART_BaudRate
UART波特率定义
Definition: ci130x_uart.h:64
Definition: ci130x_uart.h:75
Definition: ci130x_uart.h:66
Definition: ci130x_uart.h:37
Definition: ci130x_uart.h:166
void UartPollingSenddata(UART_TypeDef *UARTx, char ch)
UART 查询方式发送一个字节数据
Definition: ci130x_uart.c:337
void UARTInterruptConfig(UART_TypeDef *UARTx, UART_BaudRate bd)
UART 中断模式初始化
Definition: ci130x_uart.c:421
Definition: ci130x_uart.h:101
Definition: ci130x_uart.h:48
Definition: ci130x_uart.h:167
UART_WordLength
UART每帧有效数据位定义
Definition: ci130x_uart.h:86
unsigned char UART_RXDATA(UART_TypeDef *UARTx)
UART非阻塞模式接收数据(使用时需确保接收FIFO不为空)
Definition: ci130x_uart.c:46
Definition: ci130x_uart.h:99
Definition: ci130x_uart.h:131
Definition: ci130x_uart.h:168
UART_IntMask
UART中断标志定义
Definition: ci130x_uart.h:157
Definition: ci130x_uart.h:151
UART_Parity
UART奇偶校验定义
Definition: ci130x_uart.h:107
Definition: ci130x_uart.h:148
UART_CRBitCtrl
UART控制寄存器定义
Definition: ci130x_uart.h:126
Definition: ci130x_uart.h:78
int UART_BAUDRATEConfig(UART_TypeDef *UARTx, UART_BaudRate uartbaudrate)
UART的波特率配置
Definition: ci130x_uart.c:96
void UART_TimeoutConfig(UART_TypeDef *UARTx, unsigned short time)
UART 超时设置
Definition: ci130x_uart.c:308
Definition: ci130x_uart.h:119
void UARTPollingConfig(UART_TypeDef *UARTx, UART_BaudRate uartbaudrate)
UART 查询模式初始化
Definition: ci130x_uart.c:388
UART_StopBits
UART停止位定义
Definition: ci130x_uart.h:97
Definition: ci130x_uart.h:74
void UART_RXFIFOConfig(UART_TypeDef *UARTx, UART_FIFOLevel fifoleve)
UART 接收FIFO 触发深度选择
Definition: ci130x_uart.c:206
Definition: ci130x_uart.h:72
int UART_TXFIFOByteWordConfig(UART_TypeDef *UARTx, UART_ByteWord uarttxfifobit)
设置UART的发送FIFO数据位宽
Definition: ci130x_uart.c:150
Definition: ci130x_uart.h:169
Definition: ci130x_uart.h:67
Definition: ci130x_uart.h:51
Definition: ci130x_uart.h:76
Definition: ci130x_uart.h:132
void UART_TXRXDMAConfig(UART_TypeDef *UARTx, UART_TXRXDMA uartdma)
UART DMA 发送/接收控制使能
Definition: ci130x_uart.c:297
void UartPollingSenddone(UART_TypeDef *UARTx)
等待 UART 发送完毕
Definition: ci130x_uart.c:362
Definition: ci130x_uart.h:129
void UART_TXDATAConfig(UART_TypeDef *UARTx, unsigned int val)
UART非阻塞模式发送数据(使用时需确保发送FIFO不为满)
Definition: ci130x_uart.c:70
void UART_FIFOClear(UART_TypeDef *UARTx)
清除 UART FIFO数据
Definition: ci130x_uart.c:119
char UartPollingReceiveData(UART_TypeDef *UARTx)
UART 查询方式接收一个字节数据
Definition: ci130x_uart.c:350
Definition: ci130x_uart.h:161
void UARTDMAConfig(UART_TypeDef *UARTx, UART_BaudRate uartbaudrate)
UART DMA模式初始化(dma按byte宽度传输)
Definition: ci130x_uart.c:468
int UART_FLAGSTAT(UART_TypeDef *UARTx, UART_FLAGStatus uartflag)
读 UART 标志寄存器
Definition: ci130x_uart.c:83
Definition: ci130x_uart.h:54
Definition: ci130x_uart.h:164
Definition: ci130x_uart.h:179
Definition: ci130x_uart.h:89
chip级定义
int UART_LCRConfig(UART_TypeDef *UARTx, UART_WordLength wordlength, UART_StopBits uartstopbits, UART_Parity uartparity)
配置UART的数据位、停止位、奇偶校验位
Definition: ci130x_uart.c:134
Definition: ci130x_uart.h:163
Definition: ci130x_uart.h:135
void UART_DMAByteWordConfig(UART_TypeDef *UARTx, FunctionalState cmd)
UART DMA Byte/word 传输模式设置(仅DMA模式下配置)
Definition: ci130x_uart.c:319
UART_FIFOLevel
UART Tx/RxFIFO触发深度定义
Definition: ci130x_uart.h:143
Definition: ci130x_uart.h:70
Definition: ci130x_uart.h:110
Definition: ci130x_uart.h:40
Definition: ci130x_uart.h:91
Definition: ci130x_uart.h:130
Definition: ci130x_uart.h:133
Definition: ci130x_uart.h:120
Definition: ci130x_system.h:246
FunctionalState
Definition: ci130x_system.h:86
UART_TXRXDMA
UART 定义
Definition: ci130x_uart.h:177
Definition: ci130x_uart.h:146
Definition: ci130x_uart.h:71
Definition: ci130x_uart.h:136
void UartSetCLKBaseBaudrate(UART_TypeDef *UARTx, UART_BaudRate uartbaudrate)
根据波特率配置相应的外设时钟,并打开外设时钟
Definition: ci130x_uart.c:374
void UART_IntMaskConfig(UART_TypeDef *UARTx, UART_IntMask intmask, FunctionalState cmd)
UART 中断屏蔽设置
Definition: ci130x_uart.c:231
Definition: ci130x_uart.h:147
Definition: ci130x_uart.h:88
Definition: ci130x_uart.h:56
Definition: ci130x_uart.h:137
UART_FLAGStatus
UART标志寄存器定义
Definition: ci130x_uart.h:46
Definition: ci130x_uart.h:55
Definition: ci130x_uart.h:165
void UART_IntClear(UART_TypeDef *UARTx, UART_IntMask intmask)
UART 清除中断标志
Definition: ci130x_uart.c:279
Definition: ci130x_uart.h:90
Definition: ci130x_uart.h:160
Definition: ci130x_uart.h:100
void UART_EN(UART_TypeDef *UARTx, FunctionalState cmd)
UART 使能控制
Definition: ci130x_uart.c:169
Definition: ci130x_uart.h:73
Definition: ci130x_uart.h:109
Definition: ci130x_uart.h:150
int UART_RawIntState(UART_TypeDef *UARTx, UART_IntMask intmask)
UART 原始中断(中断屏蔽前)状态
Definition: ci130x_uart.c:255
Definition: ci130x_uart.h:159
UART_ERRORFLAG
UART接收错误标志寄存器定义
Definition: ci130x_uart.h:35
Definition: ci130x_uart.h:162
Definition: ci130x_uart.h:53
Definition: ci130x_uart.h:39
Definition: ci130x_uart.h:69
UART_ByteWord
UART总线数据传输模式定义
Definition: ci130x_uart.h:117
Definition: ci130x_uart.h:38
int UART_ERRORSTATE(UART_TypeDef *UARTx, UART_ERRORFLAG uarterrorflag)
UART错误标志状态
Definition: ci130x_uart.c:59
int UART_MaskIntState(UART_TypeDef *UARTx, UART_IntMask intmask)
UART 屏蔽后的中断状态
Definition: ci130x_uart.c:268
Definition: ci130x_uart.h:171
Definition: ci130x_uart.h:58
Definition: ci130x_uart.h:50
Definition: ci130x_uart.h:49