include/asuro_defs.h

Go to the documentation of this file.
00001 /** @file
00002  * 
00003  * General definitions for ASURO (eg pin assignments).
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_DEF_H_
00020 #define ASURO_DEF_H_
00021 
00022 #define TRUE        1   ///< boolean TRUE
00023 #define FALSE       0   ///< boolean FALSE
00024 
00025 #define AS_ON       1   ///< general ON
00026 #define AS_OFF      0   ///< general OFF
00027 
00028 #define AS_GREEN    1   ///< status LED color green
00029 #define AS_RED      2   ///< status LED color red
00030 #define AS_YELLOW   3   ///< status LED color yellow
00031 
00032 #define AS_LEFT     0   ///< left motor
00033 #define AS_RIGHT    1   ///< right motor
00034 
00035 /** @name LED ports */
00036 //@{
00037 #define AS_PB_LED_GREEN (1 << PB0)  ///< PB0: port for green status LED
00038 #define AS_PD_LED_RED   (1 << PD2)  ///< PD2: port for red status LED
00039 #define AS_PD_LED_FRONT (1 << PD6)  ///< PD6: port for front LED
00040 #define AS_PC_LED_LBACK (1 << PC1)  ///< PC1: port for left back LED
00041 #define AS_PC_LED_RBACK (1 << PC0)  ///< PC0: port for right back LED
00042 #define AS_PB_LED_IRTX  (1 << PB3)  ///< PB3: port for IR transmitter LED
00043 #define AS_PD_LED_ODO   (1 << PD7)  ///< PD7: port for wheel IR-LEDs (for odometry)
00044 //@}
00045 
00046 /** @name Motor ports */
00047 //@{
00048 #define AS_DIR_FWD      (1 << PB5)                  ///< PB5/PD5: port for motor direction: rewind
00049 #define AS_DIR_RWD      (1 << PB4)                  ///< PB4/PD4: port for motor direction: rewind
00050 #define AS_DIR_FREE     (AS_DIR_FWD | AS_DIR_RWD)   ///< no change to motor direction
00051 #define AS_DIR_BREAK    0                           ///< stop motors
00052 #define AS_PB_MTR_PWM   ((1 << PB1) | (1 << PB2))   ///< PB1, PB2: ports for pulse width modulation
00053 //@}
00054 
00055 /** @name LED control */
00056 //@{
00057 #define AS_LED_GREEN_ON     PORTB |=  AS_PB_LED_GREEN
00058 #define AS_LED_GREEN_OFF    PORTB &= ~AS_PB_LED_GREEN
00059 #define AS_LED_RED_ON       PORTD |=  AS_PD_LED_RED
00060 #define AS_LED_RED_OFF      PORTD &= ~AS_PD_LED_RED
00061 #define AS_LED_YELLOW_ON    {AS_LED_GREEN_ON; AS_LED_RED_ON;}
00062 #define AS_LED_YELLOW_OFF   {AS_LED_GREEN_OFF; AS_LED_RED_OFF;}
00063 #define AS_LED_FRONT_ON     PORTD |=  AS_PD_LED_FRONT
00064 #define AS_LED_FRONT_OFF    PORTD &= ~AS_PD_LED_FRONT
00065 #define AS_LED_RBACK_ON     PORTC |=  AS_PC_LED_RBACK   ///< you have to be in AS_BACK_LED_MODE
00066 #define AS_LED_RBACK_OFF    PORTC &= ~AS_PC_LED_RBACK   ///< you have to be in AS_BACK_LED_MODE
00067 #define AS_LED_LBACK_ON     PORTC |=  AS_PC_LED_LBACK   ///< you have to be in AS_BACK_LED_MODE
00068 #define AS_LED_LBACK_OFF    PORTC &= ~AS_PC_LED_LBACK   ///< you have to be in AS_BACK_LED_MODE
00069 #define AS_LED_ODO_ON       PORTD |=  AS_PD_LED_ODO     ///< you have to be in AS_ODOMETRY_MODE
00070 #define AS_LED_ODO_OFF      PORTD &= ~AS_PD_LED_ODO     ///< you have to be in AS_ODOMETRY_MODE
00071 //@}
00072 
00073 /** @name Motors control */
00074 //@{
00075 #define AS_DIR_LEFT(dir)    PORTD = (PORTD & ~AS_DIR_FREE) | dir    ///< set direction of left motor
00076 #define AS_DIR_RIGHT(dir)   PORTB = (PORTB & ~AS_DIR_FREE) | dir    ///< set direction of right motor
00077 //@}
00078 
00079 /** @name IO direction */
00080 //@{
00081 #define AS_BACK_LED_MODE    DDRC |= (AS_PC_LED_LBACK | AS_PC_LED_RBACK)     // output, no odometry
00082 #define AS_ODOMETRY_MODE    DDRC &= ~(AS_PC_LED_LBACK | AS_PC_LED_RBACK)    // input, no back LEDs
00083 //@}
00084 
00085 /** @name Sensors */
00086 //@{
00087 #define AS_PD_SWITCHES  (1 << PD3)  ///< PD3: port for switches
00088 //@}
00089 
00090 /** @name Sensor control */
00091 //@{
00092 #define AS_SENS_SWITCHES_MODE   DDRD |= AS_PD_SWITCHES      ///< output, switches
00093 #define AS_SENS_SWITCHES_ON     PORTD |= AS_PD_SWITCHES     ///< switch sensor on
00094 #define AS_SENS_SWITCHES_OFF    PORTD &= ~AS_PD_SWITCHES    ///< switch sensor off
00095 #define AS_SENS_SWITCH_1    (1 << 5)
00096 #define AS_SENS_SWITCH_2    (1 << 4)
00097 #define AS_SENS_SWITCH_3    (1 << 3)
00098 #define AS_SENS_SWITCH_4    (1 << 2)
00099 #define AS_SENS_SWITCH_5    (1 << 1)
00100 #define AS_SENS_SWITCH_6    1
00101 //@}
00102 
00103 /** @name ADC ports for analogue sensors */
00104 //@{
00105 #define AS_MUX_SWITCHES     (1 << MUX2)                 ///< ADC port for switches
00106 #define AS_MUX_LINE_LEFT    ((1 << MUX0) | (1 << MUX1)) ///< ADC port for left line photo transistor
00107 #define AS_MUX_LINE_RIGHT   (1 << MUX1)                 ///< ADC port for right line photo transistor
00108 #define AS_MUX_ODO_LEFT     (1 << MUX0)                 ///< ADC port for left odometry IR photo transistor
00109 #define AS_MUX_ODO_RIGHT    0                           ///< ADC port for right odometry IR photo transistor
00110 //@}
00111 
00112 /** @name A/D conversion control */
00113 //@{
00114 #define AS_ADC_START        ADCSRA |= (1 << ADSC)   ///< start A/D conversion
00115 #define AS_ADC_STOP         ADCSRA |= (1 << ADIF)   ///< stop A/D conversion (clear finished flag)
00116 #define AS_ADC_FINISHED     (ADCSRA & (1 << ADIF))  ///< ADC finished
00117 #define AS_ADC_VALUE        (ADCL + (ADCH << 8))    ///< encoded analogue value
00118 //@}
00119 
00120 /** @name Others */
00121 //@{
00122 #define AS_PD_IRRX      (1 << PD0)          ///< input port for IR receiver (IC2)
00123 #define AS_IRRX_SAMPLE  (PIND & AS_PD_IRRX) ///< returns sample of current bit received by IC2
00124 //@}
00125 
00126 #endif /*ASURO_DEF_H_*/

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