test
[aversive.git] / projects / microb2009 / mainboard / i2c_protocol.h
1 /*
2  *  Copyright Droids Corporation (2009)
3  * 
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.
8  *
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.
13  *
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
17  *
18  *  Revision : $Id: i2c_protocol.h,v 1.6 2009-11-08 17:24:33 zer0 Exp $
19  *
20  */
21
22 #ifndef _I2C_PROTOCOL_H_
23 #define _I2C_PROTOCOL_H_
24
25 void i2c_protocol_init(void);
26 void i2c_protocol_debug(void);
27
28 void i2cproto_wait_update(void);
29 void i2c_poll_slaves(void *dummy);
30
31 void i2c_recvevent(uint8_t *buf, int8_t size);
32 void i2c_recvbyteevent(uint8_t hwstatus, uint8_t i, uint8_t c);
33 void i2c_sendevent(int8_t size);
34
35 int8_t i2c_set_color(uint8_t addr, uint8_t color);
36 int8_t i2c_led_control(uint8_t addr, uint8_t led, uint8_t state);
37
38 int8_t i2c_mechboard_mode_manual(void);
39 int8_t i2c_mechboard_mode_harvest(void);
40 int8_t i2c_mechboard_mode_lazy_harvest(void);
41 int8_t i2c_mechboard_mode_prepare_pickup(uint8_t side);
42 int8_t i2c_mechboard_mode_prepare_pickup_next(uint8_t side, uint8_t next_mode);
43 int8_t i2c_mechboard_mode_pickup(void);
44 int8_t i2c_mechboard_mode_eject(void);
45 int8_t i2c_mechboard_mode_lazy_pickup(void);
46
47 int8_t i2c_mechboard_mode_prepare_build_both(uint8_t level);
48 int8_t i2c_mechboard_mode_prepare_build_select(int8_t level_l, int8_t level_r);
49 int8_t i2c_mechboard_mode_prepare_inside_both(uint8_t level);
50 int8_t i2c_mechboard_mode_prepare_inside_select(int8_t level_l, int8_t level_r);
51 int8_t i2c_mechboard_mode_simple_autobuild(uint8_t level);
52 int8_t i2c_mechboard_mode_autobuild(uint8_t level_l, uint8_t count_l,
53                                     uint8_t dist_l, 
54                                     uint8_t level_r, uint8_t count_r,
55                                     uint8_t dist_r, 
56                                     uint8_t do_lintel);
57 int8_t i2c_mechboard_mode_init(void);
58 int8_t i2c_mechboard_mode_eject(void);
59 int8_t i2c_mechboard_mode_prepare_get_lintel(void);
60 int8_t i2c_mechboard_mode_get_lintel(void);
61 int8_t i2c_mechboard_mode_put_lintel(void);
62 int8_t i2c_mechboard_mode_clear(void);
63 int8_t i2c_mechboard_mode_loaded(void);
64 int8_t i2c_mechboard_mode_store(void);
65 int8_t i2c_mechboard_mode_manivelle(void);
66 int8_t i2c_mechboard_mode_push_temple(uint8_t level);
67 int8_t i2c_mechboard_mode_push_temple_disc(uint8_t side);
68
69 int8_t i2c_sensorboard_set_beacon(uint8_t enable);
70
71 int8_t i2c_sensorboard_scanner_set(uint8_t mode);
72 static inline int8_t i2c_sensorboard_scanner_stop(void) {
73         return i2c_sensorboard_scanner_set(I2C_SENSORBOARD_SCANNER_STOP);
74 }
75 static inline int8_t i2c_sensorboard_scanner_start(void) {
76         return i2c_sensorboard_scanner_set(I2C_SENSORBOARD_SCANNER_START);
77 }
78 static inline int8_t i2c_sensorboard_scanner_prepare(void) {
79         return i2c_sensorboard_scanner_set(I2C_SENSORBOARD_SCANNER_PREPARE);
80 }
81
82 int8_t i2c_sensorboard_scanner_calib(void);
83
84 int8_t i2c_sensorboard_scanner_algo_column(uint8_t zone,
85                                            int16_t x, int16_t y);
86 int8_t i2c_sensorboard_scanner_algo_check(uint8_t level,
87                                           int16_t x, int16_t y);
88 int8_t i2c_sensorboard_scanner_algo_temple(uint8_t zone,
89                                            int16_t x, int16_t y);
90
91
92 #endif