};
+/* ************* */
+
+struct cmd_i2c_enable_result {
+ fixed_string_t cmd;
+};
+
+static void cmd_i2c_enable_parsed(void *parsed_result, void *data)
+{
+ (void)parsed_result;
+ (void)data;
+
+ i2c_protocol_enable(1);
+}
+
+const char PROGMEM str_i2c_enable[] = "i2c_enable";
+const parse_token_string_t PROGMEM cmd_i2c_enable_cmd =
+ TOKEN_STRING_INITIALIZER(struct cmd_i2c_enable_result, cmd,
+ str_i2c_enable);
+
+const char PROGMEM help_i2c_enable[] = "i2c_enable";
+const parse_inst_t PROGMEM cmd_i2c_enable = {
+ .f = cmd_i2c_enable_parsed, /* function to call */
+ .data = NULL, /* 2nd arg of func */
+ .help_str = help_i2c_enable,
+ .tokens = { /* token list, NULL terminated */
+ (PGM_P)&cmd_i2c_enable_cmd,
+ NULL,
+ },
+};
+
+
/* ************* */
/* in progmem */
&cmd_eeprom_add2,
&cmd_eeprom_list,
&cmd_dump_i2c,
+ &cmd_i2c_enable,
NULL,
};
volatile int8_t command_dest=-1;
volatile uint8_t command_size=0;
+static uint8_t i2c_enabled = 0;
+
#define I2C_ERROR(args...) do { \
if (error_log < I2C_MAX_LOG) { \
ERROR(E_USER_I2C_PROTO, args); \
(void)tim;
(void)arg;
+ if (i2c_enabled == 0)
+ goto reschedule;
+
if ((imuboard_status.flags & I2C_IMUBOARD_STATUS_SDCARD_OK) == 0) {
beep(0, 1, 1);
goto reschedule;
LED2_TOGGLE();
#endif
+ if (i2c_enabled == 0)
+ goto reschedule;
+
/* already running */
IRQ_LOCK(flags);
if (running_op != OP_READY) {
return i2c_send_command(addr, (uint8_t*)&buf, sizeof(buf));
}
+void i2c_protocol_enable(uint8_t enable)
+{
+ i2c_enabled = enable;
+}
+
void i2c_protocol_init(void)
{
callout_init(&i2c_timer, i2c_poll_slaves, NULL, I2C_PRIO);