fice version 25092900
Tool to read or write GBTX or lpGBT registers via the IC-channel
of an FLX-device (lp)GBT link,
and for lpGBT optionally from/to a secondary lpGBT via the primary lpGBT's EC-channel,
or from/to a secondary lpGBT via an I2C Master of a primary lpGBTv1/v2.

Read or write a single byte from or to the given GBTX/lpGBT register address
or write to multiple consecutive GBTX/lpGBT registers using the contents
of a file (i.e. ASCII file: 1 (register) byte value (hex) per line of text,
e.g. the 'TXT' file generated by the GBTXProgrammer tool,
or alternatively per line of text an address followed by a byte value,
optionally followed by a comment text.
NB: in the latter case registers are always written one-by-one,
    as the registers may be listed in any order).
Using option -C the file contents is not used to *configure* but *compared*
to the current GBTX or lpGBT register contents.

Provide a file name *or* use option -a with an address and an optional additional byte value
to read resp. write a single GBTX or lpGBT register or, without option -a,
to read (and display) *all* registers of the GBTX or lpGBT (v0 or v1/v2).

Without both option -a and file name all registers are read out and displayed
either in one IC read operation or optionally one-by-one (option -o).
Reading via another lpGBT I2C Master (option -s) is either one-by-one or in groups of 16
(the maximum number of bytes that can be read in a single I2C Master operation).

Option -t displays the register values in a format that could be used
as a 'TXT' file for this tool or the I2C-dongle GBTX programmer.
Usage:
 fice -h|V -d<devnr> -G<lnk> -0|1 -e -i<dma> -I<i2c> -Z|R -S -t|T
      -m<master> -f<khz> -s<i2c> -a<addr> <byte>|<filename>
  -h         : Show this help text.
  -V         : Show version.
  -0         : If lpGBT, assume v0 (default: auto-detect).
  -1         : If lpGBT, assume v1/v2 (default: auto-detect).
  -a <addr>  : GBTX/lpGBT register address (decimal or hex, 0x.. or x..)
               to read or write.
  -C         : In combination with <filename>: compare GBTX/lpGBT register
               contents to file contents and display the differences.
  -d <devnr> : FLX-device to use (default: 0).
  -e         : Use the lpGBT EC-channel to access a secondary lpGBT.
  -f <freq>  : I2C Master bus frequency, in KHz
               (only with -s; 100,200,400 or 1000; default:100).
  -G <lnk>   : GBT-link number (required).
  -i <dma>   : FLX-device DMA controller for receiving (default: 0).
  -I <i2c>   : GBTX/lpGBT I2C address (hexadecimal; optional).
  -m <master>: I2C Master index (only with -s; 0,1 or 2; default:0).
  -o         : When reading or writing all (consecutive) registers, do it one-by-one
               (default: single multi-register read/write operation when possible).
  -R         : Receive replies on any E-link.
  -s <i2c>   : I2C address (hex) of a secondary lpGBT accessed via an lpGBTv1
               I2C Master (NB: use option -0 to access an lpGBTv0 like this).
               (to be tested: use -Y<i2c> to execute I2C operation with one DMA op)
  -S         : Skip 'soft reset' at start-up.
  -t         : Display one register value per line in output
               (i.e. 'TXT'-format like).
  -T         : Display one address + register value per line in output
               (i.e. similar to 'TXT'-format, but different..).
  -Z         : Do NOT receive and process/display replies.
 <byte>      : Byte value (decimal or hex, 0x.. or x..) to write to
               a GBTX/lpGBT register (option -a).
 <filename>  : Name of text file with GBTX/lpGBT (hex) register data to compare against,
               or to write to consecutive registers (if one value per line;
               also accepts files with address+value (both hex) per line,
               separated by a space, in which case registers are written one-by-one).
=> Examples:
(NB: option -I may be left out, in which case I2C addresses 0x70 to 0x77
     will be probed in sequence until a GBTX or lpGBT is detected)
Read all registers of GBTX/lpGBT (I2C address 0x71)
connected to FLX-device GBT link 3:
  fice -G3 -I71
Read GBTX/lpGBT register 32 (0x20):
  fice -G3 -I71 -a 32 (or: fice -G 1 -I 3 -a 0x20)
Write 0xA5 to GBTX/lpGBT register 32 (0x20):
  fice -G3 -I71 -a 32 0xA5
Write contents of GBT-conf.txt to GBTX/lpGBT registers:
  fice -G3 -I71 GBT-conf.txt
Compare contents of GBT-conf.txt to GBTX/lpGBT registers:
  fice -G3 -I71 -C GBT-conf.txt
Read all registers of a secondary lpGBT (I2C address 0x72)
connected to the EC-link of an lpGBT connected to FLX-device link 3:
  fice -G3 -I72 -e 
Read all registers of a secondary lpGBTv1 or v2 (for v0 add option -0) (I2C address 0x72)
connected to I2C Master 1 (@400KHz) of an lpGBTv1 (I2C address 0x71)
connected to FLX-device link 3:
  fice -G3 -I71 -s72 -m1 -f400 
