Files | |
file | barcode_sample.c |
Barcode Sampling. | |
Functions | |
void | barcodeSample (struct BC_STRUCT *p, unsigned int count) |
General purpose barcode sampling. | |
void | barcodeOverflow (struct BC_STRUCT *p) |
Barcode sample overflow. |
void barcodeOverflow | ( | struct BC_STRUCT * | p | ) |
Barcode sample overflow.
*p | points to channel context |
Definition at line 113 of file barcode_sample.c.
References BC_STRUCT::sample_ctr, BC_STRUCT::sample_ptr, and BC_STRUCT::sample_state.
00113 { 00114 00115 // Abort if less than the minimum required samples 00116 if(p->sample_ctr < MIN_BARCODE_SAMPLES){ 00117 p->sample_state = WAITING; 00118 } 00119 00120 // Store the overflow count and flag as ready 00121 else{ 00122 *p->sample_ptr++ = 0; 00123 p->sample_state = READY; 00124 } 00125 }
void barcodeSample | ( | struct BC_STRUCT * | p, | |
unsigned int | count | |||
) |
General purpose barcode sampling.
*p | points to channel context | |
count | is sample count |
Definition at line 72 of file barcode_sample.c.
References BC_STRUCT::overflow_ctr, BC_STRUCT::sample_buffer, BC_STRUCT::sample_ctr, BC_STRUCT::sample_ptr, and BC_STRUCT::sample_state.
00073 { 00074 // Leave if sample is already available 00075 if(p->sample_state == READY){ 00076 return; 00077 } 00078 00079 // Arm overflow counter 00080 p->overflow_ctr = BARCODE_OVERFLOW_TIME; 00081 00082 // Initialize if just starting 00083 if(p->sample_state != BUSY){ 00084 p->sample_ctr = 0; 00085 p->sample_ptr = p->sample_buffer; 00086 p->sample_state = BUSY; 00087 return; 00088 } 00089 00090 // Already Sampling 00091 00092 // Buffer full? 00093 if(p->sample_ctr++ >= (sizeof p->sample_buffer / 2) - 1){ 00094 00095 // Kill the sampling 00096 p->sample_ctr = 0; 00097 p->overflow_ctr = 1; 00098 p->sample_state = WAITING; 00099 return; 00100 } 00101 00102 // Store the count 00103 *p->sample_ptr++ = count; 00104 }