3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 /*******************************************************/
26 /* abstract: This file contains a description of the */
27 /* data structure "lenval". */
28 /*******************************************************/
33 /* the lenVal structure is a byte oriented type used to store an */
34 /* arbitrary length binary value. As an example, the hex value */
35 /* 0x0e3d is represented as a lenVal with len=2 (since 2 bytes */
36 /* and val[0]=0e and val[1]=3d. val[2-MAX_LEN] are undefined */
38 /* maximum length (in bytes) of value to read in */
39 /* this needs to be at least 4, and longer than the */
40 /* length of the longest SDR instruction. If there is, */
41 /* only 1 device in the chain, MAX_LEN must be at least */
42 /* ceil(27/8) == 4. For 6 devices in a chain, MAX_LEN */
43 /* must be 5, for 14 devices MAX_LEN must be 6, for 20 */
44 /* devices MAX_LEN must be 7, etc.. */
45 /* You can safely set MAX_LEN to a smaller number if you*/
46 /* know how many devices will be in your chain. */
50 typedef struct var_len_byte
52 short len; /* number of chars in this value */
53 unsigned char val[MAX_LEN+1]; /* bytes of data */
57 /* return the long representation of a lenVal */
58 extern long value(lenVal *x);
60 /* set lenVal equal to value */
61 extern void initLenVal(lenVal *x, long value);
63 /* check if expected equals actual (taking the mask into account) */
64 extern short EqualLenVal(lenVal *expected, lenVal *actual, lenVal *mask);
66 /* add val1+val2 and put the result in resVal */
67 extern void addVal(lenVal *resVal, lenVal *val1, lenVal *val2);
69 /* return the (byte, bit) of lv (reading from left to right) */
70 extern short RetBit(lenVal *lv, int byte, int bit);
72 /* set the (byte, bit) of lv equal to val (e.g. SetBit("00000000",byte, 1)
74 extern void SetBit(lenVal *lv, int byte, int bit, short val);
76 /* read from XSVF numBytes bytes of data into x */
77 extern void readVal(lenVal *x, short numBytes);