1 /*
2 * Copyright 2016-2017 NXP
3 *
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
6 *
7 * o Redistributions of source code must retain the above copyright notice, this list
8 *   of conditions and the following disclaimer.
9 *
10 * o Redistributions in binary form must reproduce the above copyright notice, this
11 *   list of conditions and the following disclaimer in the documentation and/or
12 *   other materials provided with the distribution.
13 *
14 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
15 *   contributors may be used to endorse or promote products derived from this
16 *   software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 #ifndef _FSL_XCVR_TRIM_H_
30 /* Clang-format off. */
31 #define _FSL_XCVR_TRIM_H_
32 /* Clang-format on. */
33 
34 #include "fsl_device_registers.h"
35 /*!
36 * @addtogroup xcvr
37 * @{
38 */
39 
40 /*! @file*/
41 
42 /************************************************************************************
43 *************************************************************************************
44 * Public constant definitions
45 *************************************************************************************
46 ************************************************************************************/
47 
48 /************************************************************************************
49 *************************************************************************************
50 * Public type definitions
51 *************************************************************************************
52 ************************************************************************************/
53 
54 /* \brief  The enumerations used to define the I & Q channel selections. */
55 typedef enum
56 {
57     I_CHANNEL = 0,
58     Q_CHANNEL = 1,
59     NUM_I_Q_CHAN = 2
60 } IQ_t;
61 
62 typedef enum /* Enumeration of ADC_GAIN_CAL 2 */
63 {
64     NOMINAL2 = 0,
65     BBF_NEG = 1,
66     BBF_POS = 2,
67     TZA_STEP_N0 = 3,
68     TZA_STEP_N1 = 4,
69     TZA_STEP_N2 = 5,
70     TZA_STEP_N3 = 6,
71     TZA_STEP_N4 = 7,
72     TZA_STEP_N5 = 8,
73     TZA_STEP_N6 = 9,
74     TZA_STEP_N7 = 10,
75     TZA_STEP_N8 = 11,
76     TZA_STEP_N9 = 12,
77     TZA_STEP_N10 = 13,
78     TZA_STEP_P0 = 14,
79     TZA_STEP_P1 = 15,
80     TZA_STEP_P2 = 16,
81     TZA_STEP_P3 = 17,
82     TZA_STEP_P4 = 18,
83     TZA_STEP_P5 = 19,
84     TZA_STEP_P6 = 20,
85     TZA_STEP_P7 = 21,
86     TZA_STEP_P8 = 22,
87     TZA_STEP_P9 = 23,
88     TZA_STEP_P10 = 24,
89 
90     NUM_SWEEP_STEP_ENTRIES2 = 25 /* Including the baseline entry #0. */
91 } DAC_SWEEP_STEP2_t;
92 
93 /* \brief  Defines an entry in an array of structs to describe TZA DCOC STEP and TZA_DCOC_STEP_RECIPROCAL. */
94 typedef struct
95 {
96     uint16_t dcoc_step;
97     uint16_t dcoc_step_rcp;
98 //    uint16_t dcoc_step_q;
99 //    uint16_t dcoc_step_rcp_q;
100 } TZAdcocstep_t;
101 
102 typedef struct
103 {
104     int8_t step_value; /* The offset from nominal DAC value (see sweep_step_values[]) */
105     int16_t internal_measurement; /* The value (average code) measured from DMA samples. */
106 //    uint8_t valid; /* Set to TRUE (non zero) when a value is written to this table entry. */
107 } GAIN_CALC_TBL_ENTRY2_T;
108 
109 /*******************************************************************************
110 * Definitions
111 ******************************************************************************/
112 void rx_dc_sample_average(int16_t * i_avg, int16_t * q_avg);
113 void rx_dc_sample_average_long(int16_t * i_avg, int16_t * q_avg);
114 uint8_t rx_bba_dcoc_dac_trim_shortIQ(void);
115 void XcvrCalDelay(uint32_t time);
116 void rx_dc_est_average(int16_t * i_avg, int16_t * q_avg, uint16_t SampleNumber);
117 uint8_t rx_bba_dcoc_dac_trim_DCest(void);
118 void DCOC_DAC_INIT_Cal(uint8_t standalone_operation);
119 
120 
121 
122 
123 /* @} */
124 
125 #if defined(__cplusplus)
126 }
127 #endif
128 
129 /*! @}*/
130 
131 #endif /* _FSL_XCVR_TRIM_H_ */
132 
133