1 /*!
2  * \file t_mykonos_gpio.h
3  * \brief Mykonos GPIO error handling and type defines
4  *
5  * Mykonos API version: 1.5.1.3565
6  */
7 
8 /**
9 * \page Disclaimer Legal Disclaimer
10 * Copyright 2015-2017 Analog Devices Inc.
11 * Released under the AD9371 API license, for more information see the "LICENSE.txt" file in this zip file.
12 *
13 */
14 
15 #ifndef T_MYKONOSGPIO_H_
16 #define T_MYKONOSGPIO_H_
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 
23 #include "common.h"
24 
25 /**
26  *  \brief Enum of unique error codes from the Mykonos GPIO API functions.
27  * Each error condition in the library should get its own enum value to allow
28  * easy debug of errors.
29  */
30 typedef enum
31 {
32 	MYKONOS_ERR_GPIO_OK = 0,
33 	MYKONOS_ERR_EN_MONITOR_OUT_NOT_ENABLED,
34     MYKONOS_ERR_EN_MONITOR_OUT_SRC_CTRL,
35     MYKONOS_ERR_MONITOR_OUT_INDEX_RANGE,
36     MYKONOS_ERR_GETGPIOMON_INDEX_NULL_PARM,
37     MYKONOS_ERR_GETGPIOMON_MONITORMASK_NULL_PARM,
38 
39     MYKONOS_ERR_MGCRX2_GPIO_DECPIN_INV_PARAM,
40     MYKONOS_ERR_MGCRX2_GPIO_INCPIN_INV_PARAM,
41     MYKONOS_ERR_MGCRX2_SOURCE_CONFIG,
42     MYKONOS_ERR_MGCRX2_STEP_INV_PARAM,
43     MYKONOS_ERR_MGCRX1_GPIO_DECPIN_INV_PARAM,
44     MYKONOS_ERR_MGCRX1_GPIO_INCPIN_INV_PARAM,
45     MYKONOS_ERR_MGCRX1_STEP_INV_PARAM,
46     MYKONOS_ERR_GETRX2PIN_INCSTEP_NULL_PARM,
47     MYKONOS_ERR_GETRX2PIN_DECSTEP_NULL_PARM,
48     MYKONOS_ERR_GETRX2PIN_INCPIN_NULL_PARM,
49     MYKONOS_ERR_GETRX2PIN_DECPIN_NULL_PARM,
50     MYKONOS_ERR_GETRX2PIN_EN_NULL_PARM,
51     MYKONOS_ERR_GETRX1PIN_INCSTEP_NULL_PARM,
52     MYKONOS_ERR_GETRX1PIN_DECSTEP_NULL_PARM,
53     MYKONOS_ERR_GETRX1PIN_INCPIN_NULL_PARM,
54     MYKONOS_ERR_GETRX1PIN_DECPIN_NULL_PARM,
55     MYKONOS_ERR_GETRX1PIN_EN_NULL_PARM,
56 
57     MYKONOS_ERR_TPCTX2_GPIO_DECPIN_INV_PARAM,
58     MYKONOS_ERR_TPCTX2_GPIO_INCPIN_INV_PARAM,
59     MYKONOS_ERR_TPCTX2_GPIO_STEP_INV_PARAM,
60     MYKONOS_ERR_TPCTX1_GPIO_DECPIN_INV_PARAM,
61     MYKONOS_ERR_TPCTX1_GPIO_INCPIN_INV_PARAM,
62     MYKONOS_ERR_TPCTX1_GPIO_STEP_INV_PARAM,
63     MYKONOS_ERR_GETTX2PIN_STEP_NULL_PARM,
64     MYKONOS_ERR_GETTX2PIN_INC_NULL_PARM,
65     MYKONOS_ERR_GETTX2PIN_DEC_NULL_PARM,
66     MYKONOS_ERR_GETTX2PIN_EN_NULL_PARM,
67     MYKONOS_ERR_GETTX2PIN_TX1TX2_NULL_PARM,
68     MYKONOS_ERR_GETTX1PIN_STEP_NULL_PARM,
69     MYKONOS_ERR_GETTX1PIN_INC_NULL_PARM,
70     MYKONOS_ERR_GETTX1PIN_DEC_NULL_PARM,
71     MYKONOS_ERR_GETTX1PIN_EN_NULL_PARM,
72     MYKONOS_ERR_GETTX1PIN_TX1TX2_NULL_PARM,
73 
74 	MYKONOS_ERR_SPI2_INV_GPIO,
75 	MYKONOS_ERR_SPI2_INV_SETUP,
76 
77 	MYKONOS_ERR_SET_GPIO_1V8_INV_POINTER,
78 
79 	MYKONOS_ERR_GETGPIOSETLEVEL_NULL_PARM,
80 	MYKONOS_ERR_READGPIOSPI_NULL_PARM,
81     MYKONOS_ERR_SET_GPIO_1V8_INV_MODE,
82     MYKONOS_ERR_GETGPIO_OE_NULL_PARM,
83     MYKONOS_ERR_GPIO_OE_INV_PARAM,
84     MYKONOS_ERR_GPIO_SRC_PARAM_INV,
85     MYKONOS_ERR_GET_GPIO_SOURCE_CONTROL_NULL_PARM,
86 
87     MYKONOS_ERR_INV_GP_INT_MASK_PARM,
88     MYKONOS_ERR_GP_INT_STATUS_NULL_PARAM,
89 
90     MYKONOS_ERR_GETGPIO3V3OUT_NULL_PARM,
91     MYKONOS_ERR_SET_GPIO_3V3_INV_POINTER,
92     MYKONOS_ERR_GETGPIO3V3SPI_NULL_PARM,
93     MYKONOS_ERR_GPIO3V3OUTEN_NULL_PARM,
94     MYKONOS_ERR_SET_GPIO_3V3_INV_MODE,
95     MYKONOS_ERR_SET_GPIO_3V3_INV_SRC_CTRL,
96 
97     MYKONOS_ERR_SET_ARMGPIO_INV_POINTER,
98     MYKONOS_ERR_SET_ARMGPIO_PINS_ARMERROR,
99     MYKONOS_ERR_SET_ARMGPIO_PINS_INV_SIGNALID,
100     MYKONOS_ERR_SET_ARMGPIO_PINS_INV_GPIOPIN,
101 
102     MYKONOS_ERR_SETUPAUXDAC_NULL_PARAM,
103     MYKONOS_ERR_WRITEAUXDAC_NULL_AUXIO,
104     MYKONOS_ERR_READAUXADC_NULL_PARAM,
105     MYKONOS_ERR_SETUPAUXDAC_INV_AUXDACCODE,
106     MYKONOS_ERR_WRITEAUXDAC_INV_AUXDACCODE,
107     MYKONOS_ERR_WRITEAUXDAC_INV_AUXDACINDEX,
108     MYKONOS_ERR_INV_AUX_ADC_CHAN_PARM,
109     MYKONOS_ERR_SETUPAUXADC_INV_VCODIV,
110     MYKONOS_ERR_INV_AUX_ADC_DEC_PARM,
111 
112     MYKONOS_ERR_GAINCOMP_NULL_STRUCT,
113     MYKONOS_ERR_GAINCOMP_EN_NULL_PARM,
114     MYKONOS_ERR_GAINCOMP_SET_NULL_STRUCT,
115     MYKONOS_ERR_GAINCOMP_INV_RX1_OFFSET,
116     MYKONOS_ERR_GAINCOMP_INV_RX2_OFFSET,
117     MYKONOS_ERR_GAINCOMP_INV_STEP,
118     MYKONOS_ERR_GAINCOMP_INV_EN,
119 
120     MYKONOS_ERR_OBS_RX_GAINCOMP_SET_NULL_STRUCT,
121     MYKONOS_ERR_OBS_RX_GAINCOMP_EN_NULL_PARAM,
122     MYKONOS_ERR_OBS_RX_GAINCOMP_INV_EN,
123     MYKONOS_ERR_OBS_RX_GAINCOMP_INV_OFFSET,
124     MYKONOS_ERR_OBS_RX_GAINCOMP_INV_STEP,
125     MYKONOS_ERR_OBS_RX_GAINCOMP_NULL_STRUCT,
126 
127     MYKONOS_ERR_SLICER_STEP_OUT_OF_RANGE,
128     MYKONOS_ERR_SLICER_INV_RX1_SEL,
129     MYKONOS_ERR_SLICER_INV_RX2_SEL,
130     MYKONOS_ERR_SLICER_EN_INV,
131 
132     MYKONOS_ERR_SLICER_RX1PIN_NULL_PARM,
133     MYKONOS_ERR_SLICER_RX2PIN_NULL_PARM,
134     MYKONOS_ERR_SLICER_STEP_NULL_PARM,
135     MYKONOS_ERR_SLICER_EN_NULL_PARM,
136 
137     MYKONOS_ERR_SLICER_INV_OBS_RX_SEL,
138     MYKONOS_ERR_SLICER_OBS_RX_STEP_OUT_OF_RANGE,
139     MYKONOS_ERR_SLICER_OBS_RX_EN_INV,
140     MYKONOS_ERR_SLICER_OBS_RX_EN_NULL_PARM,
141     MYKONOS_ERR_SLICER_OBS_RX_STEP_NULL_PARM,
142     MYKONOS_ERR_SLICER_OBS_RXPIN_NULL_PARM,
143 
144     MYKONOS_ERR_FLOATFRMT_NULL_STRUCT,
145     MYKONOS_ERR_FLOATFRMT_SET_NULL_STRUCT,
146     MYKONOS_ERR_FLOATFRMT_INV_ROUND_MODE,
147     MYKONOS_ERR_FLOATFRMT_INV_DATA_FORMAT,
148     MYKONOS_ERR_FLOATFRMT_INV_ENC_NAN,
149     MYKONOS_ERR_FLOATFRMT_INV_EXP_BITS,
150     MYKONOS_ERR_FLOATFRMT_INV_LEADING,
151     MYKONOS_ERR_FLOATFRMT_INV_RX1ATT,
152     MYKONOS_ERR_FLOATFRMT_INV_RX2ATT,
153     MYKONOS_ERR_FLOATFRMT_INV_EN,
154     MYKONOS_ERR_FLOATFRMT_NULL_RX1ATT,
155     MYKONOS_ERR_FLOATFRMT_NULL_RX2ATT,
156     MYKONOS_ERR_FLOATFRMT_NULL_ENABLE,
157     MYKONOS_ERR_FLOATFRMT_SET_INV_EN,
158     MYKONOS_ERR_FLOATFRMT_SET_INV_RX1ATT,
159     MYKONOS_ERR_FLOATFRMT_SET_INV_RX2ATT,
160 
161     MYKONOS_ERR_FLOATFRMT_INV_ORXATT,
162     MYKONOS_ERR_FLOATFRMT_INV_ORXEN,
163     MYKONOS_ERR_FLOATFRMT_NULL_ORXATT,
164     MYKONOS_ERR_FLOATFRMT_NULL_ORXENABLE,
165 
166     MYKONOS_ERR_SETUPTEMPSENSOR_NULL_PARAM,
167     MYKONOS_ERR_SETUPTEMPSENSOR_INV_TEMPDECIMATION,
168     MYKONOS_ERR_SETUPTEMPSENSOR_INV_OFFSET,
169     MYKONOS_ERR_SETUPTEMPSENSOR_INV_TEMPWINDOW,
170     MYKONOS_ERR_GETTEMPSENSORCFG_NULL_PARAM,
171     MYKONOS_ERR_READTEMPSENSOR_NULL_PARAM,
172     MYKONOS_ERR_READTEMPSENSOR_NOT_LOCKED,
173 
174     MYKONOS_ERR_GAIN_CONTROL_NOT_HYBRID,
175     MYKONOS_ERR_GPIO_HYBRID_RX1_PIN,
176     MYKONOS_ERR_GPIO_HYBRID_RX2_PIN,
177     MYKONOS_ERR_GPIO_HYBRID_RX1_PIN_NULL_PARM,
178     MYKONOS_ERR_GPIO_HYBRID_RX2_PIN_NULL_PARM,
179     MYKONOS_ERR_GPIO_HYBRID_RX1_PIN_READ,
180     MYKONOS_ERR_GPIO_HYBRID_RX2_PIN_READ,
181     MYKONOS_ERR_AGC_OBS_NOT_IN_HYBRID,
182     MYKONOS_ERR_GPIO_HYBRID_ORX_PIN,
183     MYKONOS_ERR_GPIO_HYBRID_ORX_PIN_NULL_PARM,
184 
185     MYKONOS_ERR_GAIN_CONTROL_NOT_AGC,
186     MYKONOS_ERR_GPIO_AGC_SYNC_RX1_PIN,
187     MYKONOS_ERR_GPIO_AGC_SYNC_RX2_PIN,
188     MYKONOS_ERR_GPIO_AGC_SYNC_RX1_PIN_NULL_PARM,
189     MYKONOS_ERR_GPIO_AGC_SYNC_RX2_PIN_NULL_PARM,
190     MYKONOS_ERR_OBS_GAIN_CONTROL_NOT_AGC,
191     MYKONOS_ERR_GPIO_AGC_SYNC_ORX_PIN,
192     MYKONOS_ERR_GPIO_AGC_SYNC_ORX_PIN_NULL_PARM,
193 
194     MYKONOS_ERR_GETGPIODRV_NULL_PARAM,
195     MYKONOS_ERR_GPIO_DRV_INV_PARAM,
196 
197     MYKONOS_ERR_GPIO_SLEW_RATE_INV_PARAM,
198     MYKONOS_ERR_GPIO_GETSLEW_NULL_PARAM,
199 
200     MYKONOS_ERR_CMOS_DRV_INV_PARAM,
201     MYKONOS_ERR_CMOS_DRV_NULL_PARAM
202 } mykonosGpioErr_t;
203 
204 /**
205  *  \brief Enum of possible Rx Slicer pin combinations
206  */
207 typedef enum
208 {
209     GPIO_0_1_2      = 0,    /*!< GPIO combination for RX1        */
210     GPIO_5_6_7      = 1,    /*!< GPIO combination for RX1 or RX2 */
211     GPIO_8_9_10     = 2,    /*!< GPIO combination for RX1        */
212     GPIO_11_12_13   = 3     /*!< GPIO combination for RX2        */
213 } mykonosRxSlicer_t;
214 
215 /**
216  *  \brief Enum of possible observation channel Slicer pin combinations
217  */
218 typedef enum
219 {
220     GPIO_18_17_16      = 0,    /*!< GPIO combination for observation channel */
221     GPIO_16_15_14      = 1     /*!< GPIO combination for observation channel */
222 } mykonosObsRxSlicer_t;
223 
224 /**
225  *  \brief Enum of possible GPIO slew rate settings
226  */
227 typedef enum
228 {
229     MYK_SLEWRATE_NONE    = 0,    /*!< Lower slew rate for the GPIO  */
230     MYK_SLEWRATE_LOW     = 1,    /*!< Low slew rate for the GPIO    */
231     MYK_SLEWRATE_MEDIUM  = 2,    /*!< Medium slew rate for the GPIO */
232     MYK_SLEWRATE_HIGH    = 3     /*!< High slew rate for the GPIO   */
233 } mykonosGpioSlewRate_t;
234 
235 /**
236  * \brief Enumerated list of CMOS pads drive strength options
237  */
238 typedef enum
239 {
240     MYK_CMOSPAD_DRV_1X  = 0x00,       /*!<  2.5pF  load @ 65MHz */
241     MYK_CMOSPAD_DRV_2X  = 0x01,       /*!<    5pF  load @ 65MHz */
242     MYK_CMOSPAD_DRV_3X  = 0x03,       /*!<  7.5pF  load @ 65MHz */
243     MYK_CMOSPAD_DRV_4X  = 0x07,       /*!<   10pF  load @ 65MHz */
244     MYK_CMOSPAD_DRV_5X  = 0x0F        /*!< 12.5pF  load @ 65MHz */
245 } mykonosCmosPadDrvStr_t;
246 
247 
248 /**
249  * \brief Enumerated list for Aux ADCs
250  */
251 typedef enum
252 {
253     MYK_AUXADC_0        = 0x00,       /*!< Aux ADC channel 0 */
254     MYK_AUXADC_1        = 0x01,       /*!< Aux ADC channel 1 */
255     MYK_AUXADC_2        = 0x02,       /*!< Aux ADC channel 2 */
256     MYK_AUXADC_3        = 0x03,       /*!< Aux ADC channel 3 */
257     MYK_AUXADC_0_DIV2   = 0x04,       /*!< Aux ADC channel 0 with the divider by 2 set */
258     MYK_TEMPSENSOR      = 0x10        /*!< Temperature sensor channel */
259 } mykonosAuxAdcChannels_t;
260 
261 
262 /**
263  *  \brief Data structure to hold Gain compensation settings for the main receive channels
264  **/
265 typedef struct
266 {
267     uint8_t rx1Offset;  /*!< These parameter contains the Rx1 offset word used for the gain compensation
268                         when the gain index is at its maximum setting.
269                          It has a range of 0 to 0x1F with a resolution is 0.5dB per LSB. */
270     uint8_t rx2Offset;  /*!< These parameter contains the Rx2 offset word used for the gain compensation
271                         when the gain index is at its maximum setting.
272                         It has a range of 0 to 0x1F with a resolution is 0.5dB per LSB. */
273     uint8_t compStep;   /*!< These bits contains the value in dB that the total Rx gain changes
274                          when there is an LSB change in the gain index according to the following settings:
275                          compStep |  dB ramp
276                          ---------|------------
277                             0     |   0.25dB
278                             1     |   0.5dB
279                             2     |   1.0dB
280                             3     |   2.0dB
281                             4     |   3.0dB
282                             5     |   4.0dB
283                             6     |   6.0dB
284                             7     |   Not valid defaulted to 0.25dB */
285 } mykonosGainComp_t;
286 
287 /**
288  *  \brief Data structure to hold Gain compensation settings for the observation channel
289  **/
290 typedef struct
291 {
292     uint8_t obsRxOffset;    /*!< These parameter contains the Rx1 offset word used for the gain compensation
293                             when the gain index is at its maximum setting.
294                             It has a range of 0 to 0x1F with a resolution is 0.5dB per LSB. */
295     uint8_t compStep;       /*!< These bits contains the value in dB that the total Rx gain changes
296                             when there is an LSB change in the gain index according to the following settings:
297                             compStep |  dB ramp
298                             ---------|------------
299                                0     |   0.25dB
300                                1     |   0.5dB
301                                2     |   1.0dB
302                                3     |   2.0dB
303                                4     |   3.0dB
304                                5     |   4.0dB
305                                6     |   6.0dB
306                                7     |   Not valid defaulted to 0.25dB */
307 } mykonosObsRxGainComp_t;
308 
309 /**
310  * \brief Data structure to hold floating point formatter settings for the floating point
311  *  number generation
312  **/
313 typedef struct
314 {
315    uint8_t roundMode;   /*!<These parameter set the round modes for the significand.
316                         The following settings are defined in the IEEE754 specification:
317                         roundMode |  Round type
318                         ----------|-----------------
319                              0    |  RoundTiesToEven
320                              1    |  RoundTowardsPositive
321                              2    |  RoundTowardsNegative
322                              3    |  RoundTowardsZero
323                              4    |  RoundTiesToAway*/
324    uint8_t dataFormat;  /*!< These parameter sets the format of the 16-bit output on the JESD interface:
325                         Setting this to 1 then the format is from MSB to LSB to {sign, significand, exponent}.
326                         Clearing this bit sets the format to {sign, exponent, significand}.*/
327    uint8_t encNan;      /*!< if this parameter is set to 1 then the floating point formatter reserves the highest value
328                         of exponent for NaN to be compatible to the IEEE754 specification.
329                         Clearing this parameter increases the range of the exponent by one.*/
330    uint8_t expBits;     /*!<These parameter is used to indicate the number of exponent bits in the floating point number
331                         according to the following settings:
332                           expBits|  Round type
333                          --------|------------------------------------------------
334                             0    |  2 bit exponent, 13 bit significand, 1 bit sign
335                             1    |  3 bit exponent, 12 bit significand, 1 bit sign
336                             2    |  4 bit exponent, 11 bit significand, 1 bit sign
337                             3    |  5 bit exponent, 10 bit significand, 1 bit sign */
338    uint8_t leading;     /*!< Setting this parameter hides the leading one in the the significand to be compatible to the IEEE754 specification.
339                         Clearing this parameter causes the leading one to be at the MSB of the significand.*/
340 }mykonosFloatPntFrmt_t;
341 
342 /**
343  *  \brief Data structure used to configure the on-die Temperature Sensor
344  */
345 typedef struct
346 {
347     uint8_t tempDecimation;      /*!<3-bit value that controls the AuxADC decimation factor when used for temp sensor calculations;
348                                  AuxADC_decimation = 256 * 2^tempDecimation */
349     uint8_t offset;              /*!< 8-bit offset that gets added to temp sensor code internally */
350     uint8_t overrideFusedOffset; /*!< This bit overrides the factory-calibrated fuse offset
351                                  and uses the value stored in the offset member */
352     uint8_t tempWindow;          /*!<  4-bit code with a resolution of 1?C/LSB, each time a temperature measurement is performed,
353                                  the device compares the current temperature against the previous value.*/
354 }mykonosTempSensorConfig_t;
355 
356 
357 /**
358  *  \brief Data structure used to store Temperature Sensor related values
359  */
360 typedef struct
361 {
362     int16_t tempCode;       /*!< 16-bit signed temperature value (in deg C) that is read back */
363     uint8_t windowExceeded; /*!< If the absolute value of the difference is greater than the value in temperature configuration
364                             tempWindow, the windowExceeded flag is set.*/
365     uint8_t windowHiLo;     /*!<when windowExceeded member gets set,
366                             this bit is set to 1 if current value is greater than previous value, else reset */
367     uint8_t tempValid;      /*!< When the reading is complete and a valid temperature value stored in tempCode*/
368 }mykonosTempSensorStatus_t;
369 
370 
371 #ifdef __cplusplus
372 }
373 #endif
374 
375 #endif /* T_MYKONOSGPIO_H_ */
376