/*********************************************************************
*            (c) 1995 - 2018 SEGGER Microcontroller GmbH             *
*                        The Embedded Experts                        *
*                           www.segger.com                           *
**********************************************************************

-------------------------- END-OF-HEADER -----------------------------
*/

/*********************************************************************
*
*       ResetTarget
*/
void ResetTarget(void) {
  //
  // This device requires a special reset as default reset does not work for this device.
  // TBD
  //
  JLINK_TARGET_Halt(); // Make sure that the CPU is halted when reset is called
}

/*********************************************************************
*
*       InitTarget
*/
void InitTarget(void) {
  Report("***************************************************");
  Report("J-Link script: iMX7ULP Cortex-A7 core J-Link script");
  Report("***************************************************");
  JLINK_CORESIGHT_Configure("IRPre=0;DRPre=0;IRPost=0;DRPost=0;IRLenDevice=4");
  CPU = CORTEX_A7;                                                              // Pre-select that we have a Cortex-A7 connected
  JTAG_AllowTAPReset = 0;                                                       // J-Link is allowed to use a TAP reset for JTAG-chain auto-detection
  //
  // Manually configure which APs are present on the CoreSight device
  //
  CORESIGHT_CoreBaseAddr = 0x80030000;
  CORESIGHT_AddAP(0, CORESIGHT_AHB_AP);
  CORESIGHT_AddAP(1, CORESIGHT_APB_AP);
  CORESIGHT_AddAP(2, CORESIGHT_CUSTOM_AP);
  CORESIGHT_AddAP(3, CORESIGHT_AHB_AP);
  CORESIGHT_AddAP(4, CORESIGHT_CUSTOM_AP);
  CORESIGHT_AddAP(5, CORESIGHT_CUSTOM_AP);
  CORESIGHT_IndexAPBAPToUse = 1;  
  JTAG_SetDeviceId(0, 0x6BA00477);  // 4-bits IRLen
}
