00001 /* m68hc11/sio.h -- Utility methods to read/write the SIO 00002 Copyright 1999, 2000, 2003 Free Software Foundation, Inc. 00003 Written by Stephane Carrez (stcarrez@nerim.fr) 00004 00005 This file is part of GDB, GAS, and the GNU binutils. 00006 00007 GDB, GAS, and the GNU binutils are free software; you can redistribute 00008 them and/or modify them under the terms of the GNU General Public 00009 License as published by the Free Software Foundation; either version 00010 1, or (at your option) any later version. 00011 00012 GDB, GAS, and the GNU binutils are distributed in the hope that they 00013 will be useful, but WITHOUT ANY WARRANTY; without even the implied 00014 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00015 the GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this file; see the file COPYING. If not, write to the Free 00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 00020 00021 #ifndef _M68HC12_SIO_H 00022 #define _M68HC12_SIO_H 00023 00024 #include <sys/param.h> 00025 #include <sys/ports.h> 00026 00027 extern inline void 00028 serial_init (void) 00029 { 00030 _io_ports[M6812_SC0BD] = M6811_DEF_BAUD; 00031 00032 /* Setup character format 1 start, 8-bits, 1 stop. */ 00033 _io_ports[M6812_SC0CR1] = 0; 00034 00035 /* Enable reciever and transmitter. */ 00036 _io_ports[M6812_SC0CR2] = M6812_RE; 00037 } 00038 00039 /* Return != 0 if there is something to read on the serial line. */ 00040 extern inline unsigned char 00041 serial_receive_pending (void) 00042 { 00043 return _io_ports[M6812_SC0SR1] & M6812_RDRF; 00044 } 00045 00046 /* Wait until the SIO has finished to send the character. */ 00047 extern inline void 00048 serial_flush (void) 00049 { 00050 while (!(_io_ports[M6812_SC0SR1] & M6812_TDRE)) 00051 cop_optional_reset (); 00052 } 00053 00054 /* Send the character on the serial line. */ 00055 extern inline void 00056 serial_send (char c) 00057 { 00058 serial_flush (); 00059 _io_ports[M6812_SC0DRL] = c; 00060 _io_ports[M6812_SC0CR2] |= M6812_TE; 00061 } 00062 00063 /* Wait for a character on the serial line and return it. */ 00064 extern inline unsigned char 00065 serial_recv (void) 00066 { 00067 while (!(_io_ports[M6812_SC0SR1] & M6812_RDRF)) 00068 cop_optional_reset (); 00069 00070 return _io_ports[M6812_SC0DRL]; 00071 } 00072 00073 extern void serial_print (const char *msg); 00074 extern void serial_getline (char *buf); 00075 00076 #endif /* _M68HC11_SIO_H */ 00077