00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef ASURO_DEF_H_
00020 #define ASURO_DEF_H_
00021
00022 #define TRUE 1
00023 #define FALSE 0
00024
00025 #define AS_ON 1
00026 #define AS_OFF 0
00027
00028 #define AS_GREEN 1
00029 #define AS_RED 2
00030 #define AS_YELLOW 3
00031
00032 #define AS_LEFT 0
00033 #define AS_RIGHT 1
00034
00035
00036
00037 #define AS_PB_LED_GREEN (1 << PB0)
00038 #define AS_PD_LED_RED (1 << PD2)
00039 #define AS_PD_LED_FRONT (1 << PD6)
00040 #define AS_PC_LED_LBACK (1 << PC1)
00041 #define AS_PC_LED_RBACK (1 << PC0)
00042 #define AS_PB_LED_IRTX (1 << PB3)
00043 #define AS_PD_LED_ODO (1 << PD7)
00044
00045
00046
00047
00048 #define AS_DIR_FWD (1 << PB5)
00049 #define AS_DIR_RWD (1 << PB4)
00050 #define AS_DIR_FREE (AS_DIR_FWD | AS_DIR_RWD)
00051 #define AS_DIR_BREAK 0
00052 #define AS_PB_MTR_PWM ((1 << PB1) | (1 << PB2))
00053
00054
00055
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
00066 #define AS_LED_RBACK_OFF PORTC &= ~AS_PC_LED_RBACK
00067 #define AS_LED_LBACK_ON PORTC |= AS_PC_LED_LBACK
00068 #define AS_LED_LBACK_OFF PORTC &= ~AS_PC_LED_LBACK
00069 #define AS_LED_ODO_ON PORTD |= AS_PD_LED_ODO
00070 #define AS_LED_ODO_OFF PORTD &= ~AS_PD_LED_ODO
00071
00072
00073
00074
00075 #define AS_DIR_LEFT(dir) PORTD = (PORTD & ~AS_DIR_FREE) | dir
00076 #define AS_DIR_RIGHT(dir) PORTB = (PORTB & ~AS_DIR_FREE) | dir
00077
00078
00079
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
00086
00087 #define AS_PD_SWITCHES (1 << PD3)
00088
00089
00090
00091
00092 #define AS_SENS_SWITCHES_MODE DDRD |= AS_PD_SWITCHES
00093 #define AS_SENS_SWITCHES_ON PORTD |= AS_PD_SWITCHES
00094 #define AS_SENS_SWITCHES_OFF PORTD &= ~AS_PD_SWITCHES
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
00104
00105 #define AS_MUX_SWITCHES (1 << MUX2)
00106 #define AS_MUX_LINE_LEFT ((1 << MUX0) | (1 << MUX1))
00107 #define AS_MUX_LINE_RIGHT (1 << MUX1)
00108 #define AS_MUX_ODO_LEFT (1 << MUX0)
00109 #define AS_MUX_ODO_RIGHT 0
00110
00111
00112
00113
00114 #define AS_ADC_START ADCSRA |= (1 << ADSC)
00115 #define AS_ADC_STOP ADCSRA |= (1 << ADIF)
00116 #define AS_ADC_FINISHED (ADCSRA & (1 << ADIF))
00117 #define AS_ADC_VALUE (ADCL + (ADCH << 8))
00118
00119
00120
00121
00122 #define AS_PD_IRRX (1 << PD0)
00123 #define AS_IRRX_SAMPLE (PIND & AS_PD_IRRX)
00124
00125
00126 #endif