• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

llcontrol-sync2VRFM-core.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * File: llcontrol-sync2VRFM-core.c
00004  *
00005  * $RCSfile: llcontrol-sync2v-core.c,v $
00006  * 
00007  * Copyright (C) 2001 D-TACQ Solutions Ltd
00008  * not to be used without owner's permission
00009  *
00010  * Description:
00011  *     passive monitoring from remote RFM
00012  *
00013  * $Id: llcontrol-sync2v-core.c,v 1.3 2009/08/06 18:31:42 pgm Exp $
00014  * $Log: llcontrol-sync2v-core.c,v $
00015  * Revision 1.3  2009/08/06 18:31:42  pgm
00016  * README.RFM
00017  *
00018  * Revision 1.2  2009/04/02 13:19:01  pgm
00019  * docs away
00020  *
00021  * Revision 1.1  2009/03/26 14:52:03  pgm
00022  * split sync2v, acq216 from main core
00023  *
00024  * Revision 1.1.4.27  2009/03/26 12:40:36  pgm
00025  * reuse same dac_src for each card, avoid data overrun
00026  */
00027 
00028 /** @file llcontrol-sync2v-core.c demonstrates <b>SYNC_2V</b> mode. 
00029  - ./set.sync2v
00030  - llcontrol [opts] -W SYNC2V <a>ECM</a>
00031  
00032  - SYNC2V optimises the data transfer by reducing the number of 
00033     transfers-per-cycle to 2:
00034   - VI : all the inputs in one block.
00035   - VO : all the outputs in one block.
00036    - definitions of offsets in VI, VO are in acq32busprot.h, look for
00037     <b>LLCV2_</b>
00038 */
00039 #include "local.h"
00040 
00041 #include <assert.h>
00042 #include <stdio.h>
00043 #include <stdlib.h>
00044 
00045 #include <errno.h>
00046 #include <fcntl.h>
00047 #include <sys/ioctl.h>
00048 #include <sys/mman.h>
00049 #include <sys/stat.h>
00050 #include <sys/time.h>
00051 #include <sys/types.h>
00052 #include <stdio.h>
00053 #include <unistd.h>
00054 
00055 #include <popt.h>
00056 
00057 #include "acq32ioctl.h"
00058 #include "acq32busprot.h"
00059 
00060 #include "llif.h"
00061 #include "llprotocol.h"
00062 
00063 
00064 #include "llcontrol.h"
00065 #include "x86timer.h"
00066 
00067 #define FLAVOR "ACQ196"
00068 #include "llcontrol-core.h"
00069 
00070 
00071 static void sync_2v_updateTstats(
00072         u32 cmd, struct Card* card, struct TimingStats* tstats)
00073 /** updates timing stats from embedded host buffer data */
00074 {
00075 #define SAMPLE_SIZE (96*2)   /* WORKTODO */
00076         u32* stats = getVaddr(card->buf, card->sync_2v_offset_status_hsbt);
00077         tstats->tinst = llv2_extend32(stats[LLC_SYNC2V_IN_MBOX2], 
00078                                       stats[LLC_SYNC2V_IN_TINST]);
00079         tstats->tprocess = LLC_GET_TCYCLE(stats[LLC_SYNC2V_IN_MBOX0]);
00080 }
00081 
00082 static u32 card_sync_2v_WaitDmaDone(struct Card* card)
00083 {
00084         return card->tlatch = llv2WaitDmaDone_2v(card->mbx, 
00085                   getVaddr(card->buf, card->sync_2v_offset_status_hsbt),
00086                   card->tlatch
00087         );
00088 }
00089 
00090 void appEnterLLC_SYNC_2VRFM(void)
00091 /** set up LLCV2_INIT buffer and enter mode.
00092  *  Buffer set up as 4K block at offset 0
00093  * @todo - this overwrites settings from initV2Stats(), initV2Stats is therefore redundant.
00094 */
00095 {
00096 
00097 }
00098 
00099 int runSYNC_2VRFM(struct TestDescription *td, int soft_clock)
00100 /** runs the test SYNC_2V mode.
00101  * PSEUDO-CODE:
00102  *
00103  - (1) Clear the latch timer
00104  - (2) Set a local memory target address and arm the capture
00105  - (3) Poll for counter running (hardware counter starts on external gate)
00106  - (4) Iterate for required number of samples:
00107  - (5)     [optionally send a soft clock command]  trigger an acquisition
00108  - (6)     Wait for DMA Done - at this point data is available in target mem.
00109  *         A "real" control application is probably getting most of its calcs 
00110  *         done here rather than simply polling
00111  - (7)     [Get the latch (sample) and current uSec counters from the boards - 
00112  *          only if interested]
00113  - (8)     Check the process has not stopped (external gate high)
00114  - (b)     write data to host side buffer(LLCV2_AO_HSBS) 
00115  - (b.1)
00116          * take the incoming value on feedback_channel
00117          * and propagate to all DACS.
00118          * default is to assume HAWG on DAC0
00119          * (so feedback_channel better be 0 !),
00120          * but td->update_dacs makes a better test.
00121  - (b.15)  
00122          * special case where we are DRIVING the
00123          * initial DAC signal from host side. 
00124  - (b.2)
00125          *  simple feedforward case - just drive all DACS
00126          *  from AWG pattern.
00127  */
00128 {
00129         struct TimingStats tstats[1] = {};
00130 #define icard 0
00131         u32 cmd = LLC_MAKE_DECIM(td->decimation);
00132 
00133         INIT_TIMER;
00134         /* WORKTODO - assumes all cards now running */
00135 
00136         for ( td->iter = 0; td->iter != td->iterations; ++td->iter ){ /* (4) */
00137                                                   /* (6)+(7) */
00138                 MARK_TIME(1, "waitDmaDone() before");
00139                 tstats[icard].tlatch = waitDmaDone(EACHCARD(td));
00140                 MARK_TIME(2, "waitDmaDone() after");
00141 
00142                 if (!td->min_latency_test) {        /* (6)+(7) */
00143                         updateTstats(cmd, EACHCARD(td), &tstats[icard]);    
00144                 }
00145 
00146                 
00147                 if (td->do_work){
00148                         doApplicationWork(td, 0);
00149                 }
00150 
00151 
00152                 MARK_TIME(9, "after llCounterRunning check");
00153 
00154                 if (td->tlog){          
00155                         tstats[icard].target_poll =
00156                                         getMboxPollcount(EACHMBX(td));
00157                         MARK_TIME(10, "10");
00158                         updateTimingStats(
00159                                 td->stats_buf[icard], 
00160                                 td->iter, 
00161                                 &tstats[icard]);
00162                 }       
00163                 TIMER_CHECK_OVERFLOW;
00164         }
00165 
00166         G_quit = 1;
00167         return 0;
00168 }
00169 

Generated on Wed Jan 5 2011 for llcontrol by  doxygen 1.7.1