#ifndef RF_BPM_FILTER_H #define RF_BPM_FILTER_H #ifdef __cplusplus extern "C" { #endif #include #include #define NUM_BPM_CAVS 3 #define NUM_DIGI_CHNLS 4 /* Assume a power of two or at least a multiple of 4 to maintain * vector aligmnent; since we want the freq. response (which has * half the number of samples) to also fit into vectors the * sample number should actually be a multiple of 8... */ #define BPM_CAV_NSAMPLES 128 #define MAX_CAV_BPM 10 #define WB_KIND_f 0 /* raw samples */ #define WB_KIND_F 1 /* F-resp */ #define WB_KIND_H 2 /* Filter-resp */ #define WB_KIND_h 3 /* Filter-tdom */ #define WB_KIND_E 4 /* Envelope */ typedef float BpmFilterNumber; #define SEG_RE 0 #define SEG_IM 1 #define d_re segs.data[SEG_RE] #define d_im segs.data[SEG_IM] #define NO_FC(fc) (0. == (fc)) #define NO_BW(bw) (0. == (bw)) typedef struct FilterParmsRec_ { float fc, bw, td; } FilterParmsRec, *FilterParms; typedef struct FilterCoeffsRec_ { int nsamples; BpmFilterNumber *Hre, *Him; } FilterCoeffsRec, *FilterCoeffs; typedef struct BpmCavFilterRec_ { FilterParmsRec parms; FilterCoeffsRec coeffs; } BpmCavFilterRec, *BpmCavFilter; extern epicsMutexId bpmCavFilterMutex; /* * Read-access to filter bank must lock * with bpmCavFilterBankLock() */ static __inline__ void bpmCavFilterBankLock() { epicsMutexLock(bpmCavFilterMutex); } static __inline__ void bpmCavFilterBankUnlock() { epicsMutexUnlock(bpmCavFilterMutex); } extern BpmCavFilterRec bpmCavFilterBank[MAX_CAV_BPM][NUM_BPM_CAVS]; void bpmCavCoeffsFree(BpmFilterNumber *v); int bpmCavCoeffsAlloc(FilterCoeffs c); typedef float *BpmCavFFTBuf; BpmCavFFTBuf bpmCavFFTBufAlloc(); void bpmCavFFTBufFree(BpmCavFFTBuf buf); /* NOTE: The WavBuf containing the FFT data internally * maintains a 'reference-count' so that it can * be posted 'refcnt' times. The buffer + data * are only released when the 'refcnt' reaches * zero. */ WavBuf bpmCavFFT(BpmCavFFTBuf tdSignal, unsigned refcnt); void bpmCavGenerateFilter(BpmCavFilter f); void bpmCavFilterInit(); void bpmCavLLFilterPostJob(int chnl); #ifdef __PPC__ extern int vec_task_enable(); #endif #ifdef __cplusplus }; #endif #endif