add ballboard commands on mainboard
[aversive.git] / projects / microb2009 / tests / arm_test / i2c_protocol.c
1 /*
2  *  Copyright Droids Corporation (2007)
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.c,v 1.1 2009-01-30 20:38:49 zer0 Exp $
19  *
20  */
21
22
23 #include <stdio.h>
24 #include <string.h>
25
26 #include <aversive.h>
27 #include <aversive/error.h>
28
29 #include <uart.h>
30 #include <i2c.h>
31 #include <time.h>
32
33 #include "../common/i2c_commands.h"
34 #include "strat_base.h"
35 #include "main.h"
36 #include "i2c_protocol.h"
37
38 //#define DEBUG_FROM_EXT
39
40 #define I2C_TIMEOUT 100 /* ms */
41 #define I2C_MAX_ERRORS 40
42
43 /* used for commands */
44 uint8_t command_buf[I2C_SEND_BUFFER_SIZE];
45
46 void i2c_protocol_init(void)
47 {
48 }
49
50 void i2c_poll_slaves(void * dummy)
51 {
52 }
53
54 /* called when the xmit is finished */
55 void i2c_sendevent(int8_t size)
56 {
57         if (size > 0) {
58         }
59         else {
60                 i2c_errors++;
61                 NOTICE(E_USER_I2C_PROTO, "send error size=%d", size);
62         }
63 }
64
65 /* called rx event */
66 void i2c_recvevent(uint8_t * buf, int8_t size)
67 {
68         if (size < 0) {
69                 goto error;
70         }
71
72         for (i = 0; i<size; i++) {
73                 printf("%x ", buf[1]);
74         }
75         printf("\r\n");
76
77         return;
78  error:
79         NOTICE(E_USER_I2C_PROTO, "recv error size=%d", size);
80 }
81         
82 void i2c_recvbyteevent(uint8_t hwstatus, uint8_t i, uint8_t c)
83 {
84 }
85
86