2 * Copyright Droids Corporation (2010)
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_OPPONENT_NOT_THERE -1000
26 #define I2C_BEACON_NOT_FOUND -1000
28 #define I2C_MAINBOARD_ADDR 1
29 #define I2C_COBBOARD_ADDR 2
30 #define I2C_BALLBOARD_ADDR 3
32 #define I2C_LEFT_SIDE 0
33 #define I2C_RIGHT_SIDE 1
34 #define I2C_AUTO_SIDE 2
35 #define I2C_CENTER_SIDE 3
38 #define I2C_COLOR_YELLOW 0
39 #define I2C_COLOR_BLUE 1
41 #define I2C_COB_BLACK 0
42 #define I2C_COB_WHITE 1
43 #define I2C_COB_UNKNOWN 2
44 #define I2C_COB_REMOVED 3
45 #define I2C_COB_NONE 4
52 /* commands that do not need and answer */
55 #define I2C_CMD_GENERIC_LED_CONTROL 0x00
57 struct i2c_cmd_led_control {
58 struct i2c_cmd_hdr hdr;
65 #define I2C_CMD_GENERIC_SET_COLOR 0x01
67 struct i2c_cmd_generic_color {
68 struct i2c_cmd_hdr hdr;
74 #define I2C_CMD_COBBOARD_SET_MODE 0x02
76 struct i2c_cmd_cobboard_set_mode {
77 struct i2c_cmd_hdr hdr;
79 #define I2C_COBBOARD_MODE_HARVEST 0x01 /* harvest mode */
80 #define I2C_COBBOARD_MODE_EJECT 0x02 /* eject cobs */
81 #define I2C_COBBOARD_MODE_INIT 0x03 /* init state machine */
82 #define I2C_COBBOARD_MODE_KICKSTAND_UP 0x04 /* help to climb the hill */
83 #define I2C_COBBOARD_MODE_KICKSTAND_DOWN 0x05 /* help to climb the hill */
87 #define I2C_CMD_BALLBOARD_SET_MODE 0x10
89 struct i2c_cmd_ballboard_set_mode {
90 struct i2c_cmd_hdr hdr;
92 #define I2C_BALLBOARD_MODE_INIT 0x00
93 #define I2C_BALLBOARD_MODE_OFF 0x01
94 #define I2C_BALLBOARD_MODE_HARVEST 0x02
95 #define I2C_BALLBOARD_MODE_EJECT 0x03
96 #define I2C_BALLBOARD_MODE_PREP_FORK 0x04
97 #define I2C_BALLBOARD_MODE_TAKE_FORK 0x05
101 #define I2C_CMD_BALLBOARD_SET_BEACON 0x04
103 struct i2c_cmd_ballboard_start_beacon {
104 struct i2c_cmd_hdr hdr;
109 /* requests and their answers */
113 #define I2C_REQ_COBBOARD_STATUS 0x80
115 struct i2c_req_cobboard_status {
116 struct i2c_cmd_hdr hdr;
118 #define I2C_COBBOARD_SPK_DEPLOY 0x01 /* deploy the spickle */
119 #define I2C_COBBOARD_SPK_AUTOHARVEST 0x02 /* auto harvest the cobs */
120 #define I2C_COBBOARD_SPK_NO_MOVE 0x04 /* if enabled, don't change state */
121 #define I2C_COBBOARD_SPK_WEAK 0x08 /* if enabled, current limit */
126 #define I2C_ANS_COBBOARD_STATUS 0x81
128 struct i2c_ans_cobboard_status {
129 struct i2c_cmd_hdr hdr;
131 /* mode type are defined above: I2C_COBBOARD_MODE_xxx */
134 #define I2C_COBBOARD_STATUS_READY 0x00
135 #define I2C_COBBOARD_STATUS_OFF 0x01
136 #define I2C_COBBOARD_STATUS_LBUSY 0x02
137 #define I2C_COBBOARD_STATUS_RBUSY 0x03
138 #define I2C_COBBOARD_STATUS_EJECT 0x04
139 #define I2C_COBBOARD_STATUS_KICKSTAND_UP 0x05
140 #define I2C_COBBOARD_STATUS_KICKSTAND_DOWN 0x06
145 int16_t left_cobroller_speed;
146 int16_t right_cobroller_speed;
149 #define I2C_REQ_BALLBOARD_STATUS 0x82
151 struct i2c_req_ballboard_status {
152 struct i2c_cmd_hdr hdr;
154 /* position sent by mainboard */
160 #define I2C_ANS_BALLBOARD_STATUS 0x83
162 struct i2c_ans_ballboard_status {
163 struct i2c_cmd_hdr hdr;
167 #define I2C_BALLBOARD_STATUS_F_READY 0x00
168 #define I2C_BALLBOARD_STATUS_F_BUSY 0x01
169 #define I2C_BALLBOARD_STATUS_F_EXCPT 0x02
179 /* detection of cobs */
184 #endif /* _I2C_PROTOCOL_H_ */