int rp_LaAcqDefaultSettings(rp_handle_uio_t *handle) { rp_LaAcqGlobalTrigSet(handle,RP_TRG_ALL_MASK); rp_LaAcqSetConfig(handle, 0); //rp_LaAcqSetConfig(handle, RP_LA_ACQ_CFG_AUTO_MASK); rp_la_cfg_regset_t cfg; cfg.pre=0; cfg.pst=LA_ACQ_BUF_SIZE; rp_LaAcqSetCntConfig(handle,cfg); rp_la_trg_regset_t trg; trg.cmp_msk=0; trg.cmp_val=0; trg.edg_pos=0; trg.edg_neg=0; rp_LaAcqSetTrigSettings(handle,trg); rp_la_decimation_regset_t dec; dec.dec=0; rp_LaAcqSetDecimation(handle,dec); rp_LaAcqDisableRLE(handle); return RP_OK; }
RP_STATUS rp_RunBlock(uint32_t noOfPreTriggerSamples, uint32_t noOfPostTriggerSamples, uint32_t timebase, // int16_t oversample, double * timeIndisposedMs, //uint32_t segmentIndex, rpBlockReady rpReady, void * pParameter ) { double timeIntervalNanoseconds; uint32_t maxSamples=rp_LaAcqBufLenInSamples(&la_acq_handle); if(rp_GetTimebase(timebase,0,&timeIntervalNanoseconds,&maxSamples)!=RP_API_OK){ return RP_INVALID_TIMEBASE; } printf("\r\n timeIntervalNanoseconds: %f", timeIntervalNanoseconds); if(!(inrangeUint32 (noOfPreTriggerSamples+noOfPostTriggerSamples, 10, maxSamples))){ return RP_INVALID_PARAMETER; } printf("\r\n max: %d", maxSamples); *timeIndisposedMs=(noOfPreTriggerSamples+noOfPostTriggerSamples)*timeIntervalNanoseconds/10e6; // configure FPGA to start block mode // TODO; sampling rate rp_la_decimation_regset_t dec; dec.dec=timebase; rp_LaAcqSetDecimation(&la_acq_handle, dec); rp_la_cfg_regset_t cfg; cfg.pre=noOfPreTriggerSamples; cfg.pst=noOfPostTriggerSamples; if(rp_LaAcqSetCntConfig(&la_acq_handle, cfg)!=RP_OK){ return RP_INVALID_PARAMETER; } printf("\r\nrp_LaAcqRunAcq"); // start acq. if(rp_LaAcqRunAcq(&la_acq_handle)!=RP_OK){ rp_LaAcqStopAcq(&la_acq_handle); return RP_BLOCK_MODE_FAILED; } //rp_LaAcqFpgaRegDump(&la_acq_handle); // block till acq. is complete printf("\r\nBlocking read"); g_acq_running=true; rp_LaAcqBlockingRead(&la_acq_handle); g_acq_running=false; // make sure acq. is stopped bool isStoped; rp_LaAcqAcqIsStopped(&la_acq_handle, &isStoped); if(!isStoped){ printf("\r\n not stopped!!"); rp_LaAcqStopAcq(&la_acq_handle); return RP_BLOCK_MODE_FAILED; } // rp_DmaMemDump(&la_acq_handle); uint32_t trig_sample; uint32_t last_sample; bool rle; rp_LaAcqIsRLE(&la_acq_handle,&rle); if(rle){ // in the RLE mode we only check which was the last sample where acq. stopped uint32_t current; bool buf_ovfl; rp_LaAcqGetRLEStatus(&la_acq_handle, ¤t, &last_sample, &buf_ovfl); trig_sample=0; } else{ // get trigger position uint32_t pst_length; bool buf_ovfl; if(rp_LaAcqGetCntStatus(&la_acq_handle, &trig_sample, &pst_length, &buf_ovfl)!=RP_OK){ rp_LaAcqStopAcq(&la_acq_handle); return RP_BLOCK_MODE_FAILED; } printf("\r\n trig_sample %d, pst_length %d, buf_ovfl %d", trig_sample, pst_length, buf_ovfl); // acquired number of post samples must match to req if(pst_length!=noOfPostTriggerSamples){ rp_LaAcqStopAcq(&la_acq_handle); return RP_BLOCK_MODE_FAILED; } } // save properties of current acq. acq_data.pre_samples=noOfPreTriggerSamples; acq_data.post_samples=noOfPostTriggerSamples; acq_data.trig_sample=trig_sample; acq_data.last_sample=last_sample; // acquisition is completed -> callback RP_STATUS status=RP_API_OK; (*rpReady)(status,pParameter); rp_LaAcqStopAcq(&la_acq_handle); return RP_API_OK; }