3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
5 * SPDX-License-Identifier: GPL-2.0+
8 /*******************************************************/
10 /* abstract: This file contains a description of the */
11 /* data structure "lenval". */
12 /*******************************************************/
17 /* the lenVal structure is a byte oriented type used to store an */
18 /* arbitrary length binary value. As an example, the hex value */
19 /* 0x0e3d is represented as a lenVal with len=2 (since 2 bytes */
20 /* and val[0]=0e and val[1]=3d. val[2-MAX_LEN] are undefined */
22 /* maximum length (in bytes) of value to read in */
23 /* this needs to be at least 4, and longer than the */
24 /* length of the longest SDR instruction. If there is, */
25 /* only 1 device in the chain, MAX_LEN must be at least */
26 /* ceil(27/8) == 4. For 6 devices in a chain, MAX_LEN */
27 /* must be 5, for 14 devices MAX_LEN must be 6, for 20 */
28 /* devices MAX_LEN must be 7, etc.. */
29 /* You can safely set MAX_LEN to a smaller number if you*/
30 /* know how many devices will be in your chain. */
34 typedef struct var_len_byte
36 short len; /* number of chars in this value */
37 unsigned char val[MAX_LEN+1]; /* bytes of data */
41 /* return the long representation of a lenVal */
42 extern long value(lenVal *x);
44 /* set lenVal equal to value */
45 extern void initLenVal(lenVal *x, long value);
47 /* check if expected equals actual (taking the mask into account) */
48 extern short EqualLenVal(lenVal *expected, lenVal *actual, lenVal *mask);
50 /* add val1+val2 and put the result in resVal */
51 extern void addVal(lenVal *resVal, lenVal *val1, lenVal *val2);
53 /* return the (byte, bit) of lv (reading from left to right) */
54 extern short RetBit(lenVal *lv, int byte, int bit);
56 /* set the (byte, bit) of lv equal to val (e.g. SetBit("00000000",byte, 1)
58 extern void SetBit(lenVal *lv, int byte, int bit, short val);
60 /* read from XSVF numBytes bytes of data into x */
61 extern void readVal(lenVal *x, short numBytes);