1 /***************************************************************************//**
2  * @file
3  * @brief PA power conversion curves used by Silicon Labs PA power conversion
4  *   functions.
5  * @details This file contains the curves needed convert PA power levels to
6  *   dBm powers.
7  *******************************************************************************
8  * # License
9  * <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
10  *******************************************************************************
11  *
12  * SPDX-License-Identifier: Zlib
13  *
14  * The licensor of this software is Silicon Laboratories Inc.
15  *
16  * This software is provided 'as-is', without any express or implied
17  * warranty. In no event will the authors be held liable for any damages
18  * arising from the use of this software.
19  *
20  * Permission is granted to anyone to use this software for any purpose,
21  * including commercial applications, and to alter it and redistribute it
22  * freely, subject to the following restrictions:
23  *
24  * 1. The origin of this software must not be misrepresented; you must not
25  *    claim that you wrote the original software. If you use this software
26  *    in a product, an acknowledgment in the product documentation would be
27  *    appreciated but is not required.
28  * 2. Altered source versions must be plainly marked as such, and must not be
29  *    misrepresented as being the original software.
30  * 3. This notice may not be removed or altered from any source distribution.
31  *
32  ******************************************************************************/
33 
34 #ifndef __PA_CURVES_H_
35 #define __PA_CURVES_H_
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #define RAIL_PA_CURVES_LP_VALUES 7
42 #define RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS 8
43 
44 #define RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER      200
45 #define RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER      -260
46 #define RAIL_PA_CURVES_2P4_HP_VBAT_CURVES \
47   { { 252, 2776, -300026 },               \
48     { 136, 1335, -73192 },                \
49     { 83, 772, -7179 },                   \
50     { 50, 441, 17309 },                   \
51     { 41, 343, 22520 },                   \
52     { 22, 209, 22360 },                   \
53     { 14, 124, 18896 },                   \
54     { 7, 40, 10519 } }
55 
56 #define RAIL_PA_CURVES_2P4_HP_DCDC_MAX_POWER      140
57 #define RAIL_PA_CURVES_2P4_HP_DCDC_MIN_POWER      -260
58 #define RAIL_PA_CURVES_2P4_HP_DCDC_CURVES \
59   { { 65535, 0, 0 },                      \
60     { 252, 4306, -391604 },               \
61     { 117, 1435, -52495 },                \
62     { 62, 610, 13579 },                   \
63     { 37, 331, 24456 },                   \
64     { 23, 224, 23902 },                   \
65     { 14, 140, 20330 },                   \
66     { 7, 37, 10371 } }
67 
68 #define RAIL_PA_CURVES_SG_VBAT_MAX_POWER          200
69 #define RAIL_PA_CURVES_SG_VBAT_MIN_POWER          -260
70 #define RAIL_PA_CURVES_SG_VBAT_CURVES \
71   { { 248, 2757, -319913 },           \
72     { 123, 1173, -64900 },            \
73     { 74, 694, -8378 },               \
74     { 45, 429, 12097 },               \
75     { 28, 263, 18309 },               \
76     { 18, 167, 18071 },               \
77     { 11, 103, 15386 },               \
78     { 6, 34, 9064 } }
79 
80 #define RAIL_PA_CURVES_SG_DCDC_MAX_POWER          150
81 #define RAIL_PA_CURVES_SG_DCDC_MIN_POWER          -260
82 #define RAIL_PA_CURVES_SG_DCDC_CURVES \
83   { { 248, 9069, -1171644 },          \
84     { 199, 3826, -378994 },           \
85     { 92, 932, -22748 },              \
86     { 50, 470, 13485 },               \
87     { 31, 304, 19712 },               \
88     { 18, 192, 19146 },               \
89     { 11, 110, 15607 },               \
90     { 5, 31, 8239 } }
91 
92 #define RAIL_PA_CURVES_2P4_LP  \
93   {                            \
94     -125, /*! Power Level 1 */ \
95     -65,  /*! Power Level 2 */ \
96     -30,  /*! Power Level 3 */ \
97     -15,  /*! Power Level 4 */ \
98     -7,   /*! Power Level 5 */ \
99     -2,   /*! Power Level 6 */ \
100     0     /*! Power Level 7 */ \
101   }
102 
103 /**
104  * Macros to ease in the delcarations of the various power amplifier units
105  * conversion curves.
106  */
107 #define RAIL_DECLARE_PA_2P4_HP_VBAT                                     \
108   static const RAIL_TxPowerCurveSegment_t                               \
109   twoPointFourHpVbatCurves[RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS] \
110     = RAIL_PA_CURVES_2P4_HP_VBAT_CURVES;
111 
112 #define RAIL_DECLARE_PA_2P4_HP_DCDC                                     \
113   static const RAIL_TxPowerCurveSegment_t                               \
114   twoPointFourHpDcdcCurves[RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS] \
115     = RAIL_PA_CURVES_2P4_HP_DCDC_CURVES;
116 
117 #define RAIL_DECLARE_PA_SG_VBAT                                 \
118   static const RAIL_TxPowerCurveSegment_t                       \
119   subgigVbatCurves[RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS] \
120     = RAIL_PA_CURVES_SG_VBAT_CURVES;
121 
122 #define RAIL_DECLARE_PA_SG_DCDC                                 \
123   static const RAIL_TxPowerCurveSegment_t                       \
124   subgigDcdcCurves[RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS] \
125     = RAIL_PA_CURVES_SG_DCDC_CURVES;
126 
127 // Macro to declare the variables needed to initialize
128 // RAIL_TxPowerCurvesConfigAlt_t for use in RAIL_InitTxPowerCurvesAlt,
129 // assuming battery powered operation
130 #define RAIL_DECLARE_TX_POWER_VBAT_CURVES_ALT                      \
131   static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHp = {     \
132     RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER,                          \
133     RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER,                          \
134     RAIL_PA_CURVES_2P4_HP_VBAT_CURVES                              \
135   };                                                               \
136   static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataSg = {     \
137     RAIL_PA_CURVES_SG_VBAT_MAX_POWER,                              \
138     RAIL_PA_CURVES_SG_VBAT_MIN_POWER,                              \
139     RAIL_PA_CURVES_SG_VBAT_CURVES                                  \
140   };                                                               \
141   static const int16_t RAIL_curves24Lp[RAIL_PA_CURVES_LP_VALUES] = \
142     RAIL_PA_CURVES_2P4_LP;
143 // *INDENT-OFF*
144 
145 // Macro to declare the variables needed to initialize
146 // RAIL_TxPowerCurvesConfigAlt_t for use in RAIL_InitTxPowerCurvesAlt,
147 // assuming DCDC powered operation
148 #define RAIL_DECLARE_TX_POWER_DCDC_CURVES_ALT                                  \
149   static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHp = {                 \
150     RAIL_PA_CURVES_2P4_HP_DCDC_MAX_POWER,                                      \
151     RAIL_PA_CURVES_2P4_HP_DCDC_MIN_POWER,                                      \
152     RAIL_PA_CURVES_2P4_HP_DCDC_CURVES,                                         \
153   };                                                                           \
154   static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataSg = {                 \
155     RAIL_PA_CURVES_SG_DCDC_MAX_POWER,                                          \
156     RAIL_PA_CURVES_SG_DCDC_MIN_POWER,                                          \
157     RAIL_PA_CURVES_SG_DCDC_CURVES                                              \
158   };                                                                           \
159   static const int16_t RAIL_curves24Lp[RAIL_PA_CURVES_LP_VALUES] =             \
160     RAIL_PA_CURVES_2P4_LP;
161 // *INDENT-OFF*
162 
163 // Macro to declare the variables needed to initialize
164 // RAIL_TxPowerCurvesConfig_t for use in RAIL_InitTxPowerCurves,
165 // assuming battery powered operation
166 #define RAIL_DECLARE_TX_POWER_VBAT_CURVES(piecewiseSegments, curvesSg,         \
167                                           curves24Hp, curves24Lp)              \
168   static const uint8_t (piecewiseSegments) =                                   \
169     RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS;                               \
170                                                                                \
171   RAIL_DECLARE_PA_2P4_HP_VBAT;                                                 \
172   RAIL_DECLARE_PA_SG_VBAT;                                                     \
173                                                                                \
174   static const RAIL_TxPowerCurves_t curvesSg[1] = {                            \
175     { RAIL_PA_CURVES_SG_VBAT_MAX_POWER,                                        \
176       RAIL_PA_CURVES_SG_VBAT_MIN_POWER,                                        \
177       subgigVbatCurves }                                                       \
178   };                                                                           \
179   static const RAIL_TxPowerCurves_t curves24Hp[1] = {                          \
180     { RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER,                                    \
181       RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER,                                    \
182       twoPointFourHpVbatCurves }                                               \
183   };                                                                           \
184   static const int16_t curves24Lp[RAIL_PA_CURVES_LP_VALUES] =                  \
185     RAIL_PA_CURVES_2P4_LP;
186 // *INDENT-OFF*
187 
188 // Macro to declare the variables needed to initialize
189 // RAIL_TxPowerCurvesConfig_t for use in RAIL_InitTxPowerCurves,
190 // assuming DCDC powered operation
191 #define RAIL_DECLARE_TX_POWER_DCDC_CURVES(piecewiseSegments, curvesSg,         \
192                                           curves24Hp, curves24Lp)              \
193   static const uint8_t piecewiseSegments =                                     \
194     RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS;                               \
195                                                                                \
196   RAIL_DECLARE_PA_2P4_HP_DCDC;                                                 \
197   RAIL_DECLARE_PA_SG_DCDC;                                                     \
198                                                                                \
199   static const RAIL_TxPowerCurves_t curvesSg[1] = {                            \
200     { RAIL_PA_CURVES_SG_DCDC_MAX_POWER,                                        \
201       RAIL_PA_CURVES_SG_DCDC_MIN_POWER,                                        \
202       subgigDcdcCurves }                                                       \
203   };                                                                           \
204   static const RAIL_TxPowerCurves_t curves24Hp[1] = {                          \
205     { RAIL_PA_CURVES_2P4_HP_DCDC_MAX_POWER,                                    \
206       RAIL_PA_CURVES_2P4_HP_DCDC_MIN_POWER,                                    \
207       twoPointFourHpDcdcCurves }                                               \
208   };                                                                           \
209   static const int16_t curves24Lp[RAIL_PA_CURVES_LP_VALUES] =                  \
210     RAIL_PA_CURVES_2P4_LP;
211 // *INDENT-OFF*
212 
213 #define RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT                                \
214   {                                                                            \
215     .curves = {                                                                \
216       {                                                                        \
217         .algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,                       \
218         .segments = RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS,               \
219         .min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN,                                     \
220         .max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX,                                     \
221         .conversion = { .powerCurve = &RAIL_piecewiseDataHp },                 \
222       },                                                                       \
223       {                                                                        \
224         .algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE,                          \
225         .segments = 0U,                                                        \
226         .min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN,                                     \
227         .max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX,                                     \
228         .conversion = { .mappingTable = &RAIL_curves24Lp[0] },                 \
229       },                                                                       \
230       {                                                                        \
231         .algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,                       \
232         .segments = RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS,               \
233         .min = RAIL_TX_POWER_LEVEL_SUBGIG_MIN,                                 \
234         .max = RAIL_TX_POWER_LEVEL_SUBGIG_HP_MAX,                                 \
235         .conversion = { .powerCurve = &RAIL_piecewiseDataSg },                 \
236       },                                                                       \
237     }                                                                          \
238   }
239 // *INDENT-OFF*
240 
241 #ifdef __cplusplus
242 }
243 #endif
244 
245 #endif
246