struct i2c_ans_imuboard_status {
struct i2c_cmd_hdr hdr;
-#define I2C_IMUBOARD_STATUS_GPS_OK 0x01
-#define I2C_IMUBOARD_STATUS_IMU_OK 0x02
+#define I2C_IMUBOARD_STATUS_BOOT_OK 0x01
+#define I2C_IMUBOARD_STATUS_SDCARD_OK 0x02
+#define I2C_IMUBOARD_STATUS_GPS_OK 0x04
+#define I2C_IMUBOARD_STATUS_IMU_OK 0x08
uint8_t flags;
int32_t latitude; /* between -90e7 and 90e7, in 1/1e-7 degrees,
#define I2C_TIMEOUT 100 /* ms */
#define I2C_MAX_ERRORS 40
+#define IMUBOARD_BEEP_PERIOD_MS 2000
+
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 */
static uint8_t error_log = 0;
static struct callout i2c_timer;
+static struct callout imuboard_beep_timer;
static int8_t i2c_req_imuboard_status(void);
//WAIT_COND_OR_TIMEOUT((i2c_poll_num-poll_num) > 1, 150); /* XXX todo */
}
+static void imuboard_beep_cb(struct callout_mgr *cm, struct callout *tim, void *arg)
+{
+ (void)cm;
+ (void)tim;
+ (void)arg;
+
+ if ((imuboard_status.flags & I2C_IMUBOARD_STATUS_SDCARD_OK) == 0) {
+ beep(0, 1, 1);
+ goto reschedule;
+ }
+
+ if ((imuboard_status.flags & I2C_IMUBOARD_STATUS_BOOT_OK) == 0) {
+ beep(0, 1, 1);
+ beep(0, 1, 1);
+ goto reschedule;
+ }
+
+ if ((imuboard_status.flags & I2C_IMUBOARD_STATUS_GPS_OK) == 0) {
+ beep(0, 1, 1);
+ beep(0, 1, 1);
+ beep(0, 1, 1);
+ goto reschedule;
+ }
+
+ reschedule:
+ callout_reschedule(cm, tim, IMUBOARD_BEEP_PERIOD_MS);
+}
+
+
/* called periodically : the goal of this 'thread' is to send requests
* and read answers on i2c slaves in the correct order. */
static void i2c_poll_slaves(struct callout_mgr *cm, struct callout *tim, void *arg)
/* copy status in a global struct */
memcpy(&imuboard_status, ans, sizeof(imuboard_status));
- if (gps_ok == 0 &&
- (imuboard_status.flags & I2C_IMUBOARD_STATUS_GPS_OK)) {
- gps_ok = 1;
- beep(0, 1, 1);
- beep(0, 1, 1);
- }
-
break;
}
{
callout_init(&i2c_timer, i2c_poll_slaves, NULL, I2C_PRIO);
callout_schedule(&xbeeboard.intr_cm, &i2c_timer, I2C_PERIOD_MS);
+ callout_init(&imuboard_beep_timer, imuboard_beep_cb, NULL, I2C_PRIO); // prio ok ? XXX
+ callout_schedule(&xbeeboard.intr_cm, &imuboard_beep_timer,
+ IMUBOARD_BEEP_PERIOD_MS);
}