allow to dump GPS info
[protos/xbee-avr.git] / i2c_protocol.c
index 6734453..6b667b4 100644 (file)
@@ -39,8 +39,6 @@
 #define I2C_TIMEOUT 100 /* ms */
 #define I2C_MAX_ERRORS 40
 
-uint8_t imuboard = 0; /* XXX test */
-
 static volatile uint8_t i2c_poll_num = 0;
 static volatile uint8_t i2c_state = 0;
 static volatile uint16_t i2c_errors = 0;
@@ -58,6 +56,9 @@ static struct callout i2c_timer;
 
 static int8_t i2c_req_imuboard_status(void);
 
+/* latest received imuboard_status */
+struct i2c_ans_imuboard_status imuboard_status;
+
 /* used for commands */
 uint8_t command_buf[I2C_SEND_BUFFER_SIZE];
 volatile int8_t command_dest=-1;
@@ -232,14 +233,14 @@ void i2c_recvevent(uint8_t * buf, int8_t size)
        switch (buf[0]) {
 
        case I2C_ANS_IMUBOARD_STATUS: {
-               struct i2c_ans_imuboard_status * ans =
+               struct i2c_ans_imuboard_status *ans =
                        (struct i2c_ans_imuboard_status *)buf;
 
                if (size != sizeof (*ans))
                        goto error;
 
-               /* status */
-               imuboard = ans->test;
+               /* copy status in a global struct */
+               memcpy(&imuboard_status, ans, sizeof(imuboard_status));
 
                break;
        }