1. Intro


pclock2 is Prototype Clocking code for the IRSG controller.
Code is located in /home/s2/src/pclock2 on the IRTF network.

These files can be compile into pclock(Linux Host) and sgir's uboot.

   ircommand.c/.h - commands for plcock or sgir uboot.
   ir.c/.h - ir support functions ( CE support, Seq Table).
   al.c/.h - aladdin support functions.
   h2.c/.h - h2rg support functions

Other pclock file are linux specific:

plcock.c    - appplication main file. Does the command execution.
common.c/.h - provides common or utility-type C functions.


2. Integrating into uboot


The code for  ircommand, ir, al, h2 can be execute via the sgir uboot. How?

   1. soft link needed source files. And add to Makefile

      cd gpc/src-ppc405/u-boot/daq3u_apps
      ln -s /home/s2/src/pclock2/ircommand.h
      ln -s /home/s2/src/pclock2/ircommand.c
      ln -s /home/s2/src/pclock2/ir.h
      ln -s /home/s2/src/pclock2/ir.c
      ln -s /home/s2/src/pclock2/al.h
      ln -s /home/s2/src/pclock2/al.c

      vi Makefile
         add: DAQ3U_APPS += ircommand ir al # Added by TonyD

   2. add command to the commandline interface code.

      cd gpc/src-ppc405/u-boot/common/
      vi cli_comlist.c
        1. Add prototypes, ie: extern Function t1;
        2. Add entries to cmd_table[] , ie: {"t1", t1, "test1"}


3. How thing work


ircommand.c/h hold the commands and data structure required for clocking.
Most command just set parameters, ie:
   cbmode
   coadds
   darray
   (you can view the list of commands in cli_comlist.c)

Data structure & function in ircommand.c:

   struct ir_param_t Ip;            /* parameter */

   struct ir_ce_buf_t               /* a buffer to hold CE commands */
   {
      int            n;             /* number of cmd[] entries */
      int64_t        nsec;          /* total time in ns to execute table */
      unsigned int  *cmd;           /* CE commands buffer */
   };

   struct ir_ce_buf_t  CE_sam;      /* to clock out & sample = How to clock out the device. */
   struct ir_ce_buf_t  CE_reset;    /* to clock out & reset  */

   struct ir_seq_t    Seq;           /* Sequence Table = How to use CE_sam/reset to create an image */

A demo best illustrates how thing would work:

   cd /home/s2/src/pclock2
   pclock
   show
   ndr 2
   go

   1. create all data for CE_sam, CE_reset, Seq.
        ir.c - provide function support generation of CE commands.
             - provide function to build Seq data (struct ir_seq_t Seq).
        al.c - uses  ir.c function to build aladdin clocking tables (struct ir_ce_buf_t).
        h2.g - uses  h2.c function to build H2RG    clocking tables.

   2. put all data to CE FIFO.

Show a sample of the output on logic analzyer screen:
   http://irtfweb.ifa.hawaii.edu/~s2/software/loaner_notes/ce_adc_diagram_1.png

Illustrate how to clock the aladdin array:
   http://irtfweb.ifa.hawaii.edu/~s2/software/Controller_SGIR/Aladdin_clocks_illustration.pdf


3. What to do next?


1. When clocking obtain data and put into DRAM.
      Setup of the Math Eng.
      Servicing the OCM.

2. When DRAM has a full image, transfer to linux host.
   I think at the last meeting we talked about transfering each NDR.
   (vs coadd all NDR & Coadd into a single DRAM buffer, and transfering a single image after the GO).

    Thinking the linux host needs to monitor grasp_receiver stream, then starts a
    transfer when data buffer is full.

3.  monitor sock to 'stop' ...  implement stop command to abort go_app()?


Support for streaming mode:
   1. Also need to realloc a large array (8MB)if doing small subarray/streaming mode.
   2. pack many NDR subarray into a large buffer.
   3. transfer to linux host
   4. Clocking/Sampling continues un-interrupted until user say 'stop'.