# Streaming and Sampling Settings
# ############################################################################

#***** Sample output ********
set sampling 0	   		# 0= no sample output, 1 = sampling.

#***** Definition of sampling trails ******
set sample_source 0 		# 0 = from ADC, 1 = deconvoluted, 2 = timing filter, 3 = from shaper.
set no_offset_correction 0 	# 0 = offset correction; 1= no offset correction
set no_resampling 0			# 0 = resampling; 1 = no resampling

set number_presamples 4 # 0 to 1000, number of samples before input edge appears with ADC source
set number_samples	12  # 2 to 1000, total number of samples required. Even number.



#********************************************
#**** From here experts only ****************
#********************************************

#***** output data format **********
set output_format 0 	# 0 = standard WOI format #only for experts:  4 = compact_streaming, 8 = standard_streaming
						#  Compact streaming does not support sampling

#**** Firmware check *************
read a32 d16 0x600E # firmware revision
accu_mask_rotate 0x000000ff 32
accu_test_warn gte 0x50 "MDPP-16_SCP >= FW2050 required for Sampling mode"

# *** Use the variables defined above ***************

# output_format register 0x6044
# 0 (default)   -> window of interest, no samples
# 4  -> Since SCP FW2050. Enables compact_streaming.
# 8  -> Since SCP FW2050. Enables standard_streaming.
# Individual bits: {sampling, standard_streaming, compact_streaming, 0,0}
#					default: window of interest: standard_streaming = 0, compact_streaming = 0

0x6044 0x${sampling}${output_format}

# Sampling parameter (can be set for all channels or per channel pair)
0x6100 8						# select_chan_pair, 8 = all channels
0x6146 ${number_presamples}		# number of pre-samples
0x6148 ${number_samples}		# total samples to output (even number required)

# sampling source and settings [7:0]
# bits [1:0]: sample source
#   00 = from ADC
#   01 = deconvoluted
#   10 = timing filter
#   11 = from shaper
# settings [7:4]
#   bit 7 set: no offset correction
#   bit 6 set: no resampling
0x614A $(${no_offset_correction}*128+${no_resampling}*64+${sample_source})
