include/asuro.h

Go to the documentation of this file.
00001 /**@file 
00002  * 
00003  * Interface to ASURO's devices. The implentations of these are target-specific.
00004  * 
00005  * @author Denis Martin
00006  * 
00007  * This program is free software; you can redistribute it and/or modify it under
00008  * the terms of the GNU General Public License as published by the Free Software
00009  * Foundation; either version 2 of the License, or (at your option) any later
00010  * version.
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
00014  * details. You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation, Inc.,
00016  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef ASURO_H_
00020 #define ASURO_H_
00021 
00022 #ifdef UNIX
00023 #include "asuro_unix.h"
00024 #endif
00025 
00026 #ifdef AVR
00027 #include "asuro_avr.h"
00028 #endif
00029 
00030 #include "asuro_defs.h"
00031 
00032 /** @name Type definitions */
00033 //@{
00034 /**
00035  * User ISRs have to have this signature.
00036  */
00037 typedef void (*AS_UserIsr)(void);
00038 //@}
00039 
00040 /** @name Global variables */
00041 //@{
00042 /**
00043  * Set to true, when one or more of the switches are pressed. Note that you
00044  * have to turn on the concerned interrupt using AS_SensSwitchesInterruptOn()
00045  */
00046 extern volatile char AS_sensSwitched;
00047 
00048 /**
00049  * Set to true if the interrupt for switches is enabled. If it is not enabled,
00050  * you may activate it by using AS_SensSwitchesInterruptOn().
00051  */
00052 extern volatile char AS_sensSwitchesOn;
00053 
00054 /**
00055  * User defined ISR for INT1 (switches). Assign a function to this global 
00056  * variable to get your own ISR called.
00057  */
00058 extern volatile AS_UserIsr AS_UserIsrInterrupt1;
00059 //@}
00060 
00061 /** @name Main functions */
00062 //@{
00063 /**
00064  * Do some initialization stuff
00065  */
00066 inline void AS_Init(void);
00067 
00068 /**
00069  * Return the number of system clock ticks elapsed since system start. Remember
00070  * that it might overflow.
00071  * 
00072  * @return Number of system clock ticks
00073  */
00074 inline unsigned long AS_GetClockTicks(void);
00075 
00076 /**
00077  * Return the time in milliseconds elapsed since system start. Remember that it
00078  * might overflow.
00079  * 
00080  * @return System time in milliseconds
00081  */
00082 inline unsigned long AS_GetSysTime(void);
00083 
00084 /**
00085  * Halt execution for a given time in milliseconds. Note: a value of zero will
00086  * not return immediately as you might expect. Instead, the execution is halted
00087  * for over a minute!
00088  * 
00089  * @param time  Time in milliseconds to sleep
00090  */
00091 void AS_Sleep(unsigned int time);
00092 
00093 /**
00094  * Set status LED to the specified color. Note that you can also call 
00095  * AS_LED_GREEN_ON, AS_LED_GREEN_OFF, AS_LED_RED_ON, AS_LED_RED_OFF, 
00096  * AS_LED_YELLOW_ON and AS_LED_YELLOW_OFF directly.
00097  * 
00098  * @param color Color (possible values: AS_GREEN, AS_RED, AS_YELLOW)
00099  */
00100 inline void AS_StatusLED(unsigned char color);
00101 
00102 /**
00103  * Set front LED on or off. Note that you can also call AS_LED_FRONT_ON and 
00104  * AS_LED_FRONT_OFF directly.
00105  * 
00106  * @param status    AS_ON or AS_OFF
00107  */
00108 inline void AS_FrontLED(unsigned char status);
00109 
00110 /**
00111  * Set back LEDs on or off. Note that you can also call AS_LED_RBACK_ON, 
00112  * AS_LED_RBACK_OFF, AS_LED_LBACK_ON and AS_LED_LBACK_OFF directly, but you have
00113  * to switch to AS_BACK_LED_MODE before.
00114  * 
00115  * @param left      Status for left back LED (AS_ON or AS_OFF)
00116  * @param right Status for right back LED (AS_ON or AS_OFF)
00117  */
00118 inline void AS_BackLED(unsigned char left, unsigned char right);
00119 
00120 /**
00121  * Set speed of left and right motor. AS_MotorDir() before to specifiy the
00122  * direction.
00123  * 
00124  * @param left_speed    Speed of left motor (0..255)
00125  * @param right_speed   Speed of right motor (0..255)
00126  */
00127 inline void AS_MotorSpeed(unsigned char left_speed, unsigned char right_speed);
00128 
00129 /**
00130  * Set rotation direction of left and right motor. Possible values are
00131  * AS_DIR_FWD (forward), AS_DIR_RWD (backward), AS_DIR_BREAK (stop) and
00132  * AS_DIR_FREE (no change to direction).
00133  * 
00134  * @param left_dir  Direction for left motor.
00135  * @param right_dir Direction for right motor.
00136  */
00137 inline void AS_MotorDir(unsigned char left_dir, unsigned char right_dir);
00138 
00139 /**
00140  * Send data via IR serial interface.
00141  * 
00142  * @param data      Pointer to data buffer to send.
00143  * @param length    Size of data in bytes.
00144  */
00145 void AS_SerWrite(unsigned char *data, unsigned char length);
00146 
00147 /**
00148  * Turn on interrupt for activity on switches. The user ISR assigned to 
00149  * AS_UserIsrInterrupt1 will be called if any of the switches was pushed.
00150  */
00151 void AS_SensSwitchesInterruptOn(void);
00152 
00153 /**
00154  * Disable interrupt for activity on switches.
00155  */
00156 inline void AS_SensSwitchesInterruptOff(void);
00157 
00158 /**
00159  * Read status of switches. The bits of the returned value represent the 
00160  * switches currently pressed. The mapping is the following:
00161  * 
00162  * bit0 = K6,
00163  * bit1 = K5,
00164  * bit2 = K4,
00165  * bit3 = K3,
00166  * bit4 = K2,
00167  * bit5 = K1
00168  * 
00169  * @return  A value whose bits represent the switches currently pressed (see 
00170  *          above)
00171  */
00172 unsigned char AS_SensSwitchesRead(void);
00173 
00174 //@}
00175 
00176 #endif /*ASURO_H_*/

Generated on Fri May 12 10:11:15 2006 for simsuro by  doxygen 1.4.6