📄 uart.h
字号:
/**
* \addtogroup hw
* @{
*/
/**
* \file
* \brief uart module header file
* \author Jane Gao <jgao@fameg.com>
*/
/*
******************************************************************************
*
Copyright (c) 2006 FameG Shanghai, Inc. All rights reserved.
*
This is unpublished proprietary source code of FameG Shanghai, Inc.
*
The copyright notice above does not evidence any actual or intended
*
publication of such source code.
******************************************************************************
*/
/*
******************************************************************************
*
Project: FS8610 application
*
Filename: uart.h
*
Date: 27/10/06
*
Purpose: Uart functions for L4MCU (Keil C Compiler)
*
Author: Jane Gao
******************************************************************************
*/
#ifndef _UART_H_
#define _UART_H_
//#include "kernel/config.h"
#include "kernel/system.h"
#include "hw/delay.h"
#include "user_config.h"
#if INCLUDE_UART_CONTROL
/**************** Macro Definition ****************/
#define PRINT(c); {TI=1; printf c; wait_1us(100); TI= 0;}
#define DATA_7BITS 7
#define DATA_8BITS 8
#define XON 0x11 //ASCII 17
#define XOFF 0x13 //ASCII 19
#define UART_BUF_LEN 256
#define UART_LEAST_LEN 32
#define P_EVEN 1
#define P_ODD 2
#define P_NONE 3
#define F_SOFTWARE 1
#define F_HARDWARE 2
#define F_NONE 3
//for hw flowctrl implementation
#define ON 0
#define OFF 1
//if the hw structure changes, we can use function pointer
#define RTS_SIG_OFF(); {P0_0 = OFF;}
#define RTS_SIG_ON(); {P0_0 = ON;}
#define GET_RTS_SIG() P0_0
#define GET_CTS_SIG() get_CTS_signal()
#if 0//as device
//#define GET_CTS_SIG() P0_2
//as host
//#define GET_CTS_SIG() P0_4
#endif
//end of macro for hw flowctrl
/**************** Parameter Definition ****************/
extern UINT8 XDATA transmit_allowed;
extern UINT8 XDATA receive_allowed;
extern UINT8 XDATA send_xon_xoff;
extern UINT8 XDATA UART_TX_BUF[UART_BUF_LEN];
extern UINT8 XDATA UART_RX_BUF[UART_BUF_LEN];
extern UINT8 XDATA uart_tx_h, uart_tx_t;
extern UINT8 XDATA uart_rx_h, uart_rx_t;
typedef struct _UART_CONFIG {
/* serial baud rate*/
UINT32 baudrate;
/* data bits*/
UINT8 databits;
/* parity: P_EVEN, P_ODD, P_NONE */
UINT8 parity;
/* flow control: F_SOFTWARE,F_ HARDWARE, F_NONE */
UINT8 flowctl;
}uart_conf_T;
extern uart_conf_T uart_conf;
/*************** Function Definition *******************/
void uart_Init(void);
//UINT16 get_uart_tx_freesize(void);
//UINT16 get_uart_rx_freesize(void);
//void uart_send_XON(void);
//void uart_send_XOFF(void);
UINT8 uart_rxbuf_not_empty(void);
void purge_uart_rxbuf(void);
void purge_uart_txbuf(void);
void uart_putchar(UINT8 ch);
void uart_puts(UINT8 *str);
UINT8 uart_getkey(void);
UINT8 uart_getchar(void);
void uart_gets(UINT8 *str);
void uart_getstr(UINT8 *str, UINT16 len);
void uart_int_handler(void);
void uart_check_hard_flowctrl(void);
#else
#define PRINT(c); {EA=0;printf c;EA=1;}
#define uart_getkey() _getkey()
#define uart_getstr(c , l) gets(c , l)
#define uart_putchar(c) putchar(c)
#define uart_puts(c) puts(c)
void uart_Init(void);
UINT8 uart_getchar(void);
#endif /* INCLUDE_UART_CONTROL*/
#endif /* __UART_H__ */
/** @} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -