function Reset()
{
  TargetInterface.setICEBreakerBreakpoint(0, 0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x100, 0xF7);
  TargetInterface.setNSRST(0);
  TargetInterface.setNSRST(1);
  TargetInterface.waitForDebugState(1000);
  TargetInterface.trst();
  TargetInterface.setICEBreakerBreakpoint(0, 0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00, 0xF7);
}

function SRAMReset()
{
  Reset();
  TargetInterface.pokeWord(0xFFFE2008, 0x00000002);
  TargetInterface.pokeWord(0xFFFF1000, 0x18000C60); // SMCBCR0
  TargetInterface.pokeWord(0xFFFF1004, 0x10000400); // SMCBCR1
  TargetInterface.pokeWord(0xFFFF1008, 0x10000400); // SMCBCR2
  TargetInterface.pokeWord(0xFFFE5000, 0x00005F3F); // EBI_MUX
}

function FLASHReset()
{
  Reset();
  TargetInterface.pokeWord(0xFFFE2008, 0x00000000); 
  TargetInterface.pokeWord(0xFFFF1000, 0x18000C60); // SMCBCR0
  TargetInterface.pokeWord(0xFFFF1004, 0x10000400); // SMCBCR1
  TargetInterface.pokeWord(0xFFFF1008, 0x10000400); // SMCBCR2
  TargetInterface.pokeWord(0xFFFE5000, 0x00005F3F); // EBI_MUX
}


