sio.h

00001 /* asm-m68hc11/sio.h -- Utility methods to read/write the SIO
00002    Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
00003    Written by Stephane Carrez (stcarrez@worldnet.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 _M68HC11_SIO_H
00022 #define _M68HC11_SIO_H
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00033 
00043 extern inline void
00044 serial_init (void)
00045 {
00046   _io_ports[M6811_BAUD] = M6811_DEF_BAUD;
00047 
00048   /* Setup character format 1 start, 8-bits, 1 stop.  */
00049   _io_ports[M6811_SCCR1] = 0;
00050 
00051   /* Enable reciever and transmitter.  */
00052   _io_ports[M6811_SCCR2] = 0xc;
00053 }
00054 
00061 extern inline unsigned char
00062 serial_receive_pending (void)
00063 {
00064   return _io_ports[M6811_SCSR] & M6811_RDRF;
00065 }
00066 
00074 extern inline void
00075 serial_flush (void)
00076 {
00077   while (!(_io_ports[M6811_SCSR] & M6811_TDRE))
00078     cop_optional_reset ();
00079 }
00080 
00093 extern inline void
00094 serial_send (char c)
00095 {
00096   serial_flush ();
00097   _io_ports[M6811_SCDR] = c;
00098   _io_ports[M6811_SCCR2] |= M6811_TE;
00099 }
00100 
00111 extern inline unsigned char
00112 serial_recv (void)
00113 {
00114   while (!(_io_ports[M6811_SCSR] & M6811_RDRF))
00115     cop_optional_reset ();
00116 
00117   return _io_ports[M6811_SCDR];
00118 }
00119 
00122 #ifdef __cplusplus
00123 };
00124 #endif
00125 #endif /* _M68HC11_SIO_H */
00126