Serial.c
资源名称:ISP.rar [点击查看]
上传用户:cchhkk2004
上传日期:2022-05-10
资源大小:78k
文件大小:2k
源码类别:
VxWorks
开发平台:
Others
- /******************************************************************************/
- /* SERIAL.C: Low Level Serial Routines */
- /******************************************************************************/
- /* This file is part of the uVision/ARM development tools. */
- /* Copyright (c) 2005-2006 Keil Software. All rights reserved. */
- /* This software may only be used under the terms of a valid, current, */
- /* end user licence from KEIL for a compatible version of KEIL software */
- /* development tools. Nothing else gives you the right to use this software. */
- /******************************************************************************/
- #include <LPC21xx.H> /* LPC21xx definitions */
- #include "main.h"
- #define CR 0x0D
- #ifdef USE_UART0_MSG //UART0
- /* implementation of putchar (also used by printf function to output data) */
- int sendchar (int ch) { /* Write character to Serial Port */
- if (ch == 'n') {
- while (!(U0LSR & 0x20));
- U0THR = CR; /* output CR */
- }
- while (!(U0LSR & 0x20));
- return (U0THR = ch);
- }
- int getkey (void) { /* Read character from Serial Port */
- while (!(U0LSR & 0x01));
- return (U0RBR);
- }
- #else //UART1
- /* implementation of putchar (also used by printf function to output data) */
- int sendchar (int ch) { /* Write character to Serial Port */
- if (ch == 'n') {
- while (!(U1LSR & 0x20));
- U1THR = CR; /* output CR */
- }
- while (!(U1LSR & 0x20));
- return (U1THR = ch);
- }
- int getkey (void) { /* Read character from Serial Port */
- while (!(U1LSR & 0x01));
- return (U1RBR);
- }
- #endif