00001 /*! \file uart.c \brief UART driver for ARM ADuC7000 16450. */ 00002 //***************************************************************************** 00003 // 00004 // File Name : 'uart.c' 00005 // Title : UART driver for ARM ADuC7000 16450 00006 // Author : Pascal Stang - Copyright (C) 2005 00007 // Created : 2/5/2005 00008 // Revised : 2/5/2005 00009 // Version : 0.1 00010 // Target MCU : Analog Devices ARM ADuC7000 Series 00011 // Editor Tabs : 4 00012 // 00013 // This code is distributed under the GNU Public License 00014 // which can be found at http://www.gnu.org/licenses/gpl.txt 00015 // 00016 //***************************************************************************** 00017 00018 #include "aduc7026.h" 00019 00020 #include "global.h" 00021 #include "uart.h" 00022 00023 //! enable and initialize the uart 00024 void uartInit(uint16_t baud, uint32_t mode) 00025 { 00026 // set port pins for UART 00027 GP1CON = 0x11; 00028 00029 COMCON0 = 0x80; 00030 // COMDIV0 = 0x0C; 00031 COMDIV0 = 0x0B; 00032 COMDIV1 = 0x00; 00033 COMCON0 = 0x07; 00034 } 00035 00036 int uartSendByte(int data) 00037 { 00038 while(!(COMSTA0 & 0x20)) // wait for TX buffer to empty 00039 continue; // also either WDOG() or swap() 00040 00041 COMTX = (uint8_t)data; 00042 return (uint8_t)data; 00043 } 00044 00045 int uartGetByte(void) 00046 { 00047 if(COMSTA0 & 0x01) // check if character is available 00048 return COMRX; // return character 00049 return -1; 00050 } 00051