bot.h

00001 /* 
00002    Copyright (C) 2001 Free Software Foundation, Inc.
00003    Written by Duane Gustavus (duane@denton.com)
00004 
00005 This file is free software; you can redistribute it and/or modify it
00006 under the terms of the GNU General Public License as published by the
00007 Free Software Foundation; either version 2, or (at your option) any
00008 later version.
00009 
00010 In addition to the permissions in the GNU General Public License, the
00011 Free Software Foundation gives you unlimited permission to link the
00012 compiled version of this file with other programs, and to distribute
00013 those programs without any restriction coming from the use of this
00014 file.  (The General Public License restrictions do apply in other
00015 respects; for example, they cover modification of the file, and
00016 distribution when not linked into another program.)
00017 
00018 This file is distributed in the hope that it will be useful, but
00019 WITHOUT ANY WARRANTY; without even the implied warranty of
00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 General Public License for more details.
00022 
00023 You should have received a copy of the GNU General Public License
00024 along with this program; see the file COPYING.  If not, write to
00025 the Free Software Foundation, 59 Temple Place - Suite 330,
00026 Boston, MA 02111-1307, USA.  */
00027 
00028 #ifndef LIBBOT_H
00029 #define LIBBOT_H
00030 
00031 #define DIGITAL_PORT *(unsigned char volatile *)0x7000
00032 #define MAXSPEED 30
00033 #define MINSPEED -30
00034 #define LEFT_MTR 0x10
00035 #define RIGHT_MTR 0x40
00036 #define LEFT_REVERSE 0x01
00037 #define RIGHT_REVERSE 0x04
00038 
00039 /* State word  AAAA AAAA BBBB BBBB
00040                ||||    |   || ||||
00041 DSW1-----------+|||    |   || ||||
00042 DSW2------------+||    |   || ||||
00043 DSW3-------------+|    |   || ||||
00044 DSW4--------------+    |   || ||||
00045 SERVO------------------+   || ||||
00046 IR ------------------------+| ||||
00047 BUMPER ---------------------+ ||||
00048 ACTIVE mode-------------------+|||
00049 PLIR --------------------------+||
00050 PHOTO --------------------------+|
00051 STATUS report--------------------+
00052 */
00053 #define DSW1 0x8000
00054 #define DSW2 0x4000
00055 #define DSW3 0x2000
00056 #define DSW4 0x1000
00057 
00058 #define SERVO 0x100
00059 #define IR 0x20
00060 #define BUMPER 0x10
00061 #define ACTIVE 0x08
00062 #define PLIR 0x04
00063 #define PHOTO 0x02
00064 #define STATUS 0x01
00065 
00066 /* analog port mappings */
00067 #define DIP1 analog[16]
00068 #define DIP2 analog[17]
00069 #define DIP3 analog[18]
00070 #define DIP4 analog[19]
00071 #define FROB1 analog[20]
00072 #define FROB2 analog[15]
00073 /* photo sensors */
00074 #define PHOTOL analog[0]
00075 #define PHOTOR analog[1]
00076 
00077 extern char *sprintf();
00078 extern void init_buffered_io();
00079 extern unsigned char sci_putc(char);
00080 extern unsigned char sci_getc();
00081 extern int serial_print();
00082 extern unsigned char chk_serial_inbuf();
00083 extern void init_sysclock(void);
00084 extern long sysclock;
00085 extern void init_analog (void);
00086 extern unsigned char read_analog (unsigned char);
00087 extern volatile unsigned char analog[];
00088 extern void init_encoders();
00089 extern volatile int l_encoder, Lticks, r_encoder, Rticks;
00090 extern volatile char c_encoder;
00091 extern void init_ir();
00092 extern volatile int ir_detect_lt, ir_detect_rt;
00093 extern void init_poll_sensors();
00094 extern volatile int Detect, Bcount;
00095 extern void start_speed_ctl(), stop_speed_ctl();
00096 extern void init_pwm(void);
00097 extern volatile int Lspeed, Rspeed, Lmtr, Rmtr, av_velo, run_speed;
00098 extern volatile unsigned char digital_shadowbits, expbd_shadowbits;
00099 extern unsigned char choose_button(), escape_button();
00100 extern volatile unsigned short le_sample, re_sample;
00101 extern void pwm_on(void), pwm_off(void);
00102 extern void speed_ctl();
00103 extern void led0_on(), led1_on(), led0_off(), led1_off();
00104 
00105 #endif