uart.h
Go to the documentation of this file.
1 /********************************************************************************************************
2  * @file uart.h
3  *
4  * @brief This is the header file for TLSR8258
5  *
6  * @author Driver Group
7  * @date May 8, 2018
8  *
9  * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd.
10  * All rights reserved.
11  *
12  * The information contained herein is confidential property of Telink
13  * Semiconductor (Shanghai) Co., Ltd. and is available under the terms
14  * of Commercial License Agreement between Telink Semiconductor (Shanghai)
15  * Co., Ltd. and the licensee or the terms described here-in. This heading
16  * MUST NOT be removed from this file.
17  *
18  * Licensees are granted free, non-transferable use of the information in this
19  * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
20  * @par History:
21  * 1.initial release(DEC. 26 2018)
22  *
23  * @version A001
24  *
25  *******************************************************************************************************/
26 
27 #include "register.h"
28 #include "gpio.h"
29 #include "compiler.h"
30 
31 #ifndef uart_H
32 #define uart_H
33 
34 
38 enum{
43 };
44 
48 typedef enum {
53 
57 typedef enum {
62 
66 typedef enum {
70 
75 typedef enum{
82 
87 typedef enum{
95 
100 typedef enum{
106 
111 typedef enum{
117 
118 
119 
125 static inline unsigned char uart_tx_is_busy(void)
126 {
127  return ( (reg_uart_status1 & FLD_UART_TX_DONE) ? 0 : 1) ;
128 }
129 
130 
136 static inline void uart_reset(void)
137 {
139  reg_rst0 &= (~FLD_RST0_UART);
140 }
141 
142 
170 extern void uart_init(unsigned short g_uart_div, unsigned char g_bwpc, UART_ParityTypeDef Parity, UART_StopBitTypeDef StopBit);
179 extern void uart_init_baudrate(unsigned int Baudrate,unsigned int System_clock , UART_ParityTypeDef Parity, UART_StopBitTypeDef StopBit);
180 
187 extern void uart_dma_enable(unsigned char rx_dma_en, unsigned char tx_dma_en);
188 
197 extern void uart_irq_enable(unsigned char rx_irq_en, unsigned char tx_irq_en);
198 
206 extern void uart_ndma_send_byte(unsigned char uartData);
207 
218 extern void uart_ndma_irq_triglevel(unsigned char rx_level, unsigned char tx_level);
219 
227 extern unsigned char uart_ndmairq_get(void);
228 
236 extern volatile unsigned char uart_dma_send(unsigned char* Addr);
237 
245 extern volatile unsigned char uart_send_byte(unsigned char byte);
254 extern void uart_recbuff_init(unsigned char *RecvAddr, unsigned short RecvBufLen);
255 
256 
257 
264 extern unsigned char uart_is_parity_error(void);
265 
271 extern void uart_clear_parity_error(void);
272 
284 extern void uart_set_rts(unsigned char Enable, UART_RTSModeTypeDef Mode, unsigned char Thresh, unsigned char Invert, UART_RtsPinDef pin);
285 
293 extern void uart_set_rts_level(unsigned char Polarity);
294 
302 extern void uart_set_cts(unsigned char Enable, unsigned char Select,UART_CtsPinDef pin);
303 
310 extern void uart_gpio_set(UART_TxPinDef tx_pin,UART_RxPinDef rx_pin);
311 
312 
313 #endif
314  //end of GP14
static void uart_reset(void)
This function resets the UART module.
Definition: uart.h:136
Definition: gpio_8258.h:58
void uart_ndma_irq_triglevel(unsigned char rx_level, unsigned char tx_level)
config the number level setting the irq bit of status register 0x9d ie 0x9d[3]. uart_ndma_get_irq If ...
Definition: gpio_8258.h:47
Definition: uart.h:93
Definition: gpio_8258.h:56
Definition: gpio_8258.h:73
void uart_gpio_set(UART_TxPinDef tx_pin, UART_RxPinDef rx_pin)
This function serves to select pin for UART module.
Definition: uart.h:91
Definition: uart.h:77
Definition: uart.h:80
void uart_recbuff_init(unsigned char *RecvAddr, unsigned short RecvBufLen)
data receive buffer initiate function. DMA would move received uart data to the address space...
Definition: uart.h:60
Definition: gpio_8258.h:49
Definition: gpio_8258.h:69
Definition: gpio_8258.h:80
#define reg_uart_status1
Definition: register_8258.h:342
void uart_dma_enable(unsigned char rx_dma_en, unsigned char tx_dma_en)
enable uart DMA mode
Definition: uart.h:59
UART_ParityTypeDef
Define parity type.
Definition: uart.h:48
Definition: uart.h:50
void uart_set_cts(unsigned char Enable, unsigned char Select, UART_CtsPinDef pin)
UART hardware flow control configuration. Configure CTS pin.
UART_RtsPinDef
Define UART RTS pin : A4 B3 B6 C0.
Definition: uart.h:111
static unsigned char uart_tx_is_busy(void)
This function servers to indicate Tx state.
Definition: uart.h:125
void uart_clear_parity_error(void)
This function clears parity error status once when it occurs.
Definition: gpio_8258.h:68
UART_RxPinDef
Define UART RX pin: A0 B0 B7 C3 C5 D6.
Definition: uart.h:87
Definition: uart.h:76
Definition: gpio_8258.h:67
Definition: uart.h:113
void uart_ndma_send_byte(unsigned char uartData)
uart send data function with not DMA method. variable uart_TxIndex,it must cycle the four registers 0...
UART_RTSModeTypeDef
Define UART RTS mode.
Definition: uart.h:66
#define BIT(n)
Definition: bsp.h:33
Definition: uart.h:58
Definition: uart.h:67
Definition: uart.h:88
Definition: uart.h:49
Definition: uart.h:42
Definition: gpio_8258.h:64
Definition: uart.h:40
Definition: uart.h:112
Definition: uart.h:89
Definition: gpio_8258.h:55
Definition: uart.h:79
Definition: uart.h:115
Definition: gpio_8258.h:62
Definition: gpio_8258.h:76
void uart_irq_enable(unsigned char rx_irq_en, unsigned char tx_irq_en)
config the irq of uart tx and rx
Definition: gpio_8258.h:45
unsigned char uart_is_parity_error(void)
This function determines whether parity error occurs once a packet arrives.
Definition: register_8258.h:147
unsigned char uart_ndmairq_get(void)
get the status of uart irq.
Definition: uart.h:101
Definition: register_8258.h:344
Definition: uart.h:102
#define reg_rst0
Definition: register_8258.h:143
volatile unsigned char uart_send_byte(unsigned char byte)
uart send data function, this function tell the DMA to get data from the RAM and start the DMA transm...
UART_StopBitTypeDef
Define the length of stop bit.
Definition: uart.h:57
UART_CtsPinDef
Define UART CTS pin : A3 B2 C4 D1.
Definition: uart.h:100
Definition: gpio_8258.h:57
UART_TxPinDef
Define UART TX pin:A2 B1 D0 D3 D7.
Definition: uart.h:75
Definition: uart.h:78
volatile unsigned char uart_dma_send(unsigned char *Addr)
uart send data function, this function tell the DMA to get data from the RAM and start the DMA transm...
void uart_set_rts(unsigned char Enable, UART_RTSModeTypeDef Mode, unsigned char Thresh, unsigned char Invert, UART_RtsPinDef pin)
UART hardware flow control configuration. Configure RTS pin.
void uart_init_baudrate(unsigned int Baudrate, unsigned int System_clock, UART_ParityTypeDef Parity, UART_StopBitTypeDef StopBit)
This function initializes the UART module.
Definition: uart.h:90
void uart_init(unsigned short g_uart_div, unsigned char g_bwpc, UART_ParityTypeDef Parity, UART_StopBitTypeDef StopBit)
This function initializes the UART module.
void uart_set_rts_level(unsigned char Polarity)
This function sets the RTS pin's level manually.
Definition: uart.h:68
Definition: uart.h:103
Definition: uart.h:92
Definition: uart.h:114
Definition: uart.h:41
Definition: gpio_8258.h:61
Definition: gpio_8258.h:48
Definition: uart.h:39
Definition: uart.h:51
Definition: gpio_8258.h:74
Definition: uart.h:104
Definition: gpio_8258.h:79