1 /**
2 ******************************************************************************
3 * @file rtl8721d_usi_uart.h
4 * @author
5 * @version V1.0.0
6 * @date 2017-09-26
7 * @brief This file contains all the functions prototypes for the USI firmware
8 * library.
9 ******************************************************************************
10 * @attention
11 *
12 * This module is a confidential and proprietary property of RealTek and
13 * possession or use of this module requires written permission of RealTek.
14 *
15 * Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
16 ******************************************************************************
17 */
18
19 #ifndef _RTL8721D_USI_UART_H_
20 #define _RTL8721D_USI_UART_H_
21
22 #include "rtl8721d_usi.h"
23
24 /** @addtogroup AmebaD_Periph_Driver
25 * @{
26 */
27
28 /** @defgroup USI-UART
29 * @{
30 */
31
32 /** @addtogroup USI-UART
33 * @verbatim
34 *****************************************************************************************
35 * Introduction
36 *****************************************************************************************
37 * USI0-UART:
38 * - Base Address: USI0_DEV
39 * - IPclk: XTAL, normally is 40MHz
40 * - BaudRate: 110~6000000
41 * - Low Power Rx: Support
42 * - Boot From UART without Flash
43 * - IRQ: USI_IRQ
44 * - GDMA TX handshake interface: GDMA_HANDSHAKE_INTERFACE_USI0_TX
45 * - GDMA RX handshake interface: GDMA_HANDSHAKE_INTERFACE_USI0_RX
46 *
47 *****************************************************************************************
48 * USI UART Low Power Rx
49 *****************************************************************************************
50 * USI0-UART support
51 * UART can receive data when soc enter power save mode
52 * baudrate: 110~500000
53 *
54 *****************************************************************************************
55 * How to use USI Normal Uart
56 *****************************************************************************************
57 * To use the normal uart mode, the following steps are mandatory:
58 *
59 * 1. Enable peripheral clock and power:
60 *
61 * 2. configure the USI UART pinmux
62 *
63 * 3. Set default parameters, change some parameter if needed
64 * USI_UARTStructInit(USI_UARTInitTypeDef* USI_UARTInitStruct)
65 *
66 * 4. init hardware use step3 parameters.
67 * USI_UARTInit(USI_TypeDef* USIx, USI_UARTInitTypeDef *USI_UARTInitStruct)
68 *
69 * 5. Set Baud Rate.
70 * USI_UARTSetBaud(USI_TypeDef* USIx, u32 BaudRate)
71 *
72 * 6. Enable IRQ using following function if needed
73 * USI_UARTINTConfig(): USI UART IRQ Mask set
74 * InterruptRegister(): register the uart irq handler
75 * InterruptEn(): Enable the NVIC interrupt
76 *
77 * 7. Enable uart rx path:
78 * USI_UARTRxCmd().
79 *
80 *****************************************************************************************
81 * How to use USI uart in DMA mode
82 *****************************************************************************************
83 * To use the uart in DMA mode, the following steps are mandatory:
84 *
85 * 1. Enable peripheral clock and power:
86 *
87 * 2. configure the USI UART pinmux
88 *
89 * 3. Set default parameters, and change DMA mode open USI_UARTInitStruct
90 * USI_UARTStructInit(USI_UARTInitTypeDef* USI_UARTInitStruct)
91 *
92 * 4. init hardware use step3 parameters.
93 * USI_UARTInit(USI_TypeDef* USIx, USI_UARTInitTypeDef *USI_UARTInitStruct)
94 *
95 * 5. Set Baud Rate.
96 * USI_UARTSetBaud(USI_TypeDef* USIx, u32 BaudRate)
97 *
98 * 6. Enable uart rx path:
99 * USI_UARTRxCmd().
100 *
101 * 7. Configure the uart DMA burst size:
102 * USI_UARTTXDMAConfig()
103 * USI_UARTRXDMAConfig().
104 *
105 * 8. Active the UART TX/RX DMA Request:
106 * USI_UARTTXDMACmd()
107 * USI_UARTRXDMACmd().
108 *
109 * 9. GDMA related configurations(source address/destination address/block size etc.).
110 * USI_UARTTXGDMA_Init()
111 * USI_UARTRXGDMA_Init()
112 *
113 *****************************************************************************************
114 * How to use USI uart in Low Power mode
115 *****************************************************************************************
116 * To use the uart in Low Power mode, the following steps are mandatory:
117 *
118 * 1. Enable peripheral clock and power:
119 *
120 * 2. configure the USI UART pinmux
121 *
122 * 3. Set default parameters, change some parameter if needed
123 * USI_UARTStructInit(USI_UARTInitTypeDef* USI_UARTInitStruct)
124 *
125 * 4. init hardware use step3 parameters.
126 * USI_UARTInit(USI_TypeDef* USIx, USI_UARTInitTypeDef *USI_UARTInitStruct)
127 *
128 * 5. Set Baud Rate.
129 * USI_UARTSetBaud(USI_TypeDef* USIx, u32 BaudRate)
130 *
131 * 6. Enable IRQ using following function if needed
132 * USI_UARTINTConfig(): USI UART IRQ Mask set
133 * InterruptRegister(): register the uart irq handler
134 * InterruptEn(): Enable the NVIC interrupt
135 *
136 * 6. Init Low power RX:
137 * USI_UARTLPRxStructInit(USI_LPUARTInitTypeDef* USI_LPUARTInitStruct)
138 * USI_UARTLPRxInit(USI_TypeDef* USIx, USI_LPUARTInitTypeDef *USI_LPUARTInitTypeDef)
139 *
140 * 7. Set the low power RX Baud Rate
141 * USI_UARTLPRxBaudSet(USI_TypeDef* USIx, u32 BaudRate, u32 RxIPClockHz)
142 *
143 * 8. Enable monitor function if needed.
144 * USI_UARTLPRxMonitorCmd()
145 *
146 * 9. Enable low power rx path:
147 * USI_UARTLPRxCmd().
148 *
149 * @note when uart work in low power rx mode, clock source can switch between
150 * XTAL and OSC. As for how and when to excute switching action,
151 * refer to related uart specifications for more details.
152 *
153 * @note Besides, if more details about the uart low power rx path contens is needed,
154 * please refer to uart specifications.
155 *
156 *****************************************************************************************
157 * How to use USI uart in IrDA mode
158 *****************************************************************************************
159 * To use the uart in IrDA mode, the following steps are mandatory:
160 *
161 * 1. Enable peripheral clock and power:
162 *
163 * 2. configure the pinmux:
164 *
165 * 3. Disable rx path:
166 * USI_UARTRxCmd().
167 *
168 * 4. Program the IrDA tx pulse width and location and IrDA rx pulse filter:
169 * USI_UARTIrDAStructInit(USI_UartIrDAInitTypeDef * IrDA_InitStruct)
170 *
171 * 5. Init Hardware:
172 * USI_UARTIrDAInit(USI_TypeDef* USIx, USI_UartIrDAInitTypeDef * IrDA_InitStruct).
173 *
174 * 6. Enable the IrDA function:
175 * USI_UARTIrDACmd().
176 *
177 * 7. According to the IrDA SIR protocol data format requrement, program Word Length,
178 * Stop Bit, Parity and DMA Mode(ENABLE/DISABLE):
179 * USI_UARTStructInit(USI_UARTInitTypeDef* USI_UARTInitStruct)
180 * USI_UARTInit(USI_TypeDef* USIx, USI_UARTInitTypeDef *USI_UARTInitStruct)
181 *
182 * 8. Program the Baud Rate:
183 * USI_UARTSetBaud().
184 *
185 * 9. Enable IRQ if needed:
186 * USI_UARTINTConfig(): USI UART IRQ Mask set
187 * InterruptRegister(): register the uart irq handler
188 * InterruptEn(): Enable the NVIC interrupt
189 *
190 * 10. Enable uart rx path:
191 * USI_UARTRxCmd().
192 *
193 * @note AmebaD IrDA just support IrDA SIR protocol, setting baud rate is no more than
194 * 115200 bps.
195 *
196 * @note because IrDA transfers data using infrared carrier and for the property of the
197 * IrDA transceiver, IrDA just work in half duplex mode. For details, refer to the IrDA
198 * protocol specification.
199 *****************************************************************************************
200 * @endverbatim
201 */
202
203 /* Exported Types --------------------------------------------------------*/
204
205 /** @defgroup USI_UART_Exported_Types USI-UART Exported Types
206 * @{
207 */
208
209 /**
210 * @brief USI_UART Init structure definition
211 */
212 typedef struct
213 {
214 u32 USI_UARTDmaModeCtrl; /*!< Specifies the uart DMA mode state.
215 This parameter can be ENABLE or DISABLE. */
216
217 u32 USI_UARTWordLen; /*!< Specifies the USI UART word length.
218 This parameter can be a value of @ref USI_UART_Word_length_define. */
219
220 u32 USI_UARTStopBit; /*!< Specifies the USI UART stop bit number.
221 This parameter can be a value of @ref USI_UART_Stop_Bit_define. */
222
223 u32 USI_UARTParity; /*!< Specifies the USI UART parity.
224 This parameter can be a value of @ref USI_UART_Parity_Enable_define. */
225
226 u32 USI_UARTParityType; /*!< Specifies the USI UART parity type.
227 This parameter can be a value of @ref USI_UART_Parity_Type_define. */
228
229 u32 USI_UARTStickParity; /*!< Specifies the USI UART stick parity.
230 This parameter can be a value of @ref USI_UART_Stick_Parity_Type_define. */
231
232 u32 USI_UARTFlowControl; /*!< Specifies the USI UART auto flow control.
233 This parameter can be ENABLE or DISABLE. */
234
235 u32 USI_UARTFlwCtrlRxHoldThd; /*!< Specifies the USI UART uart auto flow control rx hold threshold.
236 This parameter can be a value of 0 ~ 64. */
237
238 u32 USI_UARTRxFifoTrigLevel; /*!< Specifies the USI UART rx fifo trigger level.
239 This parameter can be a value of 0 ~ 64 . */
240
241 u32 USI_UARTTxFifoTrigLevel; /*!< Specifies the USI UART rx error report control.
242 This parameter can be a value of 0 ~ 64 . */
243 } USI_UARTInitTypeDef;
244
245 /**
246 * @brief USI UART Low Power Init structure definition
247 */
248 typedef struct
249 {
250 u32 USI_LPUARTOscPerbitUpdCtrl; /*!< Specifies the OSC perbit update control when use xtal 8M.
251 This parameter can be ENABLE or DISABLE.
252 ENABLE: osc perbit updates with xtal perbit when use xtal 8M.
253 DISABLE: osc perbit does't update with xtal perbit when use xtal 8M.
254 @note This parameter is only used in low power rx path with xtal 8M.
255 @note osc perbit will update when use osc 8M, even if USI_LPUARTOscPerbitUpdCtrl is disable */
256 u32 USI_LPUARTBitNumThres; /*!< Specifies the bit number threshold of one monitor period.
257 This parameter is used to get the average clock cycles of one bit
258 and can be a number between 0x00 and 0x7f.
259 @note This parameter is only used in low power rx path. */
260 } USI_LPUARTInitTypeDef;
261
262 /**
263 * @brief USI UART IRDA Init structure definition
264 */
265 typedef struct
266 {
267 u32 USI_UARTIrDARxInv; /*!< Specifies the uart irda rx invert control.
268 This parameter can be ENABLE or DISABLE.
269 ENABLE: invert the irda input signal.
270 DISABLE: does't invert the irda input signal.
271 @note This parameter is only used in IrDA mode. */
272
273 u32 USI_UARTIrDATxInv; /*!< Specifies the uart irda tx invert control.
274 This parameter can be ENABLE or DISABLE.
275 ENABLE: invert the irda output signal.
276 DISABLE: does't invert the irda output signal.
277 @note This parameter is only used in IrDA mode. */
278
279 u32 USI_UARTUpperShift; /*!< Specifies the USI uart irda tx pulse right edge shift direction.
280 This parameter can be a value of @ref USI_UART_IRDA_PULSE_SHIFT_define. */
281
282 u32 USI_UARTUpperShiftVal; /*!< Specifies the USI uart irda tx pulse right edge shift value in the given direction.
283 This parameter can be a number between 0x0000 and 0x7fff. */
284
285 u32 USI_UARTLowShift; /*!< Specifies the USI uart irda tx pulse left edge shift direction.
286 This parameter can be a value of @ref USI_UART_IRDA_PULSE_SHIFT_define. */
287
288 u32 USI_UARTLowShiftVal; /*!< Specifies the USI uart irda tx pulse left edge shift value in the given direction.
289 This parameter can be a number between 0x0000 and 0x7fff. */
290
291 u32 USI_UARTRxFilterThres; /*!< Specifies the USI uart irda rx filter threshold.
292 This parameter can be a number between 0x0000 and 0x7fff
293 @note This parameter is only used in IrDA mode. */
294
295 u32 USI_UARTRxFilterCmd; /*!< Specifies the USI uart irda rx filter control.
296 This parameter can be ENABLE or DISABLE.
297 ENABLE: USI uart IrDA rx filter is used.
298 DISABLE: USI uart IrDA rx filter is not used.
299 @note This parameter is only used in IrDA mode. */
300 }USI_UartIrDAInitTypeDef;
301 /**
302 * @}
303 */
304
305 /* Exported constants --------------------------------------------------------*/
306 /** @defgroup USI_UART_Exported_Constants USI-UART Exported Constants
307 * @{
308 */
309
310 /** @defgroup USI_UART_IRDA_PULSE_SHIFT_define
311 * @{
312 */
313 #define USI_UART_IRDA_PULSE_LEFT_SHIFT ((u32)0x00000000)
314 #define USI_UART_IRDA_PULSE_RIGHT_SHIFT ((u32)0x00000001)
315 #define IS_USI_IRDA_PUL_SHIFT(SHIFT) (((SHIFT) == USI_UART_IRDA_PULSE_LEFT_SHIFT) || \
316 ((SHIFT) == USI_UART_IRDA_PULSE_RIGHT_SHIFT))
317
318 /**
319 * @}
320 */
321
322 /** @defgroup USI_UART_Word_length_define
323 * @{
324 */
325
326 #define USI_RUART_WLS_7BITS ((u32)0x00000000)
327 #define USI_RUART_WLS_8BITS ((u32)0x00000001)
328
329 #define IS_USI_UART_WLS(VAL) (((VAL) == USI_RUART_WLS_7BITS) || \
330 ((VAL) == USI_RUART_WLS_8BITS))
331
332 /**
333 * @}
334 */
335
336 /** @defgroup USI_UART_Stop_Bit_define
337 * @{
338 */
339
340 #define USI_RUART_STOP_BIT_1 ((u32)0x00000000)
341 #define USI_RUART_STOP_BIT_2 ((u32)0x00000002)
342
343 #define IS_USI_UART_STOP_BIT(VAL) (((VAL) == USI_RUART_STOP_BIT_1) || \
344 ((VAL) == USI_RUART_STOP_BIT_2))
345
346 /**
347 * @}
348 */
349
350 /** @defgroup USI_UART_Parity_Enable_define
351 * @{
352 */
353
354 #define USI_RUART_PARITY_DISABLE ((u32)0x00000000)
355 #define USI_RUART_PARITY_ENABLE ((u32)0x00000010)
356
357 #define IS_USI_UART_PARITY_ENABLE(VAL) (((VAL) == USI_RUART_PARITY_DISABLE) || \
358 ((VAL) == USI_RUART_PARITY_ENABLE))
359
360 /**
361 * @}
362 */
363
364 /** @defgroup USI_UART_Parity_Type_define
365 * @{
366 */
367
368 #define USI_RUART_ODD_PARITY ((u32)0x00000000)
369 #define USI_RUART_EVEN_PARITY ((u32)0x00000020)
370
371 #define IS_USI_UART_PARITY_TYPE(VAL) (((VAL) == USI_RUART_ODD_PARITY) || \
372 ((VAL) == USI_RUART_EVEN_PARITY))
373
374 /**
375 * @}
376 */
377
378 /** @defgroup USI_UART_Stick_Parity_Type_define
379 * @{
380 */
381
382 #define USI_RUART_STICK_PARITY_DISABLE ((u32)0x00000000)
383 #define USI_RUART_STICK_PARITY_ENABLE ((u32)0x00000040)
384
385 #define IS_USI_UART_STICK_PARITY_ENABLE(VAL) (((VAL) == USI_RUART_STICK_PARITY_DISABLE) || \
386 ((VAL) == USI_RUART_STICK_PARITY_ENABLE))
387
388 /**
389 * @}
390 */
391
392 /** @defgroup USI_UART_Interrupt_ID_define
393 * @{
394 */
395 /*TX FIFO (UART, I2C, SPI)*/
396 #define USI_TX_FIFO_ALMOST_EMPTY_INTER ((u32)0x00000001)
397 #define USI_TX_FIFO_OVERFLOW_INTER ((u32)0x00000002)
398 #define USI_TX_FIFO_UNDERFLOW_INTER ((u32)0x00000004) /*USI UART do not have this type interrupt*/
399
400 /*RX FIFO (UART, I2C, SPI)*/
401 #define USI_RX_FIFO_ALMOST_FULL_INTER ((u32)0x00000010)
402 #define USI_RX_FIFO_OVERFLOW_INTER ((u32)0x00000020)
403 #define USI_RX_FIFO_UNDERFLOW_INTER ((u32)0x00000040)
404
405 /*UART related interrupt*/
406 #define USI_UART_PARITY_ERROR_INTER ((u32)0x00000100)
407 #define USI_UART_STOP_ERROR_INTER ((u32)0x00000200)
408 #define USI_UART_BREAK_INTER ((u32)0x00000400)
409 #define USI_RX_FIFO_TIMEOUT_INTER ((u32)0x00000800)
410 #define USI_RX_BAUDMON_DONE_INTER ((u32)0x00001000)
411 #define USI_TX_CTS_CHANGE_INTER ((u32)0x00002000)
412
413
414 /*JUST FOR USI UART USE*/
415 #define IS_USI_UART_GET_IT(IT) (((IT) == USI_TX_FIFO_ALMOST_EMPTY_INTER) || \
416 ((IT) == USI_TX_FIFO_OVERFLOW_INTER) || \
417 ((IT) == USI_RX_FIFO_ALMOST_FULL_INTER)|| \
418 ((IT) == USI_RX_FIFO_OVERFLOW_INTER)|| \
419 ((IT) == USI_RX_FIFO_UNDERFLOW_INTER)|| \
420 ((IT) == USI_UART_PARITY_ERROR_INTER)|| \
421 ((IT) == USI_UART_STOP_ERROR_INTER)|| \
422 ((IT) == USI_UART_BREAK_INTER)|| \
423 ((IT) == USI_RX_FIFO_TIMEOUT_INTER)|| \
424 ((IT) == USI_RX_BAUDMON_DONE_INTER)|| \
425 ((IT) == USI_TX_CTS_CHANGE_INTER))
426
427 #define IS_USI_UART_IT(IT) ((((IT) & (u32)0xFFFFC08C) == 0x00) && ((IT) != 0x00))
428
429 #define IS_USI_UART_CLEAR_IT(IT) ((((IT) & (u32)0xFFFFC89D) == 0x00) && ((IT) != 0x00))
430
431 /**
432 * @}
433 */
434
435 /** @defgroup USI_UART_Rx_DMA_mode_define
436 * @{
437 */
438
439 #define USI_UART_RX_UART_IS_DMA_FLOW_CTRL ((u32)0x00000001)
440 #define USI_UART_RX_GDMA_IS_DMA_FLOW_CTRL ((u32)0x00000000)
441
442 #define IS_USI_UART_RX_DMA_MODE(MODE) (((MODE) == USI_UART_RX_UART_IS_DMA_FLOW_CTRL) || \
443 ((MODE) == USI_UART_RX_GDMA_IS_DMA_FLOW_CTRL) )
444
445 /**
446 * @}
447 */
448
449 /** @defgroup USI_Peripheral_define
450 * @{
451 */
452 #define IS_ALL_USI_PERIPH(PERIPH) (((PERIPH) == USI0_DEV))
453 #define IS_ALL_USI_LP_PERIPH(PERIPH) (((PERIPH) == USI0_DEV))
454 /**
455 * @}
456 */
457
458 /** @defgroup USI_UART_SoftWare_Status_define
459 * @{
460 */
461 #define USI_UART_STATETX_DMA 1
462 #define USI_UART_STATETX_INT 2
463 #define USI_UART_STATETX_POLL 3
464 #define USI_UART_STATERX_DMA 1
465 #define USI_UART_STATERX_INT 2
466 #define USI_UART_STATERX_POLL 3
467 /**
468 * @}
469 */
470
471
472 /**
473 * @}
474 */
475
476
477 /* Exported functions --------------------------------------------------------*/
478 /** @defgroup USI_UART_Exported_Functions USI-UART Exported Functions
479 * @{
480 */
481 /** @defgroup USI_UART_Normal_functions
482 * @{
483 */
484 _LONG_CALL_ void USI_UARTDeInit(USI_TypeDef* USIx);
485 _LONG_CALL_ void USI_UARTStructInit(USI_UARTInitTypeDef* USI_UARTInitStruct);
486 _LONG_CALL_ void USI_UARTInit(USI_TypeDef* USIx, USI_UARTInitTypeDef* USI_UARTInitStruct);
487 _LONG_CALL_ u32 USI_UARTBaudParaGet(u32 baudrate, u32 *ovsr, u32 *ovsr_adj);
488 _LONG_CALL_ void USI_UARTBaudParaGetFull(u32 IPclk, u32 baudrate, u32 *ovsr, u32 *ovsr_adj);
489 _LONG_CALL_ void USI_UARTSetBaudExt(USI_TypeDef* USIx, u32 Ovsr, u32 Ovsr_adj);
490 _LONG_CALL_ void USI_UARTSetBaud(USI_TypeDef* USIx, u32 BaudRate);
491 _LONG_CALL_ void USI_UARTSetRxLevel(USI_TypeDef* USIx, u32 FifoLv);
492 _LONG_CALL_ void USI_UARTRxCmd(USI_TypeDef* USIx, u32 NewState);
493 _LONG_CALL_ u32 USI_UARTWritable(USI_TypeDef* USIx);
494 _LONG_CALL_ u32 USI_UARTReadable(USI_TypeDef* USIx);
495 _LONG_CALL_ void USI_UARTCharPut(USI_TypeDef* USIx, u8 TxData);
496 _LONG_CALL_ void USI_UARTCharGet(USI_TypeDef* USIx, u8 *pRxByte);
497 _LONG_CALL_ void USI_UARTReceiveData(USI_TypeDef* USIx, u8* OutBuf, u32 Count);
498 _LONG_CALL_ void USI_UARTSendData(USI_TypeDef* USIx, u8* InBuf, u32 Count);
499 _LONG_CALL_ u32 USI_UARTReceiveDataTO(USI_TypeDef* USIx, u8* OutBuf, u32 Count, u32 Times);
500 _LONG_CALL_ u32 USI_UARTSendDataTO(USI_TypeDef* USIx,u8* InBuf,u32 Count, u32 Times);
501 _LONG_CALL_ void USI_UARTRxByteCntClear(USI_TypeDef* USIx);
502 _LONG_CALL_ u32 USI_UARTRxByteCntGet(USI_TypeDef* USIx);
503 _LONG_CALL_ void USI_UARTBreakCtl(USI_TypeDef* USIx, u32 NewState);
504 _LONG_CALL_ u32 USI_UARTClearRxFifo(USI_TypeDef* USIx);
505 _LONG_CALL_ void USI_UARTClearTxFifo(USI_TypeDef* USIx);
506 _LONG_CALL_ u32 USI_UARTGetRxFifoValidCnt(USI_TypeDef* USIx);
507 _LONG_CALL_ u32 USI_UARTGetTxFifoEmptyCnt(USI_TypeDef* USIx);
508 _LONG_CALL_ void USI_UARTINTConfig(USI_TypeDef* USIx, u32 UART_IT, u32 newState);
509 _LONG_CALL_ u32 USI_UARTIntStatus(USI_TypeDef* USIx);
510 _LONG_CALL_ u32 USI_UARTGetRawIntStatus(USI_TypeDef* USIx);
511 _LONG_CALL_ void USI_UARTClearAllIntStatus(USI_TypeDef* USIx);
512 _LONG_CALL_ void USI_UARTClearIntStatus(USI_TypeDef* USIx, u32 USIUART_IT);
513 _LONG_CALL_ void USI_UARTWaitBusy(USI_TypeDef* USIx, u32 PollTimes);
514 _LONG_CALL_ void USI_UARTRxTimeOutConfig(USI_TypeDef* USIx, u32 TimeOutCnt);
515 _LONG_CALL_ void USI_UARTRxDMAModeConfig(USI_TypeDef* USIx, u32 Mode);
516 _LONG_CALL_ void USI_UARTRxDMADummyDataConfig(USI_TypeDef* USIx, u8 Byte);
517 _LONG_CALL_ u32 USI_UARTGetRxDMADummyFlag(USI_TypeDef* USIx);
518 _LONG_CALL_ void USI_UARTRxClearDMADummyFlag(USI_TypeDef* USIx);
519
520 /**
521 * @}
522 */
523
524 /** @defgroup USI_UART_DMA_functions
525 * @{
526 */
527 _LONG_CALL_ void USI_UARTTXDMAConfig(USI_TypeDef* USIx, u32 TxDmaBurstSize);
528 _LONG_CALL_ void USI_UARTRXDMAConfig(USI_TypeDef* USIx, u32 RxDmaBurstSize);
529 _LONG_CALL_ void USI_UARTTXDMACmd(USI_TypeDef* USIx, u32 NewState);
530 _LONG_CALL_ void USI_UARTRXDMACmd(USI_TypeDef* USIx, u32 NewState);
531 _LONG_CALL_ BOOL USI_UARTTXGDMA_Init(u8 USIIndex, GDMA_InitTypeDef *GDMA_InitStruct, void *CallbackData, IRQ_FUN CallbackFunc, u8 *pTxBuf, int TxCount);
532 _LONG_CALL_ BOOL USI_UARTRXGDMA_Init(u8 USIIndex, GDMA_InitTypeDef *GDMA_InitStruct, void *CallbackData, IRQ_FUN CallbackFunc, u8 *pRxBuf, int RxCount);
533 /**
534 * @}
535 */
536
537 /** @defgroup USI_UART_Low_Power_functions
538 * @{
539 */
540 _LONG_CALL_ void USI_UARTLPRxStructInit(USI_LPUARTInitTypeDef* USI_UARTInitStruct);
541 _LONG_CALL_ void USI_UARTLPRxInit(USI_TypeDef* USIx, USI_LPUARTInitTypeDef *USI_UARTInitStruct);
542 _LONG_CALL_ void USI_UARTLPRxBaudSet(USI_TypeDef* USIx, u32 BaudRate, u32 RxIPClockHz);
543 _LONG_CALL_ void USI_UART_LPRxMonitorCmd(USI_TypeDef* USIx, u32 NewState);
544 _LONG_CALL_ void USI_UARTLPRxpathSet(USI_TypeDef* USIx, u32 LPRxpath);
545 _LONG_CALL_ void USI_UARTLPRxIPClockSet(USI_TypeDef* USIx, u32 RxIPClock);
546 _LONG_CALL_ void USI_UARTLPRxCmd(USI_TypeDef* USIx, u32 NewState);
547 /**
548 * @}
549 */
550
551 /** @defgroup USI_UART_IRDA_functions
552 * @{
553 */
554 _LONG_CALL_ void USI_UARTIrDAStructInit(USI_UartIrDAInitTypeDef * IrDA_InitStruct);
555 _LONG_CALL_ void USI_UARTIrDAInit(USI_TypeDef* USIx, USI_UartIrDAInitTypeDef * IrDA_InitStruct);
556 _LONG_CALL_ void USI_UARTIrDACmd(USI_TypeDef* USIx, u32 NewState);
557 /** @} */
558 /** @} */
559
560 /**
561 * @}
562 */
563
564 /**
565 * @}
566 */
567
568 /* Other Definitions --------------------------------------------------------*/
569
570 /*----------------USI UART definations---------------*/
571 typedef struct
572 {
573 u32 LOW_POWER_RX_ENABLE; /*Enable low power RX*/
574 } USI_UARTCFG_TypeDef;
575
576 extern USI_UARTCFG_TypeDef usi_uart_config[];
577 extern u32 USI_UART_StateTx[1];
578 extern u32 USI_UART_StateRx[1];
579
580 static inline void
USI_UART_SetTxFlag(u32 USIIdx,u32 Flag)581 USI_UART_SetTxFlag(u32 USIIdx, u32 Flag)
582 {
583 USI_UART_StateTx[USIIdx] = Flag;
584 }
585
586 static inline void
USI_UART_SetRxFlag(u32 USIIdx,u32 Flag)587 USI_UART_SetRxFlag(u32 USIIdx, u32 Flag)
588 {
589 USI_UART_StateRx[USIIdx] = Flag;
590 }
591
592 static inline u32
USI_UART_GetTxFlag(u32 USIIdx)593 USI_UART_GetTxFlag(u32 USIIdx)
594 {
595 return (USI_UART_StateTx[USIIdx]);
596 }
597
598 static inline u32
USI_UART_GetRxFlag(u32 USIIdx)599 USI_UART_GetRxFlag(u32 USIIdx)
600 {
601 return (USI_UART_StateRx[USIIdx]);
602 }
603
604 #endif
605 /******************* (C) COPYRIGHT 2017 Realtek Semiconductor *****END OF FILE****/
606