-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyzygy.h
137 lines (120 loc) · 6.32 KB
/
syzygy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/************************************************************************/
/* */
/* syzygy.h - SYZYGY function declarations */
/* */
/************************************************************************/
/* Author: Michael T. Alexander */
/* Copyright 2019, Digilent Inc. */
/************************************************************************/
/* Module Description: */
/* */
/* This header file contains the declarations for functions that can */
/* be used to communicate with any SYZYGY pods that are attached */
/* to the shared I2C bus on the Eclypse Z7. */
/* */
/************************************************************************/
/* Revision History: */
/* */
/* 08/19/2019 (MichaelA): created */
/* 08/20/2019 (MichaelA): added declaration of structures SzgStdFwRegs */
/* and SzgDnaStrings as well as several new functions */
/* 08/27/2019 (MichaelA): added fCheckCrc parameter to the */
/* SyzygyReadDNAHeader function */
/* 01/03/2020 (MichaelA): added SyzygyI2cWrite */
/* 01/06/2020 (MichaelA): modified SyzygyI2cRead parameter types to */
/* support larger data transfers */
/* */
/************************************************************************/
#ifndef SYZYGY_H_
#define SYZYGY_H_
/* ------------------------------------------------------------ */
/* Miscellaneous Declarations */
/* ------------------------------------------------------------ */
/* Define the different types of SmartVIO ports.
*/
#define ptypeNone 0
#define ptypeSyzygyStd 1
#define ptypeSyzygyTxr2 2
#define ptypeSyzygyTxr4 3
/* Define the major and minor version of the SYZYGY DNA specification
** supported by this firmware.
*/
#define szgverMajor 1
#define szgverMinor 0
/* Define the number of bytes contained in the SZYYGY DNA header.
*/
#define cbSyzygyDnaHeader 40
/* Define the SYZYGY attribute fields.
*/
#define sattrLvds 0x0001
#define sattrDoubleWide 0x0002
#define sattrTxr4 0x0004
/* Define useful SYZYGY addresses.
*/
#define addrFlashMagic 0x6999
#define addrDnaStart 0x8000
/* Define the maximum number of bytes that can be stored in the
** SYZYGY DNA section of the pMCU flash.
*/
#define cbSyzygyDnaMax 4096
/* ------------------------------------------------------------ */
/* General Type Declarations */
/* ------------------------------------------------------------ */
typedef struct {
BYTE fwverMjr;
BYTE fwverMin;
BYTE dnaverMjr;
BYTE dnaverMin;
WORD cbEeprom;
} SzgStdFwRegs;
typedef struct {
WORD cbDna; // DNA full data length (bytes)
WORD cbDnaHeader; // DNA header length (bytes)
BYTE dnaverMjr; // SYZYGY DNA major version
BYTE dnaverMin; // SYZYGY DNA minor version
BYTE dnaverRequiredMjr; // Required SYZYGY DNA major version
BYTE dnaverRequiredMin; // Required SYZYGY DNA minor version
WORD crntRequired5v0; // Maximum operating current 5V0 rail (mA)
WORD crntRequired3v3; // Maximum operating current 3V3 rail (mA)
WORD crntRequiredVio; // Maximum operating current VIO rail (mA)
WORD fsAttributes; // Attribute flags
WORD vltgRange1Min; // VIO Range 1 minimum voltage (10mV)
WORD vltgRange1Max; // VIO Range 1 maximum voltage (10mV)
WORD vltgRange2Min; // VIO Range 2 minimum voltage (10mV)
WORD vltgRange2Max; // VIO Range 2 maximum voltage (10mV)
WORD vltgRange3Min; // VIO Range 3 minimum voltage (10mV)
WORD vltgRange3Max; // VIO Range 3 maximum voltage (10mV)
WORD vltgRange4Min; // VIO Range 4 minimum voltage (10mV)
WORD vltgRange4Max; // VIO Range 4 maximum voltage (10mV)
BYTE cbManufacturerName; // Manufacturer Name Length (bytes)
BYTE cbProductName; // Product Name Length (bytes)
BYTE cbProductModel; // Produt model / Part number length (bytes)
BYTE cbProductVersion; // Product version / revision length (bytes)
BYTE cbSerialNumber; // Serial number length (bytes)
BYTE reserved; // RESERVED field
BYTE crcHigh; // CRC-16 most significant byte
BYTE crcLow; // CRC-16 least significant byte
} SzgDnaHeader;
typedef struct {
char* szManufacturerName;
char* szProductName;
char* szProductModel;
char* szProductVersion;
char* szSerialNumber;
} SzgDnaStrings;
/* ------------------------------------------------------------ */
/* Variable Declarations */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Procedure Declarations */
/* ------------------------------------------------------------ */
BOOL SyzygyI2cRead(int fdI2cDev, BYTE addrI2cSlave, WORD addrRead, BYTE* pbRead, WORD cbRead, WORD* pcbRead);
BOOL SyzygyI2cWrite(int fdI2cDev, BYTE addrI2cSlave, WORD addrWrite, BYTE* pbWrite, WORD cbWrite, WORD* pcbWritten);
BOOL SyzygyReadStdFwRegisters(int fdI2cDev, BYTE addrI2cSlave, SzgStdFwRegs* pszgfwregs);
BOOL SyzygyReadDNAHeader(int fdI2cDev, BYTE addrI2cSlave, SzgDnaHeader* pszgdnahdr, BOOL fCheckCrc);
BOOL SyzygyReadDNAStrings(int fdI2cDev, BYTE addrI2cSlave, SzgDnaHeader* pszgdnahdr, SzgDnaStrings* pszgdnastrings);
void SyzygyFreeDNAStrings(SzgDnaStrings* pszgdnastrings);
WORD SyzygyComputeCRC(const BYTE* pbBuf, BYTE cbBuf);
BOOL IsSyzygyPort(BYTE ptypeCheck );
/* ------------------------------------------------------------ */
#endif /* SYZYGY_H_ */