Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97882027
gqrsFC.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jan 7, 03:46
Size
5 KB
Mime Type
text/x-c
Expires
Thu, Jan 9, 03:46 (2 d)
Engine
blob
Format
Raw Data
Handle
23427477
Attached To
R9636 Event based gQRS for ECG signals
gqrsFC.h
View Options
#ifndef GQRSFC
#define GQRSFC
#define NPEAKS 100 /* number of peaks buffered (per signal) */
#define TAIL 300
#define TAILPEAKS 300
#define EVENT_CYCLES RT_PERF_CYCLES
#define EVENT_INSTR RT_PERF_INSTR
#define EVENT_ACTIVE RT_PERF_ACTIVE_CYCLES
#define EVENT_LD_STALL RT_PERF_LD_STALL
#define EVENT_JR_STALL RT_PERF_JR_STALL
#define EVENT_MEM_WHAIT RT_PERF_IMISS
#define EVENT_MEM_L RT_PERF_LD
#define EVENT_MEM_S RT_PERF_ST
#define EVENT_JUMP RT_PERF_JUMP
#define EVENT_BRANCH RT_PERF_BRANCH
#define EVENT_BRANCH_TAK RT_PERF_BTAKEN
#define EVENT_COMPR RT_PERF_RVC
#define EVENT_EXT_LD RT_PERF_LD_EXT
#define EVENT_EXT_ST RT_PERF_ST_EXT
#define EVENT_EXT_LD_STALL RT_PERF_LD_EXT_CYC
#define EVENT_EXT_ST_STALL RT_PERF_ST_EXT_CYC
#define EVENT_TCDM_CONT RT_PERF_TCDM_CONT
// ------------------------------------------- DATA STRUCTURES -------------------------------------------
RT_L2_DATA struct peak {
struct peak *prev, *next; /* pointers to neighbors (in time) */
int32_t time; /* time of local maximum of qfv */
int32_t amp; /* value of qfv at time of peak */
uint8_t type; /* 1: primary, 2: secondary, 0: not determined */
} peaks[NPEAKS], *cpeak;
RT_L2_DATA struct annotation{
int32_t time;
uint8_t anntyp;
}annot;
// Structure used to copy the last samples from previous tail to next head
RT_L2_DATA struct dataBatchTail{
int32_t v[TAIL_HEAD_TO_PASS*2+2];
int32_t t[TAIL_HEAD_TO_PASS*2+2];
int32_t bufferFull;
uint16_t index;
}batchDataTail;
// ------------------------------------------- FUNCTION LIST --------------------------------------------
void fc_call(void* args);
void addpeak(int32_t t, int32_t peak_amplitude);
uint8_t peaktype(struct peak *p);
void gqrs_init();
struct peak *find_missing(struct peak *r, struct peak *p);
uint8_t gQRS(int32_t t, int32_t v, int32_t returned[100][3]);
void initBatch(dataBatch *self);
uint16_t putSampleBatch(dataBatch *self, int32_t t, int32_t v);
// ------------------------------------------- FC GLOBAL VARIABLE -----------------------------------------
RT_L2_DATA uint16_t pthr; /* peak-detection threshold */
RT_L2_DATA uint16_t qthr; /* QRS-detection threshold */
RT_L2_DATA uint16_t pthmin, qthmin; /* minimum values for pthr and qthr */
RT_L2_DATA uint16_t rrdev; /* mean absolute deviation of RR from rrmean */
RT_L2_DATA uint16_t rrinc; /* maximum incremental change in rrmean */
RT_L2_DATA uint16_t rrmean; /* mean RR interval, in sample intervals */
RT_L2_DATA uint16_t rrmax; /* maximum likely RR interval */
RT_L2_DATA uint16_t rrmin; /* minimum RR interval, in sample intervals */
RT_L2_DATA uint16_t rtmax; /* maximum RT interval, in sample intervals */
RT_L2_DATA uint16_t rtmin; /* minimum RT interval, in sample intervals */
RT_L2_DATA uint16_t rtmean; /* mean RT interval, in sample intervals */
RT_L2_DATA float thresh = 1.0; /* normalized detection threshold */
RT_L2_DATA int32_t v1; /* integral of dv in qf() */
RT_L2_DATA int32_t v1norm; /* normalization for v1 */
RT_L2_DATA long q0, q1 = 0, q2 = 0, rr, rrd, rt, rtd, rtdmin;
RT_L2_DATA struct peak *p, *q = NULL, *r = NULL, *tw;
RT_L2_DATA int32_t last_peak = 0, last_qrs = 0;
RT_L2_DATA uint16_t sps = 360; /* sample intervals per second */
RT_L2_DATA uint16_t dt, dt2, dt3, dt4, smdt; /* time intervals set by gqrs_init() depending
on the sampling frequency and used by
filter functions sm() and qf(); units
are sample intervals */
//-------------------------------------------------------------------------------------------------------
// qfv is the filtered signal array, it's the return vector for the cluster dma transfer
// IMPORTANT !!!!!
// the last element of qfv is actually the last integration to return to the cluster the next call
//-------------------------------------------------------------------------------------------------------
RT_L2_DATA int32_t qfv[BODYLEN]; /* filter buffers*/
RT_L2_DATA uint16_t indexQFV = 0;
RT_L2_DATA int32_t returnedPeak[100][3]; //time, value, number of peaks
RT_L2_DATA uint8_t peakFound;
// data for DMA and cluster management
RT_L2_DATA dataBatch batchData;
RT_L2_DATA dmaAdrs adrs;
RT_L2_DATA uint8_t flagEventTerm;
// // NEDED VAR FOR PROFILING
//Global varibale for measuring
RT_L2_DATA uint32_t len;
RT_L2_DATA uint8_t analyzedPerf;
// Variables used to measure performance by CL
RT_L1_DATA rt_perf_t performanceCL[8];
RT_L2_DATA uint32_t returnedPerfCL[8][NUM_EVENT_PERF];
// Variables used to measure performance by FC
RT_L2_DATA rt_perf_t genericPerformance[1];
RT_L2_DATA uint32_t returnedPerfFC[1][NUM_EVENT_PERF];
RT_L2_DATA char tagDebug[128] = "\tdebug";
RT_L2_DATA char tagDebug2[128] = "\tdebug2";
RT_L2_DATA char outTag[64];
RT_L2_DATA uint16_t verboseDebug = 1000;
RT_L2_DATA uint8_t verboseNow;
RT_L2_DATA char num[20];
RT_L2_DATA unsigned eventPerfList[] = {
EVENT_CYCLES,
EVENT_INSTR,
EVENT_ACTIVE,
EVENT_LD_STALL,
EVENT_JR_STALL,
EVENT_MEM_WHAIT,
EVENT_MEM_L,
EVENT_MEM_S,
EVENT_JUMP,
EVENT_BRANCH,
EVENT_BRANCH_TAK,
EVENT_COMPR,
EVENT_EXT_LD,
EVENT_EXT_ST,
EVENT_EXT_LD_STALL,
EVENT_EXT_ST_STALL,
EVENT_TCDM_CONT
};
RT_L2_DATA perfSettings perfFC;
RT_L2_DATA perfSettings perfCL;
#endif
Event Timeline
Log In to Comment