#include <i2c.h>
#include "../fpv-common/i2c_commands.h"
-#include "main.h"
#include "i2c_protocol.h"
+#include "beep.h"
+#include "main.h"
#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_rx_count = 0;
+static volatile uint8_t i2c_tx_count = 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 */
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);
}
else
command_size = 0;
+ i2c_tx_count++;
}
else {
i2c_errors++;
goto error;
}
+ i2c_rx_count++;
+
switch (buf[0]) {
case I2C_ANS_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;
}