UART串口函数定义头文件
#ifndef _UART_REGISTERS
#define _UART_REGISTERS
/*UART 串行接口端口设置*/
ioport unsigned port0008;
#define INT1_RD port0008
ioport unsigned port8008;
#define UARTA_RHR port8008
ioport unsigned port8008;
#define UARTA_THR port8008
ioport unsigned port8009;
#define UARTA_IER port8009
ioport unsigned port800A;
#define UARTA_FCR port800A
ioport unsigned port800A;
#define UARTA_IIR port800A
ioport unsigned port800B;
#define UARTA_LCR port800B
ioport unsigned port800C;
#define UARTA_MCR port800C
ioport unsigned port800D;
#define UARTA_LSR port800D
ioport unsigned port800E;
#define UARTA_MSR port800E
ioport unsigned port800F;
#define UARTA_SPR port800F
ioport unsigned port8008;
#define UARTA_DLL port8008
ioport unsigned port8009;
#define UARTA_DLH port8009
ioport unsigned port800A;
#define UARTA_EFR port800A
ioport unsigned port800F;
#define UARTA_FIFORDY port800F
ioport unsigned port800C;
#define UARTA_XON1 port800C
ioport unsigned port800D;
#define UARTA_XON2 port800D
ioport unsigned port8010;
#define UARTB_RHR port8010
ioport unsigned port8010;
#define UARTB_THR port8010
ioport unsigned port8011;
#define UARTB_IER port8011
ioport unsigned port8012;
#define UARTB_FCR port8012
ioport unsigned port8012;
#define UARTB_IIR port8012
ioport unsigned port8013;
#define UARTB_LCR port8013
ioport unsigned port8014;
#define UARTB_MCR port8014
ioport unsigned port8015;
#define UARTB_LSR port8015
ioport unsigned port8016;
#define UARTB_MSR port8016
ioport unsigned port8017;
#define UARTB_SPR port8017
ioport unsigned port8010;
#define UARTB_DLL port8010
ioport unsigned port8011;
#define UARTB_DLH port8011
ioport unsigned port8012;
#define UARTB_EFR port8012
ioport unsigned port8017;
#define UARTB_FIFORDY port8017
ioport unsigned port8014;
#define UARTB_XON1 port8014
字符串长度头文件
ioport unsigned port8015;
#define UARTB_XON2 port8015
#endif
/*波特率设置*/
#define buad_1k2_10xE2
#define buad_1k2_h    0x04
#define buad_2k4_10x71
#define buad_2k4_10xh  0x02
#define buad_4k8_10x38
#define buad_4k8_h    0x01
#define buad_9k6_10x9C
#define buad_9k6_h    0x00
#define buad_19k2_1    0x4E
#define buad_19k2_h    0x00
#define buad_38k4_1    0x27
#define buad_38k4_h    0x00
/*UART控制字设置*/
#define data_w5  0x0000  /*数据长度为5*/
#define data_w6  0x0001  /*数据长度为6*/
#define data_w7  0x0002  /*数据长度为7*/
#define data_w8  0x0003  /*数据长度为8*/
#define data_s1  0x0000  /*数据停止位为1*/
#define data_s2  0x0004  /*数据停止位为1个半(数据长度为5)或2个*/
#define data_p  0x0008  /*设置较验位*/
#define data_po  0x0000  /*设置奇较验*/
#define data_pe  0x0010  /*设置偶较验*/
#define data_parity  0x0020  /*设置较验位*/
#define data_break  0x0040  /*设置当发送终止时,输出为低*/
#define uart_parity data_p+data_pe
#define LC_1_DLAB  0x0080
#define LC_0_DLAB  0x0000
/*FIFO设置*/
#define fifo_disable 0x0000 /*禁止fifo*/
#define fifo_enable 0x0001 /*使能fifo*/
#define fifo_rreset 0x0002 /*复位接收fifo*/
#define fifo_xreset 0x0004 /*复位发送fifo*/
#define fifo_reset 0x0007
#define fifo_dma 0x0008 /*设置DMA方式*/
#define fifo_txdip8 0x0000 /*fifo深度为8个*/
#define fifo_txdip16 0x0010 /*fifo深度为16个*/
#define fifo_txdip32 0x0020 /*fifo深度为32个*/
#define fifo_txdip56 0x0030 /*fifo深度为56个*/
#define fifo_txdip8 0x0000 /*fifo深度为8个*/
#define fifo_txdip16 0x0040 /*fifo深度为16个*/
#define fifo_txdip32 0x0080 /*fifo深度为56个*/
#define fifo_txdip56 0x00b0 /*fifo深度为60个*/
#define UartLoop  0x000b  /*设置自闭环方式*/
/*UART中断设置*/
#define uartint_rhr  0x0001  /*设置接受中断*/
#define uartint_thr  0x0002  /*设置发送中断*/
#define uartint_rls  0x0004  /*设置接受状态中断*/
#define uartint_msr  0x0008  /*设置MODEM中断*/
#define uart_sleep  0x0010  /*设置接受中断*/
#define uartint_xoff  0x0020  /*设置xxff中断*/
#define uartint_rts  0x0040  /*设置rts中断*/
#define uartint_cts  0x0080  /*设置cts中断*/
#define uart_enable  0x0008  /*使能UART中断*/
#define uartb_nodata  /*无接受数据*/
#define uartb_data  1 /*有正确数据*/

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。