/*********************************************************************
*
*       InitTarget()
*
*  Function description
*    If present, called right before performing generic connect sequence.
*    Usually used for targets which need a special connect sequence.
*    E.g.: TI devices with ICEPick TAP on them where core TAP needs to be enabled via specific ICEPick sequences first
*
*  Return value
*    >= 0:  O.K.
*     < 0:  Error
*
*  Notes
*    (1) Must not use high-level API functions like JLINK_MEM_ etc.
*    (2) For target interface JTAG, this device has to setup the JTAG chain + JTAG TAP Ids.
*/
int InitTarget(void) {
  //
  // TDI -> TAP_#1 -> TAP_#0 -> TDO
  //
  // TAP_#0 info:
  //   IRLen: 5
  //   TAPId: 0xDEB11001
  //
  // TAP_#1 info:
  //   IRLen: 5
  //   TAPId: 0x20000913
  //

  //
  // Code to connect to TAP_#0
  //
  JLINK_JTAG_DRPre  = 0;
  JLINK_JTAG_DRPost = 1;
  JLINK_JTAG_IRPre  = 0;
  JLINK_JTAG_IRPost = 5;
  JLINK_JTAG_IRLen  = 5;
  JLINK_JTAG_SetDeviceId(0, 0xDEB11001);
  JLINK_JTAG_SetDeviceId(1, 0x20000913);
  return 0;
}
