rm -f raw_z_*
# 2180*15 = 32700
# log10(32700/32768)*20 = -0.018 dBFS
# 2180*2 = 4360
# Should be rewritten in python, then it would be easy to restore dac_{0,1}_sel
# to the original setting, not just arbitrarly set it to 10 when done.

# Note that ssa_stim DAC output depends on ddsa setup as well.
# Stimulus pulses actually last 2*(g_period+1) DAC cycles:  33*12-1 = 395
# See ssa_stim.v and digitizer_dsp.v
SSA_STIM_SETTINGS="ssa_stim_g_period,18 ssa_stim_ampstep,0 ssa_stim_pertstep,12000"
SSA_STIM_SETTINGS="ssa_stim_g_period,395 ssa_stim_ampstep,4360 ssa_stim_pertstep,2180"
for IP in sys{1,2}_rfs{1,2}; do
  python new_mem_gateway.py -a $IP --nvs $SSA_STIM_SETTINGS ssa_stim_en,1 dac_0_sel,2 dac_1_sel,0
  # should be 0x8d, was 0x9c; see ssa2.py
  python get_raw_adcs.py -a $IP -m 0x9c -c 4
  mkdir ssa_${IP}_0
  mv raw_z_* ssa_${IP}_0
  python new_mem_gateway.py -a $IP --nvs $SSA_STIM_SETTINGS ssa_stim_en,1 dac_0_sel,0 dac_1_sel,2
  python get_raw_adcs.py -a $IP -m 0xe1 -c 4
  mkdir ssa_${IP}_1
  mv raw_z_* ssa_${IP}_1
  python new_mem_gateway.py -a $IP --nvs ssa_stim_en,0 dac_0_sel,1 dac_1_sel,1
done
