예제 #1
0
static inline void intermcu_parse_msg(struct transport_rx *trans, void (*commands_frame_handler)(void))
{
  /* Parse the Inter MCU message */
  uint8_t msg_id = trans->payload[1];
  switch (msg_id) {
    case DL_IMCU_COMMANDS: {
      uint8_t i;
      uint8_t size = DL_IMCU_COMMANDS_values_length(trans->payload);
      int16_t *new_commands = DL_IMCU_COMMANDS_values(trans->payload);
      for (i = 0; i < size; i++) {
        intermcu_commands[i] = new_commands[i];
      }

      inter_mcu.status = INTERMCU_OK;
      inter_mcu.time_since_last_frame = 0;
      commands_frame_handler();
      break;
    }

    default:
      break;
  }

  // Set to receive another message
  trans->msg_received = FALSE;
}
예제 #2
0
static void intermcu_parse_msg(struct transport_rx *trans, void (*commands_frame_handler)(void))
{
    /* Parse the Inter MCU message */
    uint8_t msg_id = trans->payload[1];
    switch (msg_id) {
    case DL_IMCU_COMMANDS: {
        uint8_t i;
        uint8_t size = DL_IMCU_COMMANDS_values_length(trans->payload);
        int16_t *new_commands = DL_IMCU_COMMANDS_values(trans->payload);
        uint8_t status = DL_IMCU_COMMANDS_status(trans->payload);
        autopilot_motors_on = status & 0x1;
        for (i = 0; i < size; i++) {
            intermcu_commands[i] = new_commands[i];
        }

        inter_mcu.status = INTERMCU_OK;
        inter_mcu.time_since_last_frame = 0;
        commands_frame_handler();
        break;
    }

#if defined(SPEKTRUM_HAS_SOFT_BIND_PIN) //TODO: make subscribable module parser
    case DL_IMCU_SPEKTRUM_SOFT_BIND:
        received_spektrum_soft_bind();
        break;
#endif
    default:
        break;
    }

    // Set to receive another message
    trans->msg_received = FALSE;
}
예제 #3
0
static void intermcu_parse_msg(void (*commands_frame_handler)(void))
{
  /* Parse the Inter MCU message */
  uint8_t msg_id = imcu_msg_buf[1];
  switch (msg_id) {
    case DL_IMCU_COMMANDS: {
      uint8_t i;
      uint8_t size = DL_IMCU_COMMANDS_values_length(imcu_msg_buf);
      int16_t *new_commands = DL_IMCU_COMMANDS_values(imcu_msg_buf);
      intermcu.cmd_status |= DL_IMCU_COMMANDS_status(imcu_msg_buf);

      // Read the autopilot status and then clear it
      autopilot_motors_on = INTERMCU_GET_CMD_STATUS(INTERMCU_CMD_MOTORS_ON);
      INTERMCU_CLR_CMD_STATUS(INTERMCU_CMD_MOTORS_ON)

      for (i = 0; i < size; i++) {
        intermcu_commands[i] = new_commands[i];
      }

      intermcu.status = INTERMCU_OK;
      intermcu.time_since_last_frame = 0;
      commands_frame_handler();
      break;
    }
#if defined(TELEMETRY_INTERMCU_DEV)
    case DL_IMCU_TELEMETRY: {
      uint8_t id = DL_IMCU_TELEMETRY_msg_id(imcu_msg_buf);
      uint8_t size = DL_IMCU_TELEMETRY_msg_length(imcu_msg_buf);
      uint8_t *msg = DL_IMCU_TELEMETRY_msg(imcu_msg_buf);
      telemetry_intermcu_on_msg(id, msg, size);
      break;
    }
#endif
#if defined(SPEKTRUM_HAS_SOFT_BIND_PIN) //TODO: make subscribable module parser
    case DL_IMCU_SPEKTRUM_SOFT_BIND:
      received_spektrum_soft_bind();
      break;
#endif

    default:
      break;
  }
}