Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/adrv9371x/common.h

raw symbols SCIP
1 // ***************************************************************************
2 // ***************************************************************************
3 // Copyright 2011(c) Analog Devices, Inc.
4 //
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without modification,
8 // are permitted provided that the following conditions are met:
9 // - Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // - Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in
13 // the documentation and/or other materials provided with the
14 // distribution.
15 // - Neither the name of Analog Devices, Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived
17 // from this software without specific prior written permission.
18 // - The use of this software may or may not infringe the patent rights
19 // of one or more patent holders. This license does not release you
20 // from the requirement that you obtain separate licenses from these
21 // patent holders to use this software.
22 // - Use of the software either in source or binary form, must be run
23 // on or directly connected to an Analog Devices Inc. component.
24 //
25 // THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
26 // INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
27 // PARTICULAR PURPOSE ARE DISCLAIMED.
28 //
29 // IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY
31 // RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
34 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 // ***************************************************************************
36 // ***************************************************************************
37
38 #ifndef _COMMON_H_
39 #define _COMMON_H_
40
41 #include "stdint.h"
42
43 #define AD9528_RESET_B 59
44 #define AD9528_SYSREF_REQ 58
45 #define AD9371_TX1_ENABLE 57
46 #define AD9371_TX2_ENABLE 56
47 #define AD9371_RX1_ENABLE 55
48 #define AD9371_RX2_ENABLE 54
49 #define AD9371_TEST 53
50 #define AD9371_RESET_B 52
51 #define AD9371_GPINT 51
52 #define AD9371_GPIO_00 50
53 #define AD9371_GPIO_01 49
54 #define AD9371_GPIO_02 48
55 #define AD9371_GPIO_03 47
56 #define AD9371_GPIO_04 46
57 #define AD9371_GPIO_05 45
58 #define AD9371_GPIO_06 44
59 #define AD9371_GPIO_07 43
60 #define AD9371_GPIO_15 42
61 #define AD9371_GPIO_08 41
62 #define AD9371_GPIO_09 40
63 #define AD9371_GPIO_10 39
64 #define AD9371_GPIO_11 38
65 #define AD9371_GPIO_12 37
66 #define AD9371_GPIO_14 36
67 #define AD9371_GPIO_13 35
68 #define AD9371_GPIO_17 34
69 #define AD9371_GPIO_16 33
70 #define AD9371_GPIO_18 32
71
72 #define SPIARRAYSIZE 1024
73 #define SPIARRAYTRIPSIZE ((SPIARRAYSIZE / 3) * 3)
74
75 /* all fancy software stuff */
76
77 typedef enum
78 {
79 ADIERR_OK=0,
80 ADIERR_INV_PARM,
81 ADIERR_FAILED
82 } ADI_ERR;
83
84 typedef enum
85 {
86 COMMONERR_OK=0,
87 COMMONERR_FAILED
88 } commonErr_t;
89
90 typedef enum
91 {
92 ADIHAL_LOG_NONE = 0x0,
93 ADIHAL_LOG_MESSAGE = 0x1,
94 ADIHAL_LOG_WARNING = 0x2,
95 ADIHAL_LOG_ERROR = 0x4,
96 ADIHAL_LOG_SPI = 0x8,
97 ADIHAL_LOG_AXI_REG = 0x10,
98 ADIHAL_LOG_AXI_MEM = 0x20,
99 ADIHAL_LOG_ALL = 0x3F
100 } ADI_LOGLEVEL;
101
102 /* spi settings */
103
104 typedef struct
105 {
106 uint8_t chipSelectIndex; // system chip-select bus (or index) of ad9371
107 uint8_t writeBitPolarity; // must be 0x0 for write (inverted for read, so read msb is 0x1)
108 uint8_t longInstructionWord; // must be 0x1 for 16bit addresses (not sure if api ever does 8 bit addressing)
109 uint8_t MSBFirst; // must be 0x1 for msb first (forget about lsb-first)
110 uint8_t CPHA; // set it to 0x0, you may override in your actual function call
111 uint8_t CPOL; // set it to 0x0, you may override in your actual function call
112 uint8_t enSpiStreaming; // must be 0x0 (not sure if api does it-- allows a bunch of writes/reads)
113 uint8_t autoIncAddrUp; // must be 0x0 (probably ignored because no streaming is supported)
114 uint8_t fourWireMode; // set it to 0x1, unless you are using 3 wire mode
115 uint32_t spiClkFreq_Hz; // set it to the spi frequency
116 } spiSettings_t;
117
118 /* global variable so application layer can set the log level */
119
120 extern ADI_LOGLEVEL CMB_LOGLEVEL;
121
122 /* close hardware pointers */
123
124 commonErr_t CMB_closeHardware(void);
125
126 /* GPIO function */
127
128 commonErr_t CMB_setGPIO(uint32_t GPIO);
129
130 /* hardware reset function */
131
132 commonErr_t CMB_hardReset(uint8_t spiChipSelectIndex);
133
134 /* SPI read/write functions */
135
136 commonErr_t CMB_setSPIOptions(spiSettings_t *spiSettings);
137 commonErr_t CMB_setSPIChannel(uint16_t chipSelectIndex );
138 commonErr_t CMB_SPIWriteByte(spiSettings_t *spiSettings, uint16_t addr, uint8_t data);
139 commonErr_t CMB_SPIWriteBytes(spiSettings_t *spiSettings, uint16_t *addr, uint8_t *data, uint32_t count);
140 commonErr_t CMB_SPIReadByte (spiSettings_t *spiSettings, uint16_t addr, uint8_t *readdata);
141 commonErr_t CMB_SPIWriteField(spiSettings_t *spiSettings, uint16_t addr, uint8_t field_val, uint8_t mask, uint8_t start_bit);
142 commonErr_t CMB_SPIReadField (spiSettings_t *spiSettings, uint16_t addr, uint8_t *field_val, uint8_t mask, uint8_t start_bit);
143
144 /* platform timer functions */
145
146 commonErr_t CMB_wait_ms(uint32_t time_ms);
147 commonErr_t CMB_wait_us(uint32_t time_us);
148 commonErr_t CMB_setTimeout_ms(uint32_t timeOut_ms);
149 commonErr_t CMB_setTimeout_us(uint32_t timeOut_us);
150 commonErr_t CMB_hasTimeoutExpired();
151
152 /* platform logging functions */
153
154 commonErr_t CMB_openLog(const char *filename);
155 commonErr_t CMB_closeLog(void);
156 commonErr_t CMB_writeToLog(ADI_LOGLEVEL level, uint8_t deviceIndex, uint32_t errorCode, const char *comment);
157 commonErr_t CMB_flushLog(void);
158
159 /* platform FPGA AXI register read/write functions */
160
161 commonErr_t CMB_regRead(uint32_t offset, uint32_t *data);
162 commonErr_t CMB_regWrite(uint32_t offset, uint32_t data);
163
164 /* platform DDR3 memory read/write functions */
165
166 commonErr_t CMB_memRead(uint32_t offset, uint32_t *data, uint32_t len);
167 commonErr_t CMB_memWrite(uint32_t offset, uint32_t *data, uint32_t len);
168
169 #endif
170
171 // ***************************************************************************
172 // ***************************************************************************