2 * Copyright Droids Corporation (2007)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: i2c_commands.h,v 1.9 2009-05-27 20:04:06 zer0 Exp $
22 #ifndef _I2C_COMMANDS_H_
23 #define _I2C_COMMANDS_H_
25 #define I2C_MAINBOARD_ADDR 1
26 #define I2C_MECHBOARD_ADDR 2
27 #define I2C_SENSORBOARD_ADDR 3
29 #define I2C_LEFT_SIDE 0
30 #define I2C_RIGHT_SIDE 1
31 #define I2C_AUTO_SIDE 2 /* for prepare_pickup */
32 #define I2C_CENTER_SIDE 3 /* for prepare_pickup */
34 #define I2C_COLOR_RED 0
35 #define I2C_COLOR_GREEN 1
37 #define I2C_AUTOBUILD_DEFAULT_DIST 210
44 /* commands that do not need and answer */
47 #define I2C_CMD_GENERIC_LED_CONTROL 0x00
49 struct i2c_cmd_led_control {
50 struct i2c_cmd_hdr hdr;
57 #define I2C_CMD_GENERIC_SET_COLOR 0x01
59 struct i2c_cmd_generic_color {
60 struct i2c_cmd_hdr hdr;
66 #define I2C_CMD_MECHBOARD_SET_MODE 0x02
68 struct i2c_cmd_mechboard_set_mode {
69 struct i2c_cmd_hdr hdr;
70 #define I2C_MECHBOARD_MODE_MANUAL 0x00
71 #define I2C_MECHBOARD_MODE_HARVEST 0x01
72 #define I2C_MECHBOARD_MODE_PREPARE_PICKUP 0x02
73 #define I2C_MECHBOARD_MODE_PICKUP 0x03
74 #define I2C_MECHBOARD_MODE_PREPARE_BUILD 0x04
75 #define I2C_MECHBOARD_MODE_AUTOBUILD 0x05
76 #define I2C_MECHBOARD_MODE_WAIT 0x06
77 #define I2C_MECHBOARD_MODE_INIT 0x07
78 #define I2C_MECHBOARD_MODE_PREPARE_GET_LINTEL 0x08
79 #define I2C_MECHBOARD_MODE_GET_LINTEL 0x09
80 #define I2C_MECHBOARD_MODE_PUT_LINTEL 0x0A
81 #define I2C_MECHBOARD_MODE_PREPARE_EJECT 0x0B
82 #define I2C_MECHBOARD_MODE_EJECT 0x0C
83 #define I2C_MECHBOARD_MODE_CLEAR 0x0D
84 #define I2C_MECHBOARD_MODE_LAZY_HARVEST 0x0E
85 #define I2C_MECHBOARD_MODE_LOADED 0x0F
86 #define I2C_MECHBOARD_MODE_PREPARE_INSIDE 0x10
87 #define I2C_MECHBOARD_MODE_STORE 0x11
88 #define I2C_MECHBOARD_MODE_LAZY_PICKUP 0x12
89 #define I2C_MECHBOARD_MODE_MANIVELLE 0x13
90 #define I2C_MECHBOARD_MODE_PUSH_TEMPLE 0x14
91 #define I2C_MECHBOARD_MODE_PUSH_TEMPLE_DISC 0x15
92 #define I2C_MECHBOARD_MODE_EXIT 0xFF
122 uint8_t distance_left;
123 uint8_t distance_right;
136 /* only valid in manual mode */
137 #define I2C_CMD_MECHBOARD_ARM_GOTO 0x03
139 struct i2c_cmd_mechboard_arm_goto {
140 struct i2c_cmd_hdr hdr;
141 #define I2C_MECHBOARD_ARM_LEFT 0
142 #define I2C_MECHBOARD_ARM_RIGHT 1
143 #define I2C_MECHBOARD_ARM_BOTH 2
146 uint8_t height; /* in cm */
147 uint8_t distance; /* in cm */
152 #define I2C_CMD_SENSORBOARD_SET_BEACON 0x04
154 struct i2c_cmd_sensorboard_start_beacon {
155 struct i2c_cmd_hdr hdr;
162 #define I2C_CMD_SENSORBOARD_SET_SCANNER 0x05
164 struct i2c_cmd_sensorboard_scanner {
165 struct i2c_cmd_hdr hdr;
167 #define I2C_SENSORBOARD_SCANNER_STOP 0x00
168 #define I2C_SENSORBOARD_SCANNER_PREPARE 0x01
169 #define I2C_SENSORBOARD_SCANNER_START 0x02
175 #define I2C_CMD_SENSORBOARD_CALIB_SCANNER 0x06
176 struct i2c_cmd_sensorboard_calib_scanner {
177 struct i2c_cmd_hdr hdr;
182 #define I2C_CMD_SENSORBOARD_SCANNER_ALGO 0x07
183 struct i2c_cmd_sensorboard_scanner_algo {
184 struct i2c_cmd_hdr hdr;
186 #define I2C_SCANNER_ALGO_COLUMN_DROPZONE 1
187 #define I2C_SCANNER_ALGO_CHECK_TEMPLE 2
188 #define I2C_SCANNER_ALGO_TEMPLE_DROPZONE 3
193 #define I2C_SCANNER_ZONE_0 0
194 #define I2C_SCANNER_ZONE_1 1
195 #define I2C_SCANNER_ZONE_DISC 2
196 uint8_t working_zone;
210 /* requests and their answers */
214 #define I2C_REQ_MECHBOARD_STATUS 0x80
216 struct i2c_req_mechboard_status {
217 struct i2c_cmd_hdr hdr;
219 int16_t pump_left1_current;
220 int16_t pump_left2_current;
223 #define I2C_ANS_MECHBOARD_STATUS 0x81
225 struct i2c_ans_mechboard_status {
226 struct i2c_cmd_hdr hdr;
227 /* mode type are defined above: I2C_MECHBOARD_MODE_xxx */
230 #define I2C_MECHBOARD_STATUS_F_READY 0x00
231 #define I2C_MECHBOARD_STATUS_F_BUSY 0x01
232 #define I2C_MECHBOARD_STATUS_F_EXCPT 0x02
235 uint8_t lintel_count;
237 /* flag is there if column was taken by this pump. Note that
238 * we should also check ADC (current) to see if the column is
240 #define I2C_MECHBOARD_COLUMN_L1 0x01
241 #define I2C_MECHBOARD_COLUMN_L2 0x02
242 #define I2C_MECHBOARD_COLUMN_R1 0x04
243 #define I2C_MECHBOARD_COLUMN_R2 0x08
244 uint8_t column_flags;
251 #define I2C_MECHBOARD_CURRENT_COLUMN 85
252 int16_t pump_right1_current;
253 int16_t pump_right2_current;
255 uint16_t servo_lintel_left;
256 uint16_t servo_lintel_right;
259 #define I2C_REQ_SENSORBOARD_STATUS 0x82
261 struct i2c_req_sensorboard_status {
262 struct i2c_cmd_hdr hdr;
264 /* position sent by mainboard */
270 uint8_t enable_pickup_wheels;
273 #define I2C_ANS_SENSORBOARD_STATUS 0x83
275 struct i2c_ans_sensorboard_status {
276 struct i2c_cmd_hdr hdr;
279 #define I2C_OPPONENT_NOT_THERE -1000
285 #define I2C_SCAN_DONE 1
286 #define I2C_SCAN_MAX_COLUMN 2
289 #define I2C_COLUMN_NO_DROPZONE -1
295 #endif /* _I2C_PROTOCOL_H_ */