⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib_lpc_uart.h

📁 使用embest IDE开发工具开发的基于LPC2294 的触摸屏开发
💻 H
字号:


/*
***********************************************************************

       Embest Info&Tech Co., Ltd.  All rights reserved.
                     www.embedinfo.com

***********************************************************************

---------------- file information -------------------------------------

file name: lib_lpc_uart.h
version  : v0
author   : peter pan / panqan@hotmail.com
	                   panqian@embedinfo.com
	       zhangxiuquan
	       
begin    : 2006-02-10
finish   : 2006-02-10
define   : uart init and operation lib head file

notes    :

---------------- modify information -----------------------------------
version  :
modify   :
begin    :
finish   :
define   :
-----------------------------------------------------------------------
*/


/*-------------------------------------------------------------------*/
/*                       compiler condition                          */
/*---------------------------------------------------------------- --*/
#ifndef lpc_lib_uart
	#define lpc_lib_uart


/*-------------------------------------------------------------------*/
/*                       include files                               */
/*---------------------------------------------------------------- --*/

#include	"..\..\..\com\type_redefine.h"
#include	"..\..\..\com\register_lpc22xx.h"


#include   "..\..\..\com\lib_lpc\lib_lpc_pll\lib_lpc_pll.h"
#include    "..\..\..\com\lib_22eb06\module_control\lib_22eb06_mc.h"


#include <stdarg.h>
/*
#include <string.h>
#include <stdio.h>
#include <ctype.h>
/*
*/

/*-------------------------------------------------------------------*/
/*                      constant define                              */
/*---------------------------------------------------------------- --*/

// p0 0,1 to uart0 port define in PINSEL0

#define 	P0_0_TXD0_PINSEL0_V 		(0x01)
#define 	P0_1_RXD0_PINSEL0_V 		(0x01<<2)

#define 	P0_0_TXD0_PINSEL0_M 	    (0x03)
#define 	P0_1_RXD0_PINSEL0_M 	    (0x03<<2)

#define 	UART0_EN_PINSEL0_V 		    (P0_0_TXD0_PINSEL0_V+P0_1_RXD0_PINSEL0_V)
#define 	UART0_EN_PINSEL0_M 	        (P0_0_TXD0_PINSEL0_M+P0_1_RXD0_PINSEL0_M)

// p0 8~15 to uart1 port define in PINSEL0
#define     P0_8_TXD1_PINSEL0_V         (0x01<<16)
#define     P0_8_RXD1_PINSEL0_V         (0x01<<18)
#define     P0_8_RTS1_PINSEL0_V         (0x01<<20)
#define     P0_8_CTS1_PINSEL0_V         (0x01<<22)
#define     P0_8_DSR1_PINSEL0_V         (0x01<<24)
#define     P0_8_DTR1_PINSEL0_V         (0x01<<26)
#define     P0_8_CD1_PINSEL0_V          (0x01<<28)
#define     P0_8_RI1_PINSEL0_V          (0x01<<30)

#define     P0_8_TXD1_PINSEL0_M         (0x03<<16)
#define     P0_8_RXD1_PINSEL0_M         (0x03<<18)
#define     P0_8_RTS1_PINSEL0_M         (0x03<<20)
#define     P0_8_CTS1_PINSEL0_M         (0x03<<22)
#define     P0_8_DSR1_PINSEL0_M         (0x03<<24)
#define     P0_8_DTR1_PINSEL0_M         (0x03<<26)
#define     P0_8_CD1_PINSEL0_M          (0x03<<28)
#define     P0_8_RI1_PINSEL0_M          (0x03<<30)

#define     UART1_EN_PINSEL0_V          (P0_8_TXD1_PINSEL0_V+P0_8_RXD1_PINSEL0_V\
                                        +P0_8_RTS1_PINSEL0_V+P0_8_CTS1_PINSEL0_V\
                                        +P0_8_DSR1_PINSEL0_V+P0_8_DTR1_PINSEL0_V\
                                        +P0_8_CD1_PINSEL0_V+P0_8_RI1_PINSEL0_V)

