uart_main.c

来自「LPC2468串口驱动」· C语言 代码 · 共 61 行

C
61
字号
/*****************************************************************************
 *   uarttest.c:  main C entry file for NXP LPC23xx Family Microprocessors
 *
 *   Copyright(C) 2006, NXP Semiconductor
 *   All rights reserved.
 *
 *   History
 *   2006.07.13  ver 1.00    Prelimnary version, first Release
 *
******************************************************************************/
#include "LPC24xx.h"                        /* LPC23xx/24xx definitions */
#include "type.h"
#include "irq.h"
#include "..\uart_src\uart.h"	 
#include "stdio.h"
#include "string.h"
#include "timer.h"
#include "target.h"

extern volatile DWORD UART0Count;
extern volatile BYTE UART0Buffer[BUFSIZE];
extern volatile DWORD UART1Count;
extern volatile BYTE UART1Buffer[BUFSIZE];


/*****************************************************************************
**   Main Function  main()
*****************************************************************************/
int main (void)
{
	init_timer(0,TIME_INTERVAL);

    PINSEL1 = 0x00000000;

    UARTInit(0, 9600);	/* uart0设置 */
	UARTInit(1, 9600);	/* uart1设置 */

  while (1) 
  {			
	if ( UART0Count != 0 )
	{
	  U0IER = IER_THRE | IER_RLS;			/* Disable RBR */
	  UARTSend( 0, (BYTE *)UART0Buffer, UART0Count );
	  UART0Count = 0;
	  U0IER = IER_THRE | IER_RLS | IER_RBR;	/* Re-enable RBR */
	}
	if ( UART1Count != 0 )
	{
	  U1IER = IER_THRE | IER_RLS;			/* Disable RBR */
	  UARTSend( 1, (BYTE *)UART1Buffer, UART1Count );
	  UART1Count = 0;
	  U1IER = IER_THRE | IER_RLS | IER_RBR;	/* Re-enable RBR */
	}
  }
  return 0;
}

/*****************************************************************************
**                            End Of File
*****************************************************************************/

⌨️ 快捷键说明

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