]> git.droids-corp.org - protos/xbee-avr.git/commitdiff
beep when GPS ready master
authorOlivier Matz <zer0@droids-corp.org>
Thu, 24 Jul 2014 16:16:43 +0000 (18:16 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Thu, 24 Jul 2014 16:16:43 +0000 (18:16 +0200)
commands.c
i2c_protocol.c

index 9f7eaf6b3205a7194b85ba1fe7848a78f7b51467..d67b6515ba1bc60b88620f9c798c9f030f399f3c 100644 (file)
@@ -2271,7 +2271,7 @@ static void cmd_dump_i2c_parsed(void *parsed_result, void *data)
                                imu.latitude, imu.longitude, imu.altitude);
                }
                else
                                imu.latitude, imu.longitude, imu.altitude);
                }
                else
-                       printf_P(PSTR("GPS unavailable"));
+                       printf_P(PSTR("GPS unavailable\n"));
                i2c_protocol_debug();
                wait_ms(100);
        }
                i2c_protocol_debug();
                wait_ms(100);
        }
index 6b667b4753e93dda88e1f2c288e7b35209c7428b..ca4c49c8e9815a33fce30a45bf86e509b6981cb4 100644 (file)
@@ -30,8 +30,9 @@
 #include <i2c.h>
 
 #include "../fpv-common/i2c_commands.h"
 #include <i2c.h>
 
 #include "../fpv-common/i2c_commands.h"
-#include "main.h"
 #include "i2c_protocol.h"
 #include "i2c_protocol.h"
+#include "beep.h"
+#include "main.h"
 
 #define I2C_STATE_MAX 2
 #define I2C_PERIOD_MS 50
 
 #define I2C_STATE_MAX 2
 #define I2C_PERIOD_MS 50
 
 static volatile uint8_t i2c_poll_num = 0;
 static volatile uint8_t i2c_state = 0;
 
 static volatile uint8_t i2c_poll_num = 0;
 static volatile uint8_t i2c_state = 0;
+static volatile uint8_t i2c_rx_count = 0;
+static volatile uint8_t i2c_tx_count = 0;
 static volatile uint16_t i2c_errors = 0;
 
 static volatile uint16_t i2c_errors = 0;
 
+static uint8_t gps_ok = 0;
+
 #define OP_READY 0 /* no i2c op running */
 #define OP_POLL  1 /* a user command is running */
 #define OP_CMD   2 /* a polling (req / ans) is running */
 #define OP_READY 0 /* no i2c op running */
 #define OP_POLL  1 /* a user command is running */
 #define OP_CMD   2 /* a polling (req / ans) is running */
@@ -80,6 +85,8 @@ volatile uint8_t command_size=0;
 void i2c_protocol_debug(void)
 {
        printf_P(PSTR("I2C protocol debug infos:\r\n"));
 void i2c_protocol_debug(void)
 {
        printf_P(PSTR("I2C protocol debug infos:\r\n"));
+       printf_P(PSTR("  i2c_send=%d\r\n"), i2c_tx_count);
+       printf_P(PSTR("  i2c_recv=%d\r\n"), i2c_rx_count);
        printf_P(PSTR("  i2c_state=%d\r\n"), i2c_state);
        printf_P(PSTR("  i2c_errors=%d\r\n"), i2c_errors);
        printf_P(PSTR("  running_op=%d\r\n"), running_op);
        printf_P(PSTR("  i2c_state=%d\r\n"), i2c_state);
        printf_P(PSTR("  i2c_errors=%d\r\n"), i2c_errors);
        printf_P(PSTR("  running_op=%d\r\n"), running_op);
@@ -198,6 +205,7 @@ void i2c_sendevent(int8_t size)
                }
                else
                        command_size = 0;
                }
                else
                        command_size = 0;
+               i2c_tx_count++;
        }
        else {
                i2c_errors++;
        }
        else {
                i2c_errors++;
@@ -230,6 +238,8 @@ void i2c_recvevent(uint8_t * buf, int8_t size)
                goto error;
        }
 
                goto error;
        }
 
+       i2c_rx_count++;
+
        switch (buf[0]) {
 
        case I2C_ANS_IMUBOARD_STATUS: {
        switch (buf[0]) {
 
        case I2C_ANS_IMUBOARD_STATUS: {
@@ -242,6 +252,13 @@ void i2c_recvevent(uint8_t * buf, int8_t size)
                /* copy status in a global struct */
                memcpy(&imuboard_status, ans, sizeof(imuboard_status));
 
                /* copy status in a global struct */
                memcpy(&imuboard_status, ans, sizeof(imuboard_status));
 
+               if (gps_ok == 0 &&
+                       (imuboard_status.flags & IMUBOARD_STATUS_GPS_OK)) {
+                       gps_ok = 1;
+                       beep(0, 1, 1);
+                       beep(0, 1, 1);
+               }
+
                break;
        }
 
                break;
        }