#define     UART1_EN_PINSEL0_M          ((P0_8_TXD1_PINSEL0_M+P0_8_RXD1_PINSEL0_M\
                                        +P0_8_RTS1_PINSEL0_M+P0_8_CTS1_PINSEL0_M\
                                        +P0_8_DSR1_PINSEL0_M+P0_8_DTR1_PINSEL0_M\
                                        +P0_8_CD1_PINSEL0_M+P0_8_RI1_PINSEL0_M))

/*-------------------------------------------------------------------*/
/*                       variable define                             */
/*-------------------------------------------------------------------*/
typedef enum {
	          uart_c0=0,
	          uart_c1,
	         } uart_channel;
typedef enum {
	          bdr_115200=0,
	          bdr_57600,
	          bdr_38400,
	          bdr_19200,
	         } baudrate_v;
typedef enum {
	          wdl_5=0,
	          wdl_6,
	          wdl_7,
	          wdl_8,
	         } word_length_v;
typedef enum {
	          spb_1=0,
	          spb_2,
	         } stop_bit_v;
typedef enum {
	          parity_g_dis=0,
	          parity_g_en,
	         } parity_generation_en_v;
typedef enum {
	          parity_s_00oddp=0,
	          parity_s_01evenp,
	          parity_s_10force1,
	          parity_s_11force0,
	         } parity_select_v;
typedef enum {
	          break_tr_dis=0,
	          break_tr_en,
	         } break_transmission_v;
typedef enum {
	          fifo_dis=0,
	          fifo_en,
	         } fifo_en_v;

#define uart0_INT_RBR_en_U0IER_V        0x01
#define uart0_INT_THRE_en_U0IER_V      (0x01<<1)
#define uart0_INT_Rx_line_en_U0IER_V   (0x01<<1)

#define uart0_INT_RBR_dis_U0IER_V       0x0
#define uart0_INT_THRE_dis_U0IER_V      0x0
#define uart0_INT_Rx_line_dis_U0IER_V   0x0

#define uart0_int_data_dis_all          0x0


// Uart line control register bit descriptions
#define WORD_LENTH_U0LCR_M             (0x3)
#define STOP_BIT_SEL_U0LCR_M           (0x1<<2)
#define PARITY_ENBALE_U0LCR_M          (0x1<<3)
#define PARITY_SEL_U0LCR_M             (0x3<<4)
#define BREAK_CONTROL_U0LCR_M          (0x1<<6)
#define DLAB_U0LCR_M                   (0x1<<7)


// Uart line control register bit descriptions
#define WORD_LENTH_U1LCR_M             (0x3)
#define STOP_BIT_SEL_U1LCR_M           (0x1<<2)
#define PARITY_ENBALE_U1LCR_M          (0x1<<3)
#define PARITY_SEL_U1LCR_M             (0x3<<4)
#define BREAK_CONTROL_U1LCR_M          (0x1<<6)
#define DLAB_U1LCR_M                   (0x1<<7)



/*-------------------------------------------------------------------*/
/*                       local function declare                      */
/*-------------------------------------------------------------------*/
void  uart_io_en(uart_channel uart_channel_01);
INT32U  uart_init(uart_channel uart_channel_01, INT32U uart_baudrate,
                  word_length_v uart_word_length, stop_bit_v uart_spb,
                  parity_generation_en_v uart_pg, parity_select_v uart_ps,
                  break_transmission_v uart_btr, fifo_en_v uart_fifo,
                  INT32U int_set_v
                 );
void uart_send_char(uart_channel uart_channel_01, INT8U data);
void uart_send_string(uart_channel uart_channel_01, INT8U *str);
INT8U uart_get_char(uart_channel uart_channel_01);
INT8U uart_get_key(uart_channel uart_channel_01);
void uart_get_string(uart_channel uart_channel_01, INT8U *char_top);
void uart_printf(uart_channel uart_channel_01, INT8U *fmt,...);


#endif







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -