ports.h

00001 /* m68hc11/ports.h -- Definition of 68HC11 ports
00002    Copyright 1999, 2000 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_PORTS_H
00022 #define _M68HC11_PORTS_H
00023 
00024 #include <asm-m68hc11/ports_def.h>
00025 
00026 extern inline unsigned short
00027 get_timer_counter (void)
00028 {
00029   return ((unsigned volatile short*) &_io_ports[M6811_TCTN_H])[0];
00030 }
00031 
00032 extern inline void
00033 set_timer_counter (unsigned short value)
00034 {
00035   ((unsigned volatile short*) &_io_ports[M6811_TCTN_H])[0] = value;
00036 }
00037 
00038 extern inline unsigned short
00039 get_input_capture_1 (void)
00040 {
00041   return ((unsigned volatile short*) &_io_ports[M6811_TIC1_H])[0];
00042 }
00043 
00044 extern inline void
00045 set_input_capture_1 (unsigned short value)
00046 {
00047   ((unsigned volatile short*) &_io_ports[M6811_TIC1_H])[0] = value;
00048 }
00049 
00050 extern inline unsigned short
00051 get_input_capture_2 (void)
00052 {
00053   return ((unsigned volatile short*) &_io_ports[M6811_TIC2_H])[0];
00054 }
00055 
00056 extern inline void
00057 set_input_capture_2 (unsigned short value)
00058 {
00059   ((unsigned volatile short*) &_io_ports[M6811_TIC2_H])[0] = value;
00060 }
00061 
00062 extern inline unsigned short
00063 get_input_capture_3 (void)
00064 {
00065   return ((unsigned volatile short*) &_io_ports[M6811_TIC3_H])[0];
00066 }
00067 
00068 extern inline void
00069 set_input_capture_3 (unsigned short value)
00070 {
00071   ((unsigned volatile short*) &_io_ports[M6811_TIC3_H])[0] = value;
00072 }
00073 
00074 /* Get output compare 16-bit register.  */
00075 extern inline unsigned short
00076 get_output_compare_1 (void)
00077 {
00078   return ((unsigned volatile short*) &_io_ports[M6811_TOC1_H])[0];
00079 }
00080 
00081 extern inline void
00082 set_output_compare_1 (unsigned short value)
00083 {
00084   ((unsigned volatile short*) &_io_ports[M6811_TOC1_H])[0] = value;
00085 }
00086 
00087 extern inline unsigned short
00088 get_output_compare_2 (void)
00089 {
00090   return ((unsigned volatile short*) &_io_ports[M6811_TOC2_H])[0];
00091 }
00092 
00093 extern inline void
00094 set_output_compare_2 (unsigned short value)
00095 {
00096   ((unsigned volatile short*) &_io_ports[M6811_TOC2_H])[0] = value;
00097 }
00098 
00099 extern inline unsigned short
00100 get_output_compare_3 (void)
00101 {
00102   return ((unsigned volatile short*) &_io_ports[M6811_TOC3_H])[0];
00103 }
00104 
00105 extern inline void
00106 set_output_compare_3 (unsigned short value)
00107 {
00108   ((unsigned volatile short*) &_io_ports[M6811_TOC3_H])[0] = value;
00109 }
00110 
00111 extern inline unsigned short
00112 get_output_compare_4 (void)
00113 {
00114   return ((unsigned volatile short*) &_io_ports[M6811_TOC4_H])[0];
00115 }
00116 
00117 extern inline void
00118 set_output_compare_4 (unsigned short value)
00119 {
00120   ((unsigned volatile short*) &_io_ports[M6811_TOC4_H])[0] = value;
00121 }
00122 
00123 extern inline unsigned short
00124 get_output_compare_5 (void)
00125 {
00126   return ((unsigned volatile short*) &_io_ports[M6811_TOC5_H])[0];
00127 }
00128 
00129 extern inline void
00130 set_output_compare_5 (unsigned short value)
00131 {
00132   ((unsigned volatile short*) &_io_ports[M6811_TOC5_H])[0] = value;
00133 }
00134 
00135 
00136 /* Set the board in the expanded mode to get access to external bus.  */
00137 extern inline void
00138 set_bus_expanded (void)
00139 {
00140   _io_ports[M6811_HPRIO] |= M6811_MDA;
00141 }
00142 
00143 
00144 /* Set the board in single chip mode.  */
00145 extern inline void
00146 set_bus_single_chip (void)
00147 {
00148   _io_ports[M6811_HPRIO] &= ~M6811_MDA;
00149 }
00150 
00151 /* Reset the COP.  */
00152 extern inline void
00153 cop_reset (void)
00154 {
00155   _io_ports[M6811_COPRST] = 0x55;
00156   _io_ports[M6811_COPRST] = 0xAA;
00157 }
00158 
00159 extern inline void
00160 cop_optional_reset (void)
00161 {
00162 #if defined(M6811_USE_COP) && M6811_USE_COP == 1
00163   cop_reset ();
00164 #endif
00165 }
00166 
00167 /* Acknowledge the timer interrupt.  */
00168 extern inline void
00169 timer_acknowledge (void)
00170 {
00171   _io_ports[M6811_TFLG2] = M6811_RTIF;
00172 }
00173 
00174 /* Initialize the timer.  */
00175 extern inline void
00176 timer_initialize_rate (unsigned char divisor)
00177 {
00178   _io_ports[M6811_TMSK2] = M6811_RTII | divisor;
00179 }
00180 
00181 #endif /* _M68HC11_PORTS_H */
00182