]>
Commit | Line | Data |
---|---|---|
9a2dd740 SR |
1 | /* |
2 | * (C) Copyright 2003 | |
3 | * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com | |
4 | * | |
1a459660 | 5 | * SPDX-License-Identifier: GPL-2.0+ |
9a2dd740 SR |
6 | */ |
7 | ||
8 | /*******************************************************/ | |
9 | /* file: lenval.h */ | |
10 | /* abstract: This file contains a description of the */ | |
11 | /* data structure "lenval". */ | |
12 | /*******************************************************/ | |
13 | ||
14 | #ifndef lenval_dot_h | |
15 | #define lenval_dot_h | |
16 | ||
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 */ | |
21 | ||
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. */ | |
31 | #define MAX_LEN 7000 | |
32 | ||
33 | ||
34 | typedef struct var_len_byte | |
35 | { | |
36 | short len; /* number of chars in this value */ | |
37 | unsigned char val[MAX_LEN+1]; /* bytes of data */ | |
38 | } lenVal; | |
39 | ||
40 | ||
41 | /* return the long representation of a lenVal */ | |
42 | extern long value(lenVal *x); | |
43 | ||
44 | /* set lenVal equal to value */ | |
45 | extern void initLenVal(lenVal *x, long value); | |
46 | ||
47 | /* check if expected equals actual (taking the mask into account) */ | |
48 | extern short EqualLenVal(lenVal *expected, lenVal *actual, lenVal *mask); | |
49 | ||
50 | /* add val1+val2 and put the result in resVal */ | |
51 | extern void addVal(lenVal *resVal, lenVal *val1, lenVal *val2); | |
52 | ||
53 | /* return the (byte, bit) of lv (reading from left to right) */ | |
54 | extern short RetBit(lenVal *lv, int byte, int bit); | |
55 | ||
56 | /* set the (byte, bit) of lv equal to val (e.g. SetBit("00000000",byte, 1) | |
57 | equals "01000000" */ | |
58 | extern void SetBit(lenVal *lv, int byte, int bit, short val); | |
59 | ||
60 | /* read from XSVF numBytes bytes of data into x */ | |
61 | extern void readVal(lenVal *x, short numBytes); | |
62 | ||
63 | #endif |