typedef struct{ long task; // Variable: Task address pointer float *iptr1; // Input: First input pointer float *dbuff_ptr; // pointer to the location of the data buffer float trig_value; // Input: Trigger point int prescalar; // Parameter: Data log pre scale int skip_cntr; // Variable: Data log skip counter int cntr; // Variable: Data log counter float *write_ptr; // Variable: Graph address pointer int size; // Parameter: Maximum data buffer int current_state; // current state 1= Wait for trigger, 2 = check for rising edge , 3= log data , 4= reset data log int (*init)(); // Pointer to init function int (*update)(); // Pointer to update function } DLOG_CH; // the init function should update the state to be 1 , i.e. wait for trigger DLOG_CH_update() { switch(current_state) { case 1: // if the value is already greater than the trig value then do not trigger // if the value is smaller than trigger value then wait for rising edge if(*iptr1trig_value) // the value crossed the trigger value in the rising edge current_state=3; // start logging data break; case 3: skip_cntr++; if(skip_cntr==prescalar) { // log data *write_ptr=*iptr1; write_ptr++; // move the data buffer pointer to the next location skip_ctr=0; cntr++; } if(cntr==size) { current_state=4; // finished buffering data for this trigger, reset datalogger } break; case 4: write_ptr=dbuff_ptr; // point the write buffer to the first buffer location cntr=0; current_state=1; // now keep on waiting for trigger break; } }