//! Fills user supplied structure with state of BDM communication channel
//!
//! @param bdm_status Pointer to structure to receive status
//!
//! @return 0 => Success,\n !=0 => Fail
//!
TBDML_API unsigned char _tbdml_bdm_sts(bdm_status_t *bdmStatus) {
USBDMStatus_t USBDMStatus;
USBDM_ErrorCode rc = BDM_RC_OK;

   print("_tbdml_bdm_sts()\n");

   rc = USBDM_TargetConnectWithRetry(&USBDMStatus);

   if (rc == BDM_RC_OK) {
      bdmStatus->ackn_state       = USBDMStatus.ackn_state;
      bdmStatus->connection_state = USBDMStatus.connection_state;
      bdmStatus->reset_state      = USBDMStatus.reset_recent;
   }
   else {
      bdmStatus->ackn_state       = WAIT;
      bdmStatus->connection_state = SPEED_NO_INFO;
      bdmStatus->reset_state      = NO_RESET_ACTIVITY;
   }
   return rc;
}
//! Connects to Target.
//!
//! This will cause the BDM module to attempt to connect to the Target.
//! In most cases the BDM module will automatically determine the connection
//! speed and successfully connect.  If unsuccessful, it may be necessary
//! to manually set the speed using set_speed().
//!
//! @return 0 => Success,\n !=0 => Fail
//!
TBDML_API unsigned char _tbdml_target_sync(void) {

   print("_tbdml_target_sync()\n");
   return USBDM_TargetConnectWithRetry();
}
//! Connects to Target.
//!
//! This will cause the BDM module to attempt to connect to the Target.
//! In most cases the BDM module will automatically determine the connection
//! speed and successfully connect.  If unsuccessful, it may be necessary
//! to manually set the speed using set_speed().
//!
//! @return 0 => Success,\n !=0 => Fail
//!
OSBDM_API unsigned char _opensourcebdm_target_sync(void) {

   print("_opensourcebdm_target_sync()\n");
   return USBDM_TargetConnectWithRetry();
}