00001 00017 /* 00018 Reader support - Copyright (C) 2009 John Dybowski - All rights reserved 00019 00020 reader_support.h is part of the ESE Auto-ID software distribution. 00021 00022 Redistribution and use in source and binary forms, with or without modification, is 00023 permitted provided that the following conditions are met: 00024 00025 Redistributions of source code must retain the above copyright notice, this list of 00026 conditions and the following disclaimer. Redistributions in binary form must reproduce 00027 the above copyright notice, this list of conditions and the following disclaimer in the 00028 documentation and/or other materials provided with the distribution. 00029 00030 The end-user documentation included with the redistribution, if any, must include the 00031 following acknowledgment: 'This product includes software developed by John Dybowski.' 00032 Alternately, this acknowledgment may appear in the software itself, if and wherever such 00033 third-party acknowledgments normally appear. 00034 00035 The name 'John Dybowski' must not be used to endorse or promote products derived from 00036 this software without prior written permission. 00037 00038 reader_support.h is free software; you can redistribute it and/or modify it under the terms 00039 of the GNU General Public License as published by the Free Software Foundation; either 00040 version 2 of the License, or (at your option) any later version. See the GNU General 00041 Public License for more details. 00042 00043 You should have received a copy of the GNU General Public License along with this software; 00044 if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00045 MA 02111-1307 USA 00046 00047 A special exception to the GPL can be applied should you wish to distribute a combined work 00048 that includes reader_support.h, without being obliged to provide the source code for any proprietary 00049 components. See the licensing section of http://www.EmbeddedSoftwareEngineering.com for full 00050 details of how and when the exception can be applied. 00051 00052 THIS SOFTWARE IS PROVIDED 'AS IS' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 00053 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00054 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JOHN DYBOWSKI OR ITS CONTRIBUTORS BE LIABLE 00055 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00056 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00057 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00058 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00059 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00060 */ 00061 00063 #define NUL 0 00064 00065 // Decode symbol ID 00066 extern unsigned char symbol; 00067 enum{NO_DATA, CODE39_DATA, CODABAR_DATA, CODEI25_DATA, MAG1_DATA, MAG2_DATA, MAG3_DATA, PROX_DATA}; 00068 00069 // Barcode sample and decode 00071 struct BC_STRUCT{ 00073 unsigned short sample_buffer[300]; 00075 unsigned short *sample_ptr; 00077 volatile unsigned short sample_ctr; 00078 unsigned char overflow_ctr; 00080 volatile unsigned char sample_state; 00082 #define WAITING 0 00083 00084 #define BUSY 1 00085 00086 #define READY 2 00087 00088 unsigned char decode_buffer[82]; 00090 unsigned char decode_count; 00091 }; 00092 00093 // Initialization routines 00094 extern void reader1_init(void); 00095 extern void reader2_init(void); 00096 00097 // Sample routines 00098 extern void barcodeSample(struct BC_STRUCT *p, unsigned int count); 00099 extern void magstripeSample(struct BC_STRUCT *p, unsigned char value); 00100 extern void wiegandSample(struct BC_STRUCT *p, unsigned char value); 00101 00102 // Sample overflow routines 00103 extern void barcodeOverflow(struct BC_STRUCT *p); 00104 extern void magstripeOverflow(struct BC_STRUCT *p); 00105 extern void wiegandOverflow(struct BC_STRUCT *p); 00106 00107 // Decode routines 00108 extern unsigned short barcode_decode(struct BC_STRUCT *p); 00109 extern unsigned short Decode39(struct BC_STRUCT *p); 00110 extern unsigned short DecodeCodabar(struct BC_STRUCT *p); 00111 extern unsigned short DecodeI25(struct BC_STRUCT *p, unsigned char len); 00112 extern unsigned short wiegand_decode(struct BC_STRUCT *p); 00113 extern unsigned short DecodeWiegand(struct BC_STRUCT *p, struct prox_cfg_struct *w); 00114 00115 // Barcode decode indicators 00116 extern unsigned char DecodeBarcodeReady0; 00117 extern unsigned char DecodeBarcodeReady1; 00118 00119 // MagStripe decode indicators 00120 extern unsigned char DecodeMagstripeReady0; 00121 extern unsigned char DecodeMagstripeReady1; 00122 00123 // Prox decode indicators 00124 extern unsigned char DecodeWiegandReady0; 00125 extern unsigned char DecodeWiegandReady1; 00126 00127 // Global definitions 00129 #define MIN_BARCODE_SAMPLES 10 00130 00131 #define BARCODE_OVERFLOW_TIME 10 00132 00133 #define MIN_WIEGAND_SAMPLES 9 00134 00135 #define WIEGAND_OVERFLOW_TIME 5 00136 00137 extern struct BC_STRUCT Reader0; 00138 extern struct BC_STRUCT Reader1;