interface ftdi
ftdi_vid_pid 0x0403 0x6010

# Every pin set as high impedance except TCK, TDI, TDO and TMS
ftdi_layout_init 0x0008 0x000b

# nSRST defined on pin CN2-13 of the MiniModule (pin ADBUS5 [AD5] on the FT2232H chip)
# This choice is arbitrary. Use other GPIO pin if desired.
ftdi_layout_signal nSRST -data 0x0020 -oe 0x0020

ftdi_layout_signal nTRST -data 0x0010 -oe 0x0010
transport select jtag

# ADBUS 0 - 5 are used
# 0 TCK
# 1 TDI
# 2 TDO
# 3 TMS
# 4 nTRST
# 5 nSRST


source [find target/lpc2xxx.cfg]
# parameters:
# - core_freq_khz - frequency of core in kHz during flashing, usually equal to connected crystal or internal oscillator, e.g. 12000
# - adapter_freq_khz - frequency of debug adapter in kHz, should be 8x slower than core_freq_khz, e.g. 1000

proc setup_lpc2387 {core_freq_khz adapter_freq_khz} {
	# setup_lpc2xxx <chip_name> <cputapid> <flash_size> <flash_variant> <workarea_size> <core_freq_khz> <adapter_freq_khz>
	setup_lpc2xxx lpc2387 0x4f1f0f0f 0x7d000 lpc2000_v2 0x10000 $core_freq_khz $adapter_freq_khz
}

proc init_targets {} {
	# setup_lpc2387 <core_freq_khz> <adapter_freq_khz>
	setup_lpc2387 4000 500
}