Imported more library files
Not compiling currently
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
/***************************************************************************//**
|
||||
* @file
|
||||
* @brief PA power conversion curves used by Silicon Labs PA power conversion
|
||||
* functions.
|
||||
* @details This file contains the curves needed convert PA power levels to
|
||||
* dBm powers.
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* SPDX-License-Identifier: Zlib
|
||||
*
|
||||
* The licensor of this software is Silicon Laboratories Inc.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __PA_CURVES_H_
|
||||
#define __PA_CURVES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RAIL_PA_CURVES_PIECEWISE_SEGMENTS (9U)
|
||||
#define RAIL_PA_CURVES_LP_VALUES (16U)
|
||||
|
||||
#define RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER 100
|
||||
#define RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER -300
|
||||
#define RAIL_PA_CURVES_2P4_HP_VBAT_CURVES \
|
||||
{ { 255, 100, 22 }, \
|
||||
{ 90, 1960, -116460 }, \
|
||||
{ 36, 567, -7935 }, \
|
||||
{ 22, 288, 6929 }, \
|
||||
{ 16, 192, 9881 }, \
|
||||
{ 11, 134, 10360 }, \
|
||||
{ 8, 89, 9610 }, \
|
||||
{ 6, 69, 8821 }, \
|
||||
{ 4, 18, 5138 } }
|
||||
|
||||
#define RAIL_PA_CURVES_2P4_LP_VBAT_MAX_POWER 0
|
||||
#define RAIL_PA_CURVES_2P4_LP_VBAT_MIN_POWER -260
|
||||
#define RAIL_PA_CURVES_2P4_LP_VBAT_CURVES \
|
||||
{ \
|
||||
-252, /*! Power Level 0 */ \
|
||||
-149, /*! Power Level 1 */ \
|
||||
-97, /*! Power Level 2 */ \
|
||||
-69, /*! Power Level 3 */ \
|
||||
-52, /*! Power Level 4 */ \
|
||||
-40, /*! Power Level 5 */ \
|
||||
-32, /*! Power Level 6 */ \
|
||||
-26, /*! Power Level 7 */ \
|
||||
-22, /*! Power Level 8 */ \
|
||||
-18, /*! Power Level 9 */ \
|
||||
-15, /*! Power Level 10 */ \
|
||||
-13, /*! Power Level 11 */ \
|
||||
-11, /*! Power Level 12 */ \
|
||||
-9, /*! Power Level 13 */ \
|
||||
-8, /*! Power Level 14 */ \
|
||||
-7, /*! Power Level 15 */ \
|
||||
}
|
||||
// *INDENT-OFF*
|
||||
// Macro to declare the variables needed to initialize RAIL_TxPowerCurvesConfig_t for use in
|
||||
// RAIL_InitTxPowerCurves, assuming battery powered operation
|
||||
#define RAIL_DECLARE_TX_POWER_VBAT_CURVES_ALT \
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHp = { \
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER, \
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER, \
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_CURVES, \
|
||||
}; \
|
||||
static const int16_t RAIL_curves24Lp[RAIL_PA_CURVES_LP_VALUES] = \
|
||||
RAIL_PA_CURVES_2P4_LP_VBAT_CURVES;
|
||||
// *INDENT-OFF*
|
||||
|
||||
#define RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT \
|
||||
{ \
|
||||
.curves = { \
|
||||
{ \
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR, \
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS, \
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN, \
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX, \
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHp }, \
|
||||
}, \
|
||||
{ \
|
||||
.algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE, \
|
||||
.segments = 0U, \
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN, \
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX, \
|
||||
.conversion = { .mappingTable = &RAIL_curves24Lp[0] }, \
|
||||
}, \
|
||||
} \
|
||||
}
|
||||
// *INDENT-OFF*
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,140 @@
|
||||
/***************************************************************************//**
|
||||
* @file
|
||||
* @brief PA power conversion curves used by Silicon Labs PA power conversion
|
||||
* functions.
|
||||
* @details This file contains the curves needed convert PA power levels to
|
||||
* dBm powers.
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* SPDX-License-Identifier: Zlib
|
||||
*
|
||||
* The licensor of this software is Silicon Laboratories Inc.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __PA_CURVES_H_
|
||||
#define __PA_CURVES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RAIL_PA_CURVES_PIECEWISE_SEGMENTS (8U)
|
||||
#define RAIL_PA_CURVES_LP_VALUES (16U)
|
||||
|
||||
#define RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER 200
|
||||
#define RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER -338
|
||||
#define RAIL_PA_CURVES_2P4_HP_VBAT_CURVES \
|
||||
{ { 180, 2280, -291457 }, \
|
||||
{ 78, 770, -46749 }, \
|
||||
{ 44, 431, -6673 }, \
|
||||
{ 27, 255, 6886 }, \
|
||||
{ 17, 167, 10458 }, \
|
||||
{ 10, 98, 10261 }, \
|
||||
{ 6, 59, 8616 }, \
|
||||
{ 3, 11, 3745 } }
|
||||
|
||||
#define RAIL_PA_CURVES_2P4_HP_DCDC_MAX_POWER 200
|
||||
#define RAIL_PA_CURVES_2P4_HP_DCDC_MIN_POWER -338
|
||||
#define RAIL_PA_CURVES_2P4_HP_DCDC_CURVES \
|
||||
{ { 180, 2263, -287605 }, \
|
||||
{ 78, 783, -47869 }, \
|
||||
{ 45, 432, -6351 }, \
|
||||
{ 26, 255, 7104 }, \
|
||||
{ 17, 167, 10595 }, \
|
||||
{ 10, 98, 10336 }, \
|
||||
{ 6, 59, 8671 }, \
|
||||
{ 3, 11, 3757 } }
|
||||
|
||||
#define RAIL_PA_CURVES_2P4_LP_VBAT_MAX_POWER 0
|
||||
#define RAIL_PA_CURVES_2P4_LP_VBAT_MIN_POWER -260
|
||||
#define RAIL_PA_CURVES_2P4_LP_VBAT_CURVES \
|
||||
{ \
|
||||
-250, /*! Power Level 0 */ \
|
||||
-148, /*! Power Level 1 */ \
|
||||
-95, /*! Power Level 2 */ \
|
||||
-68, /*! Power Level 3 */ \
|
||||
-51, /*! Power Level 4 */ \
|
||||
-40, /*! Power Level 5 */ \
|
||||
-32, /*! Power Level 6 */ \
|
||||
-26, /*! Power Level 7 */ \
|
||||
-22, /*! Power Level 8 */ \
|
||||
-18, /*! Power Level 9 */ \
|
||||
-16, /*! Power Level 10 */ \
|
||||
-13, /*! Power Level 11 */ \
|
||||
-12, /*! Power Level 12 */ \
|
||||
-10, /*! Power Level 13 */ \
|
||||
-9, /*! Power Level 14 */ \
|
||||
-9, /*! Power Level 15 */ \
|
||||
}
|
||||
|
||||
// *INDENT-OFF*
|
||||
// Macro to declare the variables needed to initialize RAIL_TxPowerCurvesConfig_t for use in
|
||||
// RAIL_InitTxPowerCurves, assuming battery powered operation
|
||||
#define RAIL_DECLARE_TX_POWER_VBAT_CURVES_ALT \
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHpVbat = { \
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER, \
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER, \
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_CURVES, \
|
||||
}; \
|
||||
static const int16_t RAIL_curves24Lp[RAIL_PA_CURVES_LP_VALUES] = \
|
||||
RAIL_PA_CURVES_2P4_LP_VBAT_CURVES;
|
||||
// *INDENT-OFF*
|
||||
|
||||
// Macro to declare the variables needed to initialize RAIL_TxPowerCurvesConfig_t for use in
|
||||
// RAIL_InitTxPowerCurves, assuming battery powered operation
|
||||
#define RAIL_DECLARE_TX_POWER_DCDC_CURVES_ALT \
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHpDcdc = { \
|
||||
RAIL_PA_CURVES_2P4_HP_DCDC_MAX_POWER, \
|
||||
RAIL_PA_CURVES_2P4_HP_DCDC_MIN_POWER, \
|
||||
RAIL_PA_CURVES_2P4_HP_DCDC_CURVES, \
|
||||
}; \
|
||||
static const int16_t RAIL_curves24Lp[RAIL_PA_CURVES_LP_VALUES] = \
|
||||
RAIL_PA_CURVES_2P4_LP_VBAT_CURVES;
|
||||
// *INDENT-OFF*
|
||||
|
||||
#define RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT \
|
||||
{ \
|
||||
.curves = { \
|
||||
{ \
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR, \
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS, \
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN, \
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX, \
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpVbat}, \
|
||||
}, \
|
||||
{ \
|
||||
.algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE, \
|
||||
.segments = 0U, \
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN, \
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX, \
|
||||
.conversion = { .mappingTable = &RAIL_curves24Lp[0] }, \
|
||||
}, \
|
||||
} \
|
||||
}
|
||||
// *INDENT-OFF*
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,801 @@
|
||||
/***************************************************************************//**
|
||||
* @file
|
||||
* @brief PA power conversion functions provided to the customer as source for
|
||||
* highest level of customization.
|
||||
* @details This file contains the curves and logic that convert PA power
|
||||
* levels to dBm powers.
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* SPDX-License-Identifier: Zlib
|
||||
*
|
||||
* The licensor of this software is Silicon Laboratories Inc.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
******************************************************************************/
|
||||
// For details on how to use this plugin, see
|
||||
// https://www.silabs.com/documents/public/application-notes/an1127-power-amplifier-power-conversion-functions.pdf
|
||||
|
||||
#include "em_device.h"
|
||||
#if defined(_SILICON_LABS_32B_SERIES_2) || defined(SIMULATION_DEVICE)
|
||||
#include "em_cmu.h"
|
||||
#else
|
||||
#include "sl_clock_manager.h"
|
||||
#endif
|
||||
|
||||
#include "pa_conversions_efr32.h"
|
||||
#include "rail.h"
|
||||
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
static RAIL_TxPowerCurvesConfigAlt_t powerCurvesState;
|
||||
|
||||
// Make sure SUPPORTED_PA_INDICES match the per-platform PA curves
|
||||
// provided by RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT and resulting
|
||||
// RAIL_TxPowerCurvesConfigAlt_t!
|
||||
#ifndef SUPPORTED_PA_INDICES
|
||||
#if defined(_SILICON_LABS_32B_SERIES_1)
|
||||
#define SUPPORTED_PA_INDICES { \
|
||||
0U, /* 2P4GIG_HP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_MP */ \
|
||||
1U, /* 2P4GIG_LP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_LLP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_HIGHEST */ \
|
||||
RAIL_NUM_PA, /* SUBGIG_POWERSETTING_TABLE */ \
|
||||
2U, /* SUBGIG_HP */ \
|
||||
/* The rest are unsupported */ \
|
||||
}
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 1)
|
||||
#define SUPPORTED_PA_INDICES { \
|
||||
0U, /* 2P4GIG_HP */ \
|
||||
1U, /* 2P4GIG_MP */ \
|
||||
2U, /* 2P4GIG_LP */ \
|
||||
/* The rest are unsupported */ \
|
||||
}
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 2)
|
||||
#define SUPPORTED_PA_INDICES { \
|
||||
0U, /* 2P4GIG_HP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_MP */ \
|
||||
1U, /* 2P4GIG_LP */ \
|
||||
/* The rest are unsupported */ \
|
||||
}
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 3)
|
||||
#define SUPPORTED_PA_INDICES { \
|
||||
RAIL_NUM_PA, /* 2P4GIG_HP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_MP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_LP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_LLP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_HIGHEST */ \
|
||||
RAIL_NUM_PA, /* SUBGIG_POWERSETTING_TABLE */ \
|
||||
0U, /* SUBGIG_HP */ \
|
||||
1U, /* SUBGIG_MP */ \
|
||||
2U, /* SUBGIG_LP */ \
|
||||
3U, /* SUBGIG_LLP */ \
|
||||
/* The rest are unsupported */ \
|
||||
}
|
||||
#elif ((_SILICON_LABS_32B_SERIES_2_CONFIG == 4) || (_SILICON_LABS_32B_SERIES_2_CONFIG == 6) || !defined(_SILICON_LABS_32B_SERIES_2))
|
||||
#define SUPPORTED_PA_INDICES { \
|
||||
0U, /* 2P4GIG_HP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_MP */ \
|
||||
1U, /* 2P4GIG_LP */ \
|
||||
/* The rest are unsupported */ \
|
||||
}
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 5)
|
||||
#define SUPPORTED_PA_INDICES { \
|
||||
RAIL_NUM_PA, /* 2P4GIG_HP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_MP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_LP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_LLP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_HIGHEST */ \
|
||||
0U, /* SUBGIG_POWERSETTING_TABLE */ \
|
||||
RAIL_NUM_PA, /* SUBGIG_HP */ \
|
||||
RAIL_NUM_PA, /* SUBGIG_MP */ \
|
||||
RAIL_NUM_PA, /* SUBGIG_LP */ \
|
||||
RAIL_NUM_PA, /* SUBGIG_LLP */ \
|
||||
RAIL_NUM_PA, /* SUBGIG_HIGHEST */ \
|
||||
1U, /* OFDM_PA_POWERSETTING_TABLE */ \
|
||||
}
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 7)
|
||||
#define SUPPORTED_PA_INDICES { \
|
||||
0U, /* 2P4GIG_HP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_MP */ \
|
||||
1U, /* 2P4GIG_LP */ \
|
||||
/* The rest are unsupported */ \
|
||||
}
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 8)
|
||||
#define SUPPORTED_PA_INDICES { \
|
||||
0U, /* 2P4GIG_HP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_MP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_LP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_LLP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_HIGHEST */ \
|
||||
RAIL_NUM_PA, /* SUBGIG_POWERSETTING_TABLE */ \
|
||||
1U, /* SUBGIG_HP */ \
|
||||
2U, /* SUBGIG_MP */ \
|
||||
3U, /* SUBGIG_LP */ \
|
||||
4U, /* SUBGIG_LLP */ \
|
||||
/* The rest are unsupported */ \
|
||||
}
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 9)
|
||||
#define SUPPORTED_PA_INDICES { \
|
||||
0U, /* 2P4GIG_HP */ \
|
||||
RAIL_NUM_PA, /* 2P4GIG_MP */ \
|
||||
1U, /* 2P4GIG_LP */ \
|
||||
/* The rest are unsupported */ \
|
||||
}
|
||||
#else
|
||||
#error "unknown platform"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static const uint8_t supportedPaIndices[] = SUPPORTED_PA_INDICES;
|
||||
|
||||
#if defined(_SILICON_LABS_32B_SERIES_1) || defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1)
|
||||
#define PA_CONVERSION_MINIMUM_PWRLVL 1U
|
||||
#else
|
||||
#define PA_CONVERSION_MINIMUM_PWRLVL 0U
|
||||
#endif
|
||||
|
||||
// This macro is defined when Silicon Labs builds this into the library as WEAK
|
||||
// to ensure it can be overriden by customer versions of these functions. The macro
|
||||
// should *not* be defined in a customer build.
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurves_t *RAIL_GetTxPowerCurve(RAIL_TxPowerMode_t mode)
|
||||
{
|
||||
static RAIL_TxPowerCurves_t powerCurves;
|
||||
RAIL_TxPowerLevel_t maxPowerLevel, minPowerLevel;
|
||||
if (RAIL_SupportsTxPowerModeAlt(RAIL_EFR32_HANDLE,
|
||||
&mode,
|
||||
&maxPowerLevel,
|
||||
&minPowerLevel)
|
||||
&& (mode < sizeof(supportedPaIndices))
|
||||
&& (supportedPaIndices[mode] < RAIL_NUM_PA)) {
|
||||
const RAIL_PaDescriptor_t *modeInfo = &powerCurvesState.curves[supportedPaIndices[mode]];
|
||||
const RAIL_TxPowerCurveAlt_t *curve = modeInfo->conversion.powerCurve;
|
||||
// Check for an invalid power curve
|
||||
if (curve == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
if (modeInfo->algorithm == RAIL_PA_ALGORITHM_DBM_POWERSETTING_MAPPING_TABLE) {
|
||||
powerCurves.maxPower = modeInfo->maxPowerDbm;
|
||||
powerCurves.minPower = modeInfo->minPowerDbm;
|
||||
// Mapping table does not have RAIL_TxPowerCurveSegment_t segments
|
||||
powerCurves.powerParams = NULL;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
powerCurves.maxPower = curve->maxPower;
|
||||
powerCurves.minPower = curve->minPower;
|
||||
powerCurves.powerParams = &curve->powerParams[0];
|
||||
}
|
||||
return &powerCurves;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// This function will not be supported for any parts after efr32xg1x
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
RAIL_Status_t RAIL_InitTxPowerCurves(const RAIL_TxPowerCurvesConfig_t *config)
|
||||
{
|
||||
#ifdef _SILICON_LABS_32B_SERIES_1
|
||||
// First PA is 2.4 GHz high power, using a piecewise fit
|
||||
RAIL_PaDescriptor_t *current = &powerCurvesState.curves[0];
|
||||
current->algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR;
|
||||
current->segments = config->piecewiseSegments;
|
||||
current->min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN;
|
||||
current->max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX;
|
||||
static RAIL_TxPowerCurveAlt_t txPower2p4 = {
|
||||
.minPower = 0U,
|
||||
.maxPower = 0U,
|
||||
.powerParams = { // The current max number of piecewise segments is 8
|
||||
{ 0U, 0U, 0U }, { 0U, 0U, 0U }, { 0U, 0U, 0U }, { 0U, 0U, 0U },
|
||||
{ 0U, 0U, 0U }, { 0U, 0U, 0U }, { 0U, 0U, 0U }, { 0U, 0U, 0U },
|
||||
}
|
||||
};
|
||||
txPower2p4.maxPower = config->txPowerSgCurves->maxPower;
|
||||
txPower2p4.minPower = config->txPowerSgCurves->minPower;
|
||||
(void) memcpy(&txPower2p4.powerParams[0],
|
||||
config->txPowerSgCurves->powerParams,
|
||||
config->piecewiseSegments * sizeof(RAIL_TxPowerCurveSegment_t));
|
||||
current->conversion.powerCurve = &txPower2p4;
|
||||
|
||||
// Second PA is 2.4 GHz low power, using a mapping table
|
||||
current = &powerCurvesState.curves[1];
|
||||
current->algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE;
|
||||
current->segments = 0U;
|
||||
current->min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN;
|
||||
current->max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX;
|
||||
current->conversion.mappingTable = config->txPower24LpCurves;
|
||||
|
||||
// Third and final PA is Sub-GHz, using a piecewise fit
|
||||
current = &powerCurvesState.curves[2];
|
||||
current->algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR;
|
||||
current->segments = config->piecewiseSegments;
|
||||
current->min = RAIL_TX_POWER_LEVEL_SUBGIG_MIN;
|
||||
current->max = RAIL_TX_POWER_LEVEL_SUBGIG_HP_MAX;
|
||||
static RAIL_TxPowerCurveAlt_t txPowerSubGig = {
|
||||
.minPower = 0U,
|
||||
.maxPower = 0U,
|
||||
.powerParams = { // The current max number of piecewise segments is 8
|
||||
{ 0U, 0U, 0U }, { 0U, 0U, 0U }, { 0U, 0U, 0U }, { 0U, 0U, 0U },
|
||||
{ 0U, 0U, 0U }, { 0U, 0U, 0U }, { 0U, 0U, 0U }, { 0U, 0U, 0U },
|
||||
}
|
||||
};
|
||||
txPowerSubGig.maxPower = config->txPowerSgCurves->maxPower;
|
||||
txPowerSubGig.minPower = config->txPowerSgCurves->minPower;
|
||||
(void) memcpy(&txPowerSubGig.powerParams[0],
|
||||
config->txPowerSgCurves->powerParams,
|
||||
config->piecewiseSegments * sizeof(RAIL_TxPowerCurveSegment_t));
|
||||
current->conversion.powerCurve = &txPowerSubGig;
|
||||
|
||||
return RAIL_STATUS_NO_ERROR;
|
||||
#else
|
||||
(void) config;
|
||||
return RAIL_STATUS_INVALID_CALL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
RAIL_Status_t RAIL_InitTxPowerCurvesAlt(const RAIL_TxPowerCurvesConfigAlt_t *config)
|
||||
{
|
||||
RAIL_Status_t status = RAIL_VerifyTxPowerCurves(config);
|
||||
if (status == RAIL_STATUS_NO_ERROR) {
|
||||
powerCurvesState = *config;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
#if RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
const RAIL_PaPowerSetting_t *RAIL_GetPowerSettingTable(RAIL_Handle_t railHandle, RAIL_TxPowerMode_t mode,
|
||||
RAIL_TxPower_t *minPower, RAIL_TxPower_t *maxPower,
|
||||
RAIL_TxPowerLevel_t *step)
|
||||
{
|
||||
(void)railHandle;
|
||||
#if RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
if ((mode < sizeof(supportedPaIndices))
|
||||
&& (supportedPaIndices[mode] < RAIL_NUM_PA)) {
|
||||
RAIL_PaDescriptor_t *modeInfo = &powerCurvesState.curves[supportedPaIndices[mode]];
|
||||
*minPower = modeInfo->minPowerDbm;
|
||||
*maxPower = modeInfo->maxPowerDbm;
|
||||
*step = modeInfo->step;
|
||||
return (RAIL_PaPowerSetting_t*)(modeInfo->conversion.mappingTable);
|
||||
}
|
||||
return NULL;
|
||||
#else
|
||||
(void)mode;
|
||||
(void)minPower;
|
||||
(void)maxPower;
|
||||
(void)step;
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
#endif // RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
RAIL_Status_t RAIL_ConvertDbmToPowerSettingEntry(RAIL_Handle_t railHandle,
|
||||
RAIL_TxPowerMode_t mode,
|
||||
RAIL_TxPower_t power,
|
||||
RAIL_TxPowerSettingEntry_t *powerSettingInfo)
|
||||
{
|
||||
(void)railHandle;
|
||||
#if RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
if ((mode < sizeof(supportedPaIndices))
|
||||
&& (supportedPaIndices[mode] < RAIL_NUM_PA)) {
|
||||
RAIL_PaDescriptor_t const *modeInfo = &powerCurvesState.curves[supportedPaIndices[mode]];
|
||||
if (modeInfo->algorithm == RAIL_PA_ALGORITHM_DBM_POWERSETTING_MAPPING_TABLE) {
|
||||
RAIL_TxPower_t minPower = modeInfo->minPowerDbm;
|
||||
RAIL_TxPower_t maxPower = modeInfo->maxPowerDbm;
|
||||
RAIL_TxPowerLevel_t step = modeInfo->step;
|
||||
|
||||
// Cap the power to within the range of the mapping table
|
||||
if (power < minPower) {
|
||||
power = minPower;
|
||||
} else if (power > maxPower) {
|
||||
power = maxPower;
|
||||
} else {
|
||||
// Power level is within bounds (MISRA required else)
|
||||
}
|
||||
|
||||
// Calculate indices
|
||||
uint32_t maxIndex = (uint32_t)((maxPower - minPower) / step);
|
||||
uint32_t powerIndex = (uint32_t)((power - minPower) / step);
|
||||
|
||||
// Ensure powerIndex is within bounds
|
||||
if (powerIndex > maxIndex) {
|
||||
powerIndex = maxIndex;
|
||||
}
|
||||
|
||||
RAIL_PaPowerSetting_t powerSetting = modeInfo->conversion.mappingTable[powerIndex];
|
||||
|
||||
while ((powerIndex > 0U)
|
||||
&& (powerSetting == (RAIL_PaPowerSetting_t)modeInfo->conversion.mappingTable[powerIndex - 1U])) {
|
||||
powerIndex--;
|
||||
}
|
||||
power = minPower + ((RAIL_TxPower_t)powerIndex * step);
|
||||
|
||||
powerSettingInfo->paPowerSetting = powerSetting;
|
||||
powerSettingInfo->minPaPowerDdbm = minPower;
|
||||
powerSettingInfo->maxPaPowerDdbm = maxPower;
|
||||
powerSettingInfo->currentPaPowerDdbm = power;
|
||||
return RAIL_STATUS_NO_ERROR;
|
||||
}
|
||||
}
|
||||
return RAIL_STATUS_INVALID_CALL;
|
||||
#else
|
||||
(void) mode;
|
||||
(void) power;
|
||||
(void) powerSettingInfo;
|
||||
return RAIL_STATUS_INVALID_CALL;
|
||||
#endif //RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
}
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
RAIL_TxPowerLevel_t RAIL_ConvertDbmToRaw(RAIL_Handle_t railHandle,
|
||||
RAIL_TxPowerMode_t mode,
|
||||
RAIL_TxPower_t power)
|
||||
{
|
||||
(void)railHandle;
|
||||
#if RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
// Powersetting tables do not have raw powerlevels.
|
||||
// Could use RAIL_ConvertDbmToPowerSettingEntry
|
||||
(void)mode;
|
||||
(void) power;
|
||||
#else
|
||||
|
||||
// When a channel dBm limitation greater than or equal to \ref RAIL_TX_POWER_MAX
|
||||
// is converted to raw units, the max RAIL_TxPowerLevel_t will be
|
||||
// returned. When compared to the current power level of the PA,
|
||||
// it will always be greater, indicating that no power coercion
|
||||
// is necessary to comply with channel limitations.
|
||||
if (power >= RAIL_TX_POWER_MAX) {
|
||||
return 255U;
|
||||
}
|
||||
|
||||
if ((mode < sizeof(supportedPaIndices))
|
||||
&& (supportedPaIndices[mode] < RAIL_NUM_PA)) {
|
||||
RAIL_PaDescriptor_t const *modeInfo = &powerCurvesState.curves[supportedPaIndices[mode]];
|
||||
uint32_t minPowerLevel = MAX(modeInfo->min, PA_CONVERSION_MINIMUM_PWRLVL);
|
||||
|
||||
// If we're in low power mode, just use the simple lookup table
|
||||
if (modeInfo->algorithm == RAIL_PA_ALGORITHM_MAPPING_TABLE) {
|
||||
// Binary search through the lookup table to find the closest power level
|
||||
// without going over.
|
||||
uint32_t lower = 0U;
|
||||
// Track the high side of the estimate
|
||||
uint32_t powerIndex = modeInfo->max - minPowerLevel;
|
||||
|
||||
while (lower < powerIndex) {
|
||||
// Calculate the midpoint of the current range
|
||||
uint32_t index = powerIndex - (powerIndex - lower) / 2U;
|
||||
if (power < modeInfo->conversion.mappingTable[index]) {
|
||||
powerIndex = index - 1U;
|
||||
} else {
|
||||
lower = index;
|
||||
}
|
||||
}
|
||||
return (RAIL_TxPowerLevel_t)(powerIndex + minPowerLevel);
|
||||
}
|
||||
|
||||
// Here we know we're using the piecewise linear conversion
|
||||
RAIL_TxPowerCurveAlt_t const *paParams = modeInfo->conversion.powerCurve;
|
||||
// Check for valid paParams before using them
|
||||
if (paParams == NULL) {
|
||||
return 0U;
|
||||
}
|
||||
|
||||
// Cap the power based on the PA settings.
|
||||
if (power > paParams->maxPower) {
|
||||
// If we go above the maximum dbm the chip supports
|
||||
// Then provide maximum powerLevel
|
||||
power = paParams->maxPower;
|
||||
} else if (power < paParams->minPower) {
|
||||
// If we go below the minimum we want included in the curve fit, force it.
|
||||
power = paParams->minPower;
|
||||
} else {
|
||||
// Do nothing, power is OK
|
||||
}
|
||||
// Map the power value to a 0 - 7 curveIndex value
|
||||
//There are 8 segments of step size of RAIL_TX_POWER_CURVE_INCREMENT in deci dBm
|
||||
//starting from maximum RAIL_TX_POWER_CURVE_MAX in deci dBm
|
||||
// These are just starting points to give the code
|
||||
// a rough idea of which segment to use, based on
|
||||
// how they were fit. Adjustments are made later on
|
||||
// if this turns out to be incorrect.
|
||||
RAIL_TxPower_t txPowerMax = RAIL_TX_POWER_CURVE_DEFAULT_MAX;
|
||||
RAIL_TxPower_t txPowerIncrement = RAIL_TX_POWER_CURVE_DEFAULT_INCREMENT;
|
||||
int16_t curveIndex = 0;
|
||||
// if the first curve segment starts with RAIL_TX_POWER_LEVEL_INVALID
|
||||
//It is an extra curve segment to depict the maxpower and increment
|
||||
// (in deci-dBm) used while generating the curves.
|
||||
// The extra segment is only present when curve segment is generated by
|
||||
//using values different than the default - RAIL_TX_POWER_CURVE_DEFAULT_MAX
|
||||
// and RAIL_TX_POWER_CURVE_DEFAULT_INCREMENT.
|
||||
if ((paParams->powerParams[0].maxPowerLevel) == RAIL_TX_POWER_LEVEL_INVALID) {
|
||||
curveIndex += 1;
|
||||
txPowerMax = (RAIL_TxPower_t) paParams->powerParams[0].slope;
|
||||
txPowerIncrement = (RAIL_TxPower_t) paParams->powerParams[0].intercept;
|
||||
}
|
||||
|
||||
curveIndex += (txPowerMax - power) / txPowerIncrement;
|
||||
if ((curveIndex > ((int16_t)modeInfo->segments - 1))
|
||||
|| (curveIndex < 0)) {
|
||||
curveIndex = ((int16_t)modeInfo->segments - 1);
|
||||
}
|
||||
|
||||
uint32_t powerLevel;
|
||||
do {
|
||||
// Select the correct piecewise segment to use for conversion.
|
||||
RAIL_TxPowerCurveSegment_t const *powerParams =
|
||||
&paParams->powerParams[curveIndex];
|
||||
|
||||
// powerLevel can only go down to 0.
|
||||
int32_t powerLevelInt = powerParams->intercept + ((int32_t)powerParams->slope * (int32_t)power);
|
||||
if (powerLevelInt < 0) {
|
||||
powerLevel = 0U;
|
||||
} else {
|
||||
powerLevel = (uint32_t) powerLevelInt;
|
||||
}
|
||||
// RAIL_LIB-8330: Modified from adding 500 to adding 92, this was tested on xg21 as being the highest
|
||||
// number we can use without exceeding the requested power in dBm
|
||||
powerLevel = ((powerLevel + 92U) / 1000U);
|
||||
|
||||
// In case it turns out the resultant power level was too low and we have
|
||||
// to recalculate with the next curve...
|
||||
curveIndex++;
|
||||
} while ((curveIndex < (int16_t)modeInfo->segments)
|
||||
&& (powerLevel <= paParams->powerParams[curveIndex].maxPowerLevel));
|
||||
|
||||
// We already know that curveIndex is at most modeInfo->segments
|
||||
if (powerLevel > paParams->powerParams[curveIndex - 1].maxPowerLevel) {
|
||||
powerLevel = paParams->powerParams[curveIndex - 1].maxPowerLevel;
|
||||
}
|
||||
|
||||
// If we go below the minimum we want included in the curve fit, force it.
|
||||
if (powerLevel < minPowerLevel) {
|
||||
powerLevel = minPowerLevel;
|
||||
}
|
||||
|
||||
return (RAIL_TxPowerLevel_t)powerLevel;
|
||||
}
|
||||
#endif // RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
return 0U;
|
||||
}
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
RAIL_TxPower_t RAIL_ConvertRawToDbm(RAIL_Handle_t railHandle,
|
||||
RAIL_TxPowerMode_t mode,
|
||||
RAIL_TxPowerLevel_t powerLevel)
|
||||
{
|
||||
(void)railHandle;
|
||||
|
||||
if ((mode < sizeof(supportedPaIndices))
|
||||
&& (supportedPaIndices[mode] < RAIL_NUM_PA)) {
|
||||
RAIL_PaDescriptor_t const *modeInfo = &powerCurvesState.curves[supportedPaIndices[mode]];
|
||||
if (modeInfo->algorithm == RAIL_PA_ALGORITHM_MAPPING_TABLE) {
|
||||
// Limit the max power level
|
||||
if (powerLevel > modeInfo->max) {
|
||||
powerLevel = modeInfo->max;
|
||||
}
|
||||
|
||||
// We 1-index low power PA power levels, but of course arrays are 0 indexed
|
||||
powerLevel -= MAX(modeInfo->min, PA_CONVERSION_MINIMUM_PWRLVL);
|
||||
|
||||
//If the index calculation above underflowed, then provide the lowest array index.
|
||||
if (powerLevel > (modeInfo->max - modeInfo->min)) {
|
||||
powerLevel = 0U;
|
||||
}
|
||||
return modeInfo->conversion.mappingTable[powerLevel];
|
||||
} else {
|
||||
#if defined(_SILICON_LABS_32B_SERIES_1) || defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1)
|
||||
// Although 0 is a legitimate power on non-2.4 LP PA's and can be set via
|
||||
// "RAIL_SetTxPower(railHandle, 0)" it is MUCH lower than power
|
||||
// level 1 (approximately -50 dBm). Including it in the piecewise
|
||||
// linear fit would skew the curve substantially, so we exclude it
|
||||
// from the conversion.
|
||||
if (powerLevel == 0U) {
|
||||
return -500;
|
||||
}
|
||||
#endif
|
||||
|
||||
RAIL_TxPowerCurveAlt_t const *powerCurve = modeInfo->conversion.powerCurve;
|
||||
// Check for a valid powerCurve pointer before using it
|
||||
if (powerCurve == NULL) {
|
||||
return RAIL_TX_POWER_MIN;
|
||||
}
|
||||
|
||||
RAIL_TxPowerCurveSegment_t const *powerParams = powerCurve->powerParams;
|
||||
|
||||
// Hard code the extremes (i.e. don't use the curve fit) in order
|
||||
// to make it clear that we are reaching the extent of the chip's
|
||||
// capabilities
|
||||
if (powerLevel <= modeInfo->min) {
|
||||
return powerCurve->minPower;
|
||||
} else if (powerLevel >= modeInfo->max) {
|
||||
return powerCurve->maxPower;
|
||||
} else {
|
||||
// Power level is within bounds (MISRA required else)
|
||||
}
|
||||
|
||||
// Figure out which parameter to use based on the power level
|
||||
uint8_t x = 0;
|
||||
uint8_t upperBound = modeInfo->segments - 1U;
|
||||
|
||||
// If the first curve segment starts with RAIL_TX_POWER_LEVEL_INVALID,
|
||||
// then it is an additional curve segment that stores maxpower and increment
|
||||
// (in deci-dBm) used to generate the curves.
|
||||
// The extra info segment is present only if the curves were generated using
|
||||
// values other than default - RAIL_TX_POWER_CURVE_DEFAULT_MAX and
|
||||
// RAIL_TX_POWER_CURVE_DEFAULT_INCREMENT.
|
||||
if ((powerParams[0].maxPowerLevel) == RAIL_TX_POWER_LEVEL_INVALID) {
|
||||
x = 1U; // skip over the first entry
|
||||
}
|
||||
|
||||
for (; x < upperBound; x++) {
|
||||
if (powerParams[x + 1U].maxPowerLevel < powerLevel) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int32_t power;
|
||||
power = ((1000 * (int32_t)(powerLevel)) - powerParams[x].intercept);
|
||||
power = ((power + ((int32_t)powerParams[x].slope / 2)) / (int32_t)powerParams[x].slope);
|
||||
|
||||
if (power > powerCurve->maxPower) {
|
||||
return powerCurve->maxPower;
|
||||
} else if (power < powerCurve->minPower) {
|
||||
return powerCurve->minPower;
|
||||
} else {
|
||||
return (RAIL_TxPower_t)power;
|
||||
}
|
||||
}
|
||||
}
|
||||
return RAIL_TX_POWER_MIN;
|
||||
}
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
RAIL_Status_t RAIL_GetTxPowerCurveLimits(RAIL_Handle_t railHandle,
|
||||
RAIL_TxPowerMode_t mode,
|
||||
RAIL_TxPower_t *maxPower,
|
||||
RAIL_TxPower_t *increment)
|
||||
{
|
||||
(void)railHandle;
|
||||
if ((mode < sizeof(supportedPaIndices))
|
||||
&& (supportedPaIndices[mode] < RAIL_NUM_PA)) {
|
||||
RAIL_PaDescriptor_t const *modeInfo = &powerCurvesState.curves[supportedPaIndices[mode]];
|
||||
#if RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
if (modeInfo->algorithm == RAIL_PA_ALGORITHM_DBM_POWERSETTING_MAPPING_TABLE) {
|
||||
*maxPower = modeInfo->maxPowerDbm;
|
||||
*increment = modeInfo->step;
|
||||
return RAIL_STATUS_NO_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
//The power max info only for available Linear fit
|
||||
if (modeInfo->algorithm == RAIL_PA_ALGORITHM_MAPPING_TABLE) {
|
||||
return RAIL_STATUS_INVALID_CALL;
|
||||
}
|
||||
*maxPower = RAIL_TX_POWER_CURVE_DEFAULT_MAX;
|
||||
*increment = RAIL_TX_POWER_CURVE_DEFAULT_INCREMENT;
|
||||
RAIL_TxPowerCurveAlt_t const *paParams = modeInfo->conversion.powerCurve;
|
||||
if ((paParams->powerParams[0].maxPowerLevel) == RAIL_TX_POWER_LEVEL_INVALID) {
|
||||
*maxPower = paParams->powerParams[0].slope;
|
||||
*increment = (RAIL_TxPower_t)paParams->powerParams[0].intercept;
|
||||
}
|
||||
return RAIL_STATUS_NO_ERROR;
|
||||
}
|
||||
return RAIL_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// This macro is defined when Silicon Labs builds curves into the library as WEAK
|
||||
// to ensure it can be overriden by customer versions of these functions. It
|
||||
// should *not* be defined in a customer build.
|
||||
#if !defined(RAIL_PA_CONVERSIONS_WEAK) && !defined(HAL_CONFIG)
|
||||
|
||||
#include "sl_rail_util_pa_config.h"
|
||||
|
||||
void sl_rail_util_pa_init(void)
|
||||
{
|
||||
#if SL_RAIL_UTIL_PA_VOLTAGE_MV > 1800
|
||||
(void)RAIL_InitTxPowerCurvesAlt(&RAIL_TxPowerCurvesVbat);
|
||||
#else
|
||||
(void)RAIL_InitTxPowerCurvesAlt(&RAIL_TxPowerCurvesDcdc);
|
||||
#endif
|
||||
#if SL_RAIL_UTIL_PA_CALIBRATION_ENABLE
|
||||
RAIL_EnablePaCal(true);
|
||||
#else
|
||||
RAIL_EnablePaCal(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if RAIL_SUPPORTS_2P4GHZ_BAND
|
||||
static RAIL_TxPowerConfig_t txPowerConfig2p4Ghz = {
|
||||
.mode = SL_RAIL_UTIL_PA_SELECTION_2P4GHZ,
|
||||
.voltage = SL_RAIL_UTIL_PA_VOLTAGE_MV,
|
||||
.rampTime = SL_RAIL_UTIL_PA_RAMP_TIME_US,
|
||||
};
|
||||
#endif
|
||||
RAIL_TxPowerConfig_t *sl_rail_util_pa_get_tx_power_config_2p4ghz(void)
|
||||
{
|
||||
#if RAIL_SUPPORTS_2P4GHZ_BAND
|
||||
return &txPowerConfig2p4Ghz;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if RAIL_SUPPORTS_SUBGHZ_BAND
|
||||
static RAIL_TxPowerConfig_t txPowerConfigSubGhz = {
|
||||
.mode = SL_RAIL_UTIL_PA_SELECTION_SUBGHZ,
|
||||
.voltage = SL_RAIL_UTIL_PA_VOLTAGE_MV,
|
||||
.rampTime = SL_RAIL_UTIL_PA_RAMP_TIME_US,
|
||||
};
|
||||
#endif
|
||||
RAIL_TxPowerConfig_t *sl_rail_util_pa_get_tx_power_config_subghz(void)
|
||||
{
|
||||
#if RAIL_SUPPORTS_SUBGHZ_BAND
|
||||
return &txPowerConfigSubGhz;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if RAIL_SUPPORTS_OFDM_PA
|
||||
#ifndef SL_RAIL_UTIL_PA_SELECTION_OFDM
|
||||
#define SL_RAIL_UTIL_PA_SELECTION_OFDM RAIL_TX_POWER_MODE_OFDM_PA_POWERSETTING_TABLE
|
||||
#endif
|
||||
static RAIL_TxPowerConfig_t txPowerConfigOFDM = {
|
||||
.mode = SL_RAIL_UTIL_PA_SELECTION_OFDM,
|
||||
.voltage = SL_RAIL_UTIL_PA_VOLTAGE_MV,
|
||||
};
|
||||
#endif // RAIL_SUPPORTS_OFDM_PA
|
||||
RAIL_TxPowerConfig_t *sl_rail_util_pa_get_tx_power_config_ofdm(void)
|
||||
{
|
||||
#if RAIL_SUPPORTS_OFDM_PA
|
||||
return &txPowerConfigOFDM;
|
||||
#else
|
||||
return NULL;
|
||||
#endif // RAIL_SUPPORTS_OFDM_PA
|
||||
}
|
||||
|
||||
void sl_rail_util_pa_on_channel_config_change(RAIL_Handle_t rail_handle,
|
||||
const RAIL_ChannelConfigEntry_t *entry)
|
||||
{
|
||||
if (!RAIL_IsPaAutoModeEnabled(rail_handle)) {
|
||||
RAIL_TxPowerConfig_t currentTxPowerConfig;
|
||||
RAIL_TxPowerConfig_t *newTxPowerConfigPtr;
|
||||
RAIL_Status_t status;
|
||||
|
||||
// Get current TX Power Config.
|
||||
status = RAIL_GetTxPowerConfig(rail_handle, ¤tTxPowerConfig);
|
||||
if (status != RAIL_STATUS_NO_ERROR) {
|
||||
while (true) {
|
||||
} // Error: Can't get TX Power Config
|
||||
}
|
||||
|
||||
#if RAIL_SUPPORTS_DUAL_BAND
|
||||
// Determine new TX Power Config.
|
||||
if (entry->baseFrequency < 1000000000UL) {
|
||||
newTxPowerConfigPtr = &txPowerConfigSubGhz;
|
||||
} else {
|
||||
newTxPowerConfigPtr = &txPowerConfig2p4Ghz;
|
||||
}
|
||||
#else
|
||||
(void) entry;
|
||||
#if RAIL_SUPPORTS_2P4GHZ_BAND
|
||||
newTxPowerConfigPtr = &txPowerConfig2p4Ghz;
|
||||
#else
|
||||
newTxPowerConfigPtr = &txPowerConfigSubGhz;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if RAIL_IEEE802154_SUPPORTS_DUAL_PA_CONFIG
|
||||
if (currentTxPowerConfig.mode == RAIL_TX_POWER_MODE_NONE) {
|
||||
#if RAIL_SUPPORTS_OFDM_PA
|
||||
if (RAIL_SupportsTxPowerModeAlt(rail_handle,
|
||||
&txPowerConfigOFDM.mode,
|
||||
NULL, NULL)) {
|
||||
// Apply OFDM Power Config.
|
||||
status = RAIL_ConfigTxPower(rail_handle, &txPowerConfigOFDM);
|
||||
if (status != RAIL_STATUS_NO_ERROR) {
|
||||
while (true) {
|
||||
} // Error: Can't set TX Power Config
|
||||
}
|
||||
// Set default TX power after RAIL_ConfigTxPower.
|
||||
status = RAIL_SetTxPowerDbm(rail_handle, SL_RAIL_UTIL_PA_POWER_DECI_DBM);
|
||||
if (status != RAIL_STATUS_NO_ERROR) {
|
||||
while (true) {
|
||||
} // Error: Can't set TX Power
|
||||
}
|
||||
}
|
||||
#endif // RAIL_SUPPORTS_OFDM_PA
|
||||
// Apply FSK Power Config.
|
||||
status = RAIL_ConfigTxPower(rail_handle, newTxPowerConfigPtr);
|
||||
if (status != RAIL_STATUS_NO_ERROR) {
|
||||
while (true) {
|
||||
} // Error: Can't set TX Power Config
|
||||
}
|
||||
// Set default TX power after RAIL_ConfigTxPower.
|
||||
status = RAIL_SetTxPowerDbm(rail_handle, SL_RAIL_UTIL_PA_POWER_DECI_DBM);
|
||||
if (status != RAIL_STATUS_NO_ERROR) {
|
||||
while (true) {
|
||||
} // Error: Can't set TX Power
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Call RAIL_ConfigTxPower only if TX Power Config mode has changed.
|
||||
if (currentTxPowerConfig.mode != newTxPowerConfigPtr->mode) {
|
||||
// Save current TX power before RAIL_ConfigTxPower (because not preserved).
|
||||
RAIL_TxPower_t txPowerDeciDbm;
|
||||
if (currentTxPowerConfig.mode == RAIL_TX_POWER_MODE_NONE) {
|
||||
txPowerDeciDbm = SL_RAIL_UTIL_PA_POWER_DECI_DBM;
|
||||
} else {
|
||||
txPowerDeciDbm = RAIL_GetTxPowerDbm(rail_handle);
|
||||
}
|
||||
|
||||
// Apply new TX Power Config.
|
||||
status = RAIL_ConfigTxPower(rail_handle, newTxPowerConfigPtr);
|
||||
if (status != RAIL_STATUS_NO_ERROR) {
|
||||
while (true) {
|
||||
} // Error: Can't set TX Power Config
|
||||
}
|
||||
// Restore TX power after RAIL_ConfigTxPower.
|
||||
status = RAIL_SetTxPowerDbm(rail_handle, txPowerDeciDbm);
|
||||
if (status != RAIL_STATUS_NO_ERROR) {
|
||||
while (true) {
|
||||
} // Error: Can't set TX Power
|
||||
}
|
||||
// If requested a HIGHEST setting, update it with the real one selected
|
||||
// to short-circuit the next time through here since HIGHEST never
|
||||
// matches the real PA returned by RAIL_GetTxPowerConfig(), causing
|
||||
// reconfiguration of the same PA on every callback.
|
||||
if (false
|
||||
#ifdef RAIL_TX_POWER_MODE_2P4GIG_HIGHEST
|
||||
|| (newTxPowerConfigPtr->mode == RAIL_TX_POWER_MODE_2P4GIG_HIGHEST)
|
||||
#endif
|
||||
#ifdef RAIL_TX_POWER_MODE_SUBGIG_HIGHEST
|
||||
|| (newTxPowerConfigPtr->mode == RAIL_TX_POWER_MODE_SUBGIG_HIGHEST)
|
||||
#endif
|
||||
) {
|
||||
(void) RAIL_GetTxPowerConfig(rail_handle, ¤tTxPowerConfig);
|
||||
newTxPowerConfigPtr->mode = currentTxPowerConfig.mode;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // !RAIL_IsPaAutoModeEnabled
|
||||
}
|
||||
#endif // !RAIL_PA_CONVERSIONS_WEAK
|
||||
@@ -0,0 +1,188 @@
|
||||
/***************************************************************************//**
|
||||
* @file
|
||||
* @brief PA power conversion functions provided to the customer as source for
|
||||
* highest level of customization.
|
||||
* @details This file contains the curves and logic that convert PA power
|
||||
* levels to dBm powers.
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* SPDX-License-Identifier: Zlib
|
||||
*
|
||||
* The licensor of this software is Silicon Laboratories Inc.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef PA_CONVERSIONS_EFR32_H
|
||||
#define PA_CONVERSIONS_EFR32_H
|
||||
|
||||
#include "rail_types.h"
|
||||
|
||||
// This macro is defined when Silicon Labs builds curves into the library as WEAK
|
||||
// to ensure it can be overriden by customer versions of these functions. It
|
||||
// should *not* be defined in a customer build.
|
||||
#ifndef RAIL_PA_CONVERSIONS_WEAK
|
||||
#ifdef SL_RAIL_UTIL_PA_CONFIG_HEADER
|
||||
#include SL_RAIL_UTIL_PA_CONFIG_HEADER
|
||||
#else
|
||||
#include "sl_rail_util_pa_conversions_efr32_config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAL_CONFIG
|
||||
#include "hal-config.h"
|
||||
#ifdef HAL_PA_CURVE_HEADER
|
||||
#ifdef SL_RAIL_UTIL_PA_CURVE_HEADER
|
||||
#undef SL_RAIL_UTIL_PA_CURVE_HEADER
|
||||
#endif
|
||||
#define SL_RAIL_UTIL_PA_CURVE_HEADER HAL_PA_CURVE_HEADER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SL_RAIL_UTIL_PA_CURVE_TYPES
|
||||
#include SL_RAIL_UTIL_PA_CURVE_TYPES
|
||||
#else
|
||||
#include "pa_curve_types_efr32.h"
|
||||
#endif
|
||||
|
||||
#ifdef SL_RAIL_UTIL_PA_CURVE_HEADER
|
||||
#include SL_RAIL_UTIL_PA_CURVE_HEADER
|
||||
#else
|
||||
#include "pa_curves_efr32.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup PA_Curve_Conversions PA Curve Conversions
|
||||
* @ingroup PA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// The curves to be used when battery voltage powers transmission
|
||||
extern const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesVbat;
|
||||
|
||||
/// The curves to be used when the DC-DC converter powers transmission
|
||||
extern const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesDcdc;
|
||||
|
||||
/**
|
||||
* Initialize Transmit power curves.
|
||||
*
|
||||
* @param[in] config A pointer to the custom TX power curves.
|
||||
* @return Status code indicating success of the function call.
|
||||
*
|
||||
* @deprecated function is no longer supported.
|
||||
* Must use \ref RAIL_InitTxPowerCurvesAlt() instead.
|
||||
*/
|
||||
RAIL_Status_t RAIL_InitTxPowerCurves(const RAIL_TxPowerCurvesConfig_t *config);
|
||||
|
||||
/**
|
||||
* Initialize TxPower curves.
|
||||
*
|
||||
* @param[in] config A pointer to the custom TX power curves to use.
|
||||
* @return Status code indicating success of the function call.
|
||||
*/
|
||||
RAIL_Status_t RAIL_InitTxPowerCurvesAlt(const RAIL_TxPowerCurvesConfigAlt_t *config);
|
||||
|
||||
/**
|
||||
* Gets the curve that should be used for conversion functions based on the
|
||||
* current PA configuration.
|
||||
*
|
||||
* @param[in] mode PA mode whose curves are needed.
|
||||
* @return A pointer to the \ref RAIL_TxPowerCurves_t that are used for conversion functions.
|
||||
*
|
||||
* @note: If the mode is not supported by the the chip,
|
||||
* then NULL will be returned.
|
||||
*/
|
||||
RAIL_TxPowerCurves_t const *RAIL_GetTxPowerCurve(RAIL_TxPowerMode_t mode);
|
||||
|
||||
/**
|
||||
* Gets the maximum power in deci-dBm that should be used for calculating
|
||||
* the segments and to find right curve segment to convert Dbm to raw power
|
||||
* level for a specific PA.
|
||||
*
|
||||
* @param[in] railHandle A RAIL instance handle.
|
||||
* @param[in] mode PA mode whose curves are needed.
|
||||
* @param[out] maxpower A non-NULL pointer to memory allocated to hold
|
||||
* the max power in deci-dBm used in calculation of curve segments.
|
||||
* @param[out] increment A non-NULL pointer to memory allocated to hold
|
||||
* the increment in deci-dBm used in calculation of curve segments.
|
||||
* @return Status code indicating success of the function call.
|
||||
*
|
||||
* For the PAs with \ref RAIL_PaConversionAlgorithm_t
|
||||
* \ref RAIL_PA_ALGORITHM_PIECEWISE_LINEAR, if the curves are generated with
|
||||
* maxPower and increment other than \ref RAIL_TX_POWER_CURVE_DEFAULT_MAX and
|
||||
* \ref RAIL_TX_POWER_CURVE_DEFAULT_INCREMENT respectively, then the first
|
||||
* \ref RAIL_TxPowerCurveSegment_t has its maxPowerLevel equal to
|
||||
* \ref RAIL_TX_POWER_LEVEL_INVALID and its slope and intercept stores the
|
||||
* maxPower and increment in deci-dBm respectively.
|
||||
*/
|
||||
RAIL_Status_t RAIL_GetTxPowerCurveLimits(RAIL_Handle_t railHandle,
|
||||
RAIL_TxPowerMode_t mode,
|
||||
RAIL_TxPower_t *maxpower,
|
||||
RAIL_TxPower_t *increment);
|
||||
|
||||
/**
|
||||
* Initialize PA TX Curves.
|
||||
*/
|
||||
void sl_rail_util_pa_init(void);
|
||||
|
||||
/**
|
||||
* Get a pointer to the TX Power Config 2.4 GHz structure.
|
||||
*
|
||||
* @return A pointer to the TX Power Config stucture.
|
||||
*/
|
||||
RAIL_TxPowerConfig_t *sl_rail_util_pa_get_tx_power_config_2p4ghz(void);
|
||||
|
||||
/**
|
||||
* Get a pointer to the TX Power Config Sub-GHz structure.
|
||||
*
|
||||
* @return A pointer to the TX Power Config stucture.
|
||||
*/
|
||||
RAIL_TxPowerConfig_t *sl_rail_util_pa_get_tx_power_config_subghz(void);
|
||||
|
||||
/**
|
||||
* Get a pointer to the TX Power Config OFDM structure.
|
||||
*
|
||||
* @return A pointer to the TX Power Config stucture.
|
||||
*/
|
||||
RAIL_TxPowerConfig_t *sl_rail_util_pa_get_tx_power_config_ofdm(void);
|
||||
|
||||
/**
|
||||
* Provide a channel config change callback capable of configuring the PA
|
||||
* correctly.
|
||||
*
|
||||
* @param[in] rail_handle The RAIL handle being passed into this callback.
|
||||
* @param[in] entry A pointer to the channel config entry being switched
|
||||
* to by hardware.
|
||||
*/
|
||||
void sl_rail_util_pa_on_channel_config_change(RAIL_Handle_t rail_handle,
|
||||
const RAIL_ChannelConfigEntry_t *entry);
|
||||
|
||||
/** @} */ // PA_Curve_Conversions
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PA_CONVERSIONS_EFR32_H
|
||||
@@ -0,0 +1,290 @@
|
||||
/***************************************************************************//**
|
||||
* @file
|
||||
* @brief PA power conversion curve types used by Silicon Labs PA power
|
||||
* conversion functions.
|
||||
* @details This file contains the curve types needed convert PA power levels
|
||||
* to dBm powers.
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* SPDX-License-Identifier: Zlib
|
||||
*
|
||||
* The licensor of this software is Silicon Laboratories Inc.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef PA_CURVE_TYPES_EFR32_H
|
||||
#define PA_CURVE_TYPES_EFR32_H
|
||||
|
||||
#include "rail_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup PA_Curve_Conversions PA Curve Conversions
|
||||
* @ingroup PA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @struct RAIL_TxPowerCurveSegment_t
|
||||
*
|
||||
* @brief Structure containing data defining each segment of the
|
||||
* deci-dBm to raw power level mapping curve fits.
|
||||
*
|
||||
* Note, these used in an equation of the form:
|
||||
*
|
||||
* powerLevel * 1000 = slope * power + intercept
|
||||
*
|
||||
* powerLevel is the 0-252/0-248/1-7 values used in the RAIL_Get/SetTxPower()
|
||||
* functions, and power is the actual output power of the PA, specified
|
||||
* in deci-dBm.
|
||||
*
|
||||
* @note If the curves are generated with
|
||||
* maxPower and increment other than \ref RAIL_TX_POWER_CURVE_DEFAULT_MAX and
|
||||
* \ref RAIL_TX_POWER_CURVE_DEFAULT_INCREMENT respectively, then the first
|
||||
* \ref RAIL_TxPowerCurveSegment_t has its maxPowerLevel equal to
|
||||
* \ref RAIL_TX_POWER_LEVEL_INVALID and its slope and intercept stores the
|
||||
* maxPower and increment in deci-dBm respectively.
|
||||
*/
|
||||
typedef struct RAIL_TxPowerCurveSegment {
|
||||
/** The highest power level that this segment will be used to convert */
|
||||
uint16_t maxPowerLevel;
|
||||
/** slope of the line */
|
||||
int16_t slope;
|
||||
/** y-intercept of the line */
|
||||
int32_t intercept;
|
||||
} RAIL_TxPowerCurveSegment_t;
|
||||
|
||||
/**
|
||||
* @struct RAIL_TxPowerCurves_t
|
||||
*
|
||||
* @brief Structure containing the min and max values for a given
|
||||
* PA and voltage supply combination (in deci-dBm).
|
||||
*/
|
||||
typedef struct RAIL_TxPowerCurves {
|
||||
/** max deci-dBm value */
|
||||
int16_t maxPower;
|
||||
/** min deci-dBm value */
|
||||
int16_t minPower;
|
||||
/**
|
||||
* Pointer to an array of \ref RAIL_TxPowerCurvesConfig_t::piecewiseSegments
|
||||
* elements of \ref RAIL_TxPowerCurveSegment_t for deci-dBm to raw
|
||||
* power level conversion fits.
|
||||
*/
|
||||
const RAIL_TxPowerCurveSegment_t *powerParams;
|
||||
} RAIL_TxPowerCurves_t;
|
||||
|
||||
/**
|
||||
* @struct RAIL_TxPowerCurvesConfig_t
|
||||
*
|
||||
* @brief Structure containing curve fit information and other metadata
|
||||
* required to properly use the WEAK versions of RAIL_ConvertRawToDb
|
||||
* and RAIL_ConvertDbmToRaw.
|
||||
*/
|
||||
typedef struct RAIL_TxPowerCurvesConfig {
|
||||
/**
|
||||
* Pointer a RAIL_TxPowerCurves_t representing the piecewise linear segments
|
||||
* of curves that map power level to power in dBm for the 2.4 GHz high power
|
||||
* PA.
|
||||
*
|
||||
* @note By the default conversion implementation, segments must be specified
|
||||
* in decreasing power order. That is, the 0th entry of this array should be
|
||||
* used to convert the highest power (levels). Segment at position n is valid
|
||||
* from maxPowerLevel+1 from the segment at n+1 (or 0 if n is array length - 1)
|
||||
* to maxPowerLevel of segment n, inclusive.
|
||||
*/
|
||||
const RAIL_TxPowerCurves_t *txPower24HpCurves;
|
||||
|
||||
/**
|
||||
* Pointer a RAIL_TxPowerCurves_t representing the piecewise linear segments
|
||||
* of curves that map power level to power in dBm for the subgig PA.
|
||||
*
|
||||
* @note By the default conversion implementation, segments must be specified
|
||||
* in decreasing power order. That is, the 0th entry of this array should be
|
||||
* used to convert the highest power (levels). Segment at position n is valid
|
||||
* from maxPowerLevel+1 from the segment at n+1 (or 0 if n is array length - 1)
|
||||
* to maxPowerLevel of segment n, inclusive.
|
||||
*/
|
||||
const RAIL_TxPowerCurves_t *txPowerSgCurves;
|
||||
|
||||
/**
|
||||
* Look up table for each of the power levels of the 2.4GHz low power
|
||||
* amplifier and their equivalent deci-dB value.
|
||||
*/
|
||||
const int16_t *txPower24LpCurves;
|
||||
/**
|
||||
* The number of piecewise segments provided to the PA in each of the four
|
||||
* conversion curve fits. The default is 8, but regardless of the number, it
|
||||
* must be the same for all curves.
|
||||
*/
|
||||
uint8_t piecewiseSegments;
|
||||
} RAIL_TxPowerCurvesConfig_t;
|
||||
|
||||
/**
|
||||
* @enum RAIL_PaConversionAlgorithm_t
|
||||
* @brief PA conversion algorithms types for converting between dBm and power levels
|
||||
*/
|
||||
RAIL_ENUM(RAIL_PaConversionAlgorithm_t) {
|
||||
/** Piecewise linear fit */
|
||||
RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
/** Mapping table between quantities */
|
||||
RAIL_PA_ALGORITHM_MAPPING_TABLE,
|
||||
/** Mapping table between pa power settings and dBm values */
|
||||
RAIL_PA_ALGORITHM_DBM_POWERSETTING_MAPPING_TABLE,
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
// Self-referencing defines minimize compiler complaints when using RAIL_ENUM
|
||||
#define RAIL_PA_ALGORITHM_PIECEWISE_LINEAR ((RAIL_PaConversionAlgorithm_t) RAIL_PA_ALGORITHM_PIECEWISE_LINEAR)
|
||||
#define RAIL_PA_ALGORITHM_MAPPING_TABLE ((RAIL_PaConversionAlgorithm_t) RAIL_PA_ALGORITHM_MAPPING_TABLE)
|
||||
#define RAIL_PA_ALGORITHM_DBM_POWERSETTING_MAPPING_TABLE ((RAIL_PaConversionAlgorithm_t) RAIL_PA_ALGORITHM_DBM_POWERSETTING_MAPPING_TABLE)
|
||||
#endif//DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
/**
|
||||
* @struct RAIL_TxPowerCurveAlt_t
|
||||
*
|
||||
* @brief Structure containing the min and max values for a given
|
||||
* PA and voltage supply combination (in deci-dBm).
|
||||
*/
|
||||
typedef struct RAIL_TxPowerCurveAlt {
|
||||
/** max deci-dBm value */
|
||||
int16_t maxPower;
|
||||
/** min deci-dBm value */
|
||||
int16_t minPower;
|
||||
/**
|
||||
* Array of \ref RAIL_PaDescriptor_t::segments \ref RAIL_TxPowerCurveSegment_t
|
||||
* structures for the deci-dBm to raw power level conversion fits.
|
||||
*/
|
||||
//Array does not have a size since it can be various sizes.
|
||||
//No further fields allowed after this one.
|
||||
RAIL_TxPowerCurveSegment_t powerParams[];
|
||||
} RAIL_TxPowerCurveAlt_t;
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
#if defined(SL_RAIL_UTIL_PA_POWERSETTING_TABLE_VERSION)
|
||||
#if RAIL_SUPPORTS_COMMON_PA_INTERFACE
|
||||
#if SL_RAIL_UTIL_PA_POWERSETTING_TABLE_VERSION == 1
|
||||
/// The entry in the powersetting table have the below bitfields
|
||||
/// |15-14 =sub-mode|13-8:unused|7-0:scalor(stripe+slice)|
|
||||
/// Mask for submode
|
||||
#define SLI_RAIL_UTIL_PA_TABLE_SUBMODE_MASK 0xC000UL
|
||||
/// Shift for submode
|
||||
#define SLI_RAIL_UTIL_PA_TABLE_SUBMODE_SHIFT 14U
|
||||
/// Mask for scalor
|
||||
#define SLI_RAIL_UTIL_PATABLE_SCALOR_MASK 0xFFU
|
||||
/// Shift for scalor
|
||||
#define SLI_RAIL_UTIL_PA_TABLE_SCALOR_SHIFT 0U
|
||||
#endif //SL_RAIL_UTIL_PA_POWERSETTING_TABLE_VERSION == 1
|
||||
#endif //RAIL_SUPPORTS_COMMON_PA_INTERFACE
|
||||
#endif //defined(SL_RAIL_UTIL_PA_POWERSETTING_TABLE_VERSION)
|
||||
#endif //DOXYGEN_SHOULD_SKIP_THIS
|
||||
/**
|
||||
* @struct RAIL_PowerConversion_t
|
||||
*
|
||||
* @brief Union containing a pointer to algorithm-specific conversion data.
|
||||
*/
|
||||
typedef union RAIL_PowerConversion {
|
||||
/**
|
||||
* Pointer to a powerCurve containing line segment data for the curves
|
||||
* corresponding to a specific PA.
|
||||
*
|
||||
* @note By the default conversion implementation, segments must be specified
|
||||
* in decreasing power order. That is, the 0th entry of this array should be
|
||||
* used to convert the highest power (levels). Segment at position n is valid
|
||||
* from maxPowerLevel+1 from the segment at n+1 (or 0 if n is array length - 1)
|
||||
* to maxPowerLevel of segment n, inclusive.
|
||||
*/
|
||||
const RAIL_TxPowerCurveAlt_t *powerCurve;
|
||||
/**
|
||||
* Lookup table for PA's which use the mapping table algorithm for converting
|
||||
* between deci-dBm and power levels.
|
||||
*/
|
||||
#if RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
#if RAIL_SUPPORTS_COMMON_PA_INTERFACE
|
||||
const int16_t *mappingTable;
|
||||
#else
|
||||
const int32_t *mappingTable;
|
||||
#endif
|
||||
#else
|
||||
const int16_t *mappingTable;
|
||||
#endif
|
||||
} RAIL_PowerConversion_t;
|
||||
|
||||
/**
|
||||
* @struct RAIL_PaDescriptor_t
|
||||
*
|
||||
* @brief Struct containing specifics of PA configuration.
|
||||
* PA descriptor as used in the PA conversion functions.
|
||||
*/
|
||||
typedef struct RAIL_PaDescriptor {
|
||||
/** Algorithm used to map dBm to power levels for this PA. */
|
||||
RAIL_PaConversionAlgorithm_t algorithm;
|
||||
/**
|
||||
* The number of piecewise segments provided to the PA in a piecewise linear
|
||||
* curve fit. The default is 8. Should be set to 0 when not using the
|
||||
* piecewise linear algorithm.
|
||||
*/
|
||||
uint8_t segments;
|
||||
/** Min power level for this PA. */
|
||||
RAIL_TxPowerLevel_t min;
|
||||
/** Max power level for this PA. */
|
||||
RAIL_TxPowerLevel_t max;
|
||||
#if RAIL_SUPPORTS_DBM_POWERSETTING_MAPPING_TABLE
|
||||
/** step size in deci-dBm between entries in table. */
|
||||
RAIL_TxPowerLevel_t step;
|
||||
/** structure padding. */
|
||||
uint8_t padding;
|
||||
/** structure padding. */
|
||||
uint16_t padding2;
|
||||
/** Min power in deci-dBm for this PA. */
|
||||
RAIL_TxPower_t minPowerDbm;
|
||||
/** Max power in deci-dBm for this PA. */
|
||||
RAIL_TxPower_t maxPowerDbm;
|
||||
#endif
|
||||
/** Union containing a pointer to algorithm-specific conversion data. */
|
||||
RAIL_PowerConversion_t conversion;
|
||||
} RAIL_PaDescriptor_t;
|
||||
|
||||
/**
|
||||
* @struct RAIL_TxPowerCurvesConfigAlt_t
|
||||
*
|
||||
* @brief More generic structure containing information about
|
||||
* piecewise linear curves and mapping tables, instead of specific PA's.
|
||||
*/
|
||||
typedef struct RAIL_TxPowerCurvesConfigAlt {
|
||||
/** The curves for each PA. */
|
||||
RAIL_PaDescriptor_t curves[RAIL_NUM_PA];
|
||||
/** Signature used for validation of the curves configuruation. */
|
||||
uint32_t signature;
|
||||
/** PA VDD voltage, in millivolts. */
|
||||
uint16_t paVoltage;
|
||||
} RAIL_TxPowerCurvesConfigAlt_t;
|
||||
|
||||
/** @} */ // PA_Curve_Conversions
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PA_CURVE_TYPES_EFR32_H
|
||||
@@ -0,0 +1,383 @@
|
||||
/***************************************************************************//**
|
||||
* @file
|
||||
* @brief Default PA power conversion structures with curves calibrated by the
|
||||
* RAIL team.
|
||||
* @details This file contains the curves that convert PA power levels to dBm
|
||||
* powers.
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* SPDX-License-Identifier: Zlib
|
||||
*
|
||||
* The licensor of this software is Silicon Laboratories Inc.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
// This entire file should never be used on FCC pre-certified modules
|
||||
#ifndef _SILICON_LABS_MODULE
|
||||
|
||||
#include "em_device.h"
|
||||
#include "pa_conversions_efr32.h"
|
||||
|
||||
#if defined(_SILICON_LABS_32B_SERIES_1)
|
||||
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHpVbat = {
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_CURVES
|
||||
};
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataSgVbat = {
|
||||
RAIL_PA_CURVES_SG_VBAT_MAX_POWER,
|
||||
RAIL_PA_CURVES_SG_VBAT_MIN_POWER,
|
||||
RAIL_PA_CURVES_SG_VBAT_CURVES
|
||||
};
|
||||
static const int16_t RAIL_curves24LpVbat[RAIL_PA_CURVES_LP_VALUES] =
|
||||
RAIL_PA_CURVES_2P4_LP;
|
||||
|
||||
// This macro is defined when Silicon Labs builds this into the library as WEAK
|
||||
// to ensure it can be overriden by customer versions of these functions. It
|
||||
// should *not* be defined in a customer build.
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesVbat = {
|
||||
.curves = {
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpVbat },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE,
|
||||
.segments = 0U,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX,
|
||||
.conversion = { .mappingTable = &RAIL_curves24LpVbat[0] },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_SUBGIG_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_SUBGIG_HP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataSgVbat },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHpDcdc = {
|
||||
RAIL_PA_CURVES_2P4_HP_DCDC_MAX_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_DCDC_MIN_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_DCDC_CURVES
|
||||
};
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataSgDcdc = {
|
||||
RAIL_PA_CURVES_SG_DCDC_MAX_POWER,
|
||||
RAIL_PA_CURVES_SG_DCDC_MIN_POWER,
|
||||
RAIL_PA_CURVES_SG_DCDC_CURVES
|
||||
};
|
||||
static const int16_t RAIL_curves24LpDcdc[RAIL_PA_CURVES_LP_VALUES] =
|
||||
RAIL_PA_CURVES_2P4_LP;
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesDcdc = {
|
||||
.curves = {
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpDcdc },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE,
|
||||
.segments = 0U,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX,
|
||||
.conversion = { .mappingTable = &RAIL_curves24LpDcdc[0] },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_2P4_HP_SG_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_SUBGIG_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_SUBGIG_HP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataSgDcdc },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
#elif ((_SILICON_LABS_32B_SERIES_2_CONFIG == 2) \
|
||||
|| (_SILICON_LABS_32B_SERIES_2_CONFIG == 7) \
|
||||
|| (_SILICON_LABS_32B_SERIES_2_CONFIG == 9))
|
||||
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHpVbat = {
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_CURVES,
|
||||
};
|
||||
static const int16_t RAIL_curves24Lp[RAIL_PA_CURVES_LP_VALUES] =
|
||||
RAIL_PA_CURVES_2P4_LP_VBAT_CURVES;
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesVbat = {
|
||||
.curves = {
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpVbat },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE,
|
||||
.segments = 0U,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX,
|
||||
.conversion = { .mappingTable = &RAIL_curves24Lp[0] },
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesDcdc = {
|
||||
.curves = {
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpVbat },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE,
|
||||
.segments = 0U,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX,
|
||||
.conversion = { .mappingTable = &RAIL_curves24Lp[0] },
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
#elif ((_SILICON_LABS_32B_SERIES_2_CONFIG == 3) || (_SILICON_LABS_32B_SERIES_2_CONFIG == 8))
|
||||
|
||||
RAIL_DECLARE_TX_POWER_VBAT_CURVES_ALT;
|
||||
|
||||
// This chip has the same curve for Vbat and DCDC
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesVbat = RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT;
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesDcdc = RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT;
|
||||
|
||||
#elif defined(_SILICON_LABS_32B_SERIES_2_CONFIG_5)
|
||||
|
||||
static const int32_t RAIL_curvesOFDM[RAIL_PA_CURVES_OFDM_CURVES_NUM_VALUES] =
|
||||
RAIL_PA_CURVES_OFDM_CURVES;
|
||||
|
||||
static const int32_t RAIL_curvesSubgig[RAIL_PA_CURVES_SUBGIG_CURVES_NUM_VALUES] =
|
||||
RAIL_PA_CURVES_SUBGIG_CURVES;
|
||||
|
||||
// This chip has the same curve for Vbat and DCDC
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesVbat = RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT;
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesDcdc = RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT;
|
||||
|
||||
#elif defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1)
|
||||
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHpVbat = {
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_CURVES,
|
||||
};
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataMpVbat = {
|
||||
RAIL_PA_CURVES_2P4_MP_VBAT_MAX_POWER,
|
||||
RAIL_PA_CURVES_2P4_MP_VBAT_MIN_POWER,
|
||||
RAIL_PA_CURVES_2P4_MP_VBAT_CURVES,
|
||||
};
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataLpVbat = {
|
||||
RAIL_PA_CURVES_2P4_LP_VBAT_MAX_POWER,
|
||||
RAIL_PA_CURVES_2P4_LP_VBAT_MIN_POWER,
|
||||
RAIL_PA_CURVES_2P4_LP,
|
||||
};
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesVbat = {
|
||||
.curves = {
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpVbat },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_MP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_MP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataMpVbat },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataLpVbat },
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesDcdc = {
|
||||
.curves = {
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_HP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_HP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpVbat },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_MP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_MP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataMpVbat },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_LP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_LP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataLpVbat },
|
||||
},
|
||||
}
|
||||
};
|
||||
#elif defined(_SILICON_LABS_32B_SERIES_2_CONFIG_4) || defined(_SILICON_LABS_32B_SERIES_2_CONFIG_6)
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHpVbat = {
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MAX_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_MIN_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_VBAT_CURVES,
|
||||
};
|
||||
|
||||
#if defined(RAIL_DECLARE_TX_POWER_DCDC_CURVES_ALT)
|
||||
static const RAIL_TxPowerCurveAlt_t RAIL_piecewiseDataHpDcdc = {
|
||||
RAIL_PA_CURVES_2P4_HP_DCDC_MAX_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_DCDC_MIN_POWER,
|
||||
RAIL_PA_CURVES_2P4_HP_DCDC_CURVES,
|
||||
};
|
||||
#endif
|
||||
|
||||
static const int16_t RAIL_curves24Lp[RAIL_PA_CURVES_LP_VALUES] =
|
||||
RAIL_PA_CURVES_2P4_LP_VBAT_CURVES;
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesVbat = {
|
||||
.curves = {
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX,
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpVbat },
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE,
|
||||
.segments = 0U,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX,
|
||||
.conversion = { .mappingTable = &RAIL_curves24Lp[0] },
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesDcdc = {
|
||||
.curves = {
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_PIECEWISE_LINEAR,
|
||||
.segments = RAIL_PA_CURVES_PIECEWISE_SEGMENTS,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_HP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_HP_MAX,
|
||||
#if defined(RAIL_DECLARE_TX_POWER_DCDC_CURVES_ALT)
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpDcdc },
|
||||
#else
|
||||
.conversion = { .powerCurve = &RAIL_piecewiseDataHpVbat },
|
||||
#endif
|
||||
},
|
||||
{
|
||||
.algorithm = RAIL_PA_ALGORITHM_MAPPING_TABLE,
|
||||
.segments = 0U,
|
||||
.min = RAIL_TX_POWER_LEVEL_2P4_LP_MIN,
|
||||
.max = RAIL_TX_POWER_LEVEL_2P4_LP_MAX,
|
||||
.conversion = { .mappingTable = &RAIL_curves24Lp[0] },
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
#elif !defined(_SILICON_LABS_32B_SERIES_2)
|
||||
|
||||
static const int16_t RAIL_curves10dbm[RAIL_PA_CURVES_COMMON_INTERFACE_10DBM_NUM_VALUES] =
|
||||
RAIL_PA_CURVES_COMMON_INTERFACE_10DBM_CURVES;
|
||||
|
||||
static const int16_t RAIL_curves0dbm[RAIL_PA_CURVES_COMMON_INTERFACE_0DBM_NUM_VALUES] =
|
||||
RAIL_PA_CURVES_COMMON_INTERFACE_0DBM_CURVES;
|
||||
|
||||
// This chip has the same curve for Vbat and DCDC
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesVbat = RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT;
|
||||
|
||||
#ifdef RAIL_PA_CONVERSIONS_WEAK
|
||||
__WEAK
|
||||
#endif
|
||||
const RAIL_TxPowerCurvesConfigAlt_t RAIL_TxPowerCurvesDcdc = RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT;
|
||||
|
||||
#else
|
||||
#error "Unsupported platform!"
|
||||
#endif
|
||||
|
||||
#endif //_SILICON_LABS_MODULE
|
||||
@@ -0,0 +1,129 @@
|
||||
/***************************************************************************//**
|
||||
* @file
|
||||
* @brief PA power conversion curves used by Silicon Labs PA power conversion
|
||||
* functions.
|
||||
* @details This file contains the curves needed convert PA power levels to
|
||||
* dBm powers.
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* SPDX-License-Identifier: Zlib
|
||||
*
|
||||
* The licensor of this software is Silicon Laboratories Inc.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef PA_CURVES_EFR32_H
|
||||
#define PA_CURVES_EFR32_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "em_device.h"
|
||||
|
||||
#ifdef _SILICON_LABS_32B_SERIES_1
|
||||
#include "efr32xg1x/sl_rail_util_pa_curves.h"
|
||||
#elif defined (_SILICON_LABS_32B_SERIES_2_CONFIG_1)
|
||||
#include "efr32xg21/sl_rail_util_pa_curves.h"
|
||||
#elif defined(_SILICON_LABS_32B_SERIES_2_CONFIG_2)
|
||||
#include "efr32xg22/sl_rail_util_pa_curves.h"
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 3)
|
||||
#if defined(_SILICON_LABS_EFR32_SUBGHZ_HP_PA_PRESENT)
|
||||
#if (_SILICON_LABS_EFR32_SUBGHZ_HP_PA_MAX_OUTPUT_DBM == 20)
|
||||
#include "efr32xg23/sl_rail_util_pa_curves_20dbm.h"
|
||||
#elif (_SILICON_LABS_EFR32_SUBGHZ_HP_PA_MAX_OUTPUT_DBM == 10)
|
||||
#include "efr32xg23/sl_rail_util_pa_curves_10dbm_434M.h"
|
||||
#else
|
||||
#include "efr32xg23/sl_rail_util_pa_curves_14dbm.h"
|
||||
#endif
|
||||
#else
|
||||
#error "No valid PA available for selected chip."
|
||||
#endif
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 8)
|
||||
#if defined(_SILICON_LABS_EFR32_SUBGHZ_HP_PA_PRESENT)
|
||||
#if (_SILICON_LABS_EFR32_SUBGHZ_HP_PA_MAX_OUTPUT_DBM == 20)
|
||||
#if defined(HARDWARE_BOARD_SUPPORTS_RF_BAND_868)
|
||||
#include "efr32xg28/sl_rail_util_pa_curves_20dbm_868M.h"
|
||||
#else
|
||||
#include "efr32xg28/sl_rail_util_pa_curves_20dbm_915M.h"
|
||||
#endif
|
||||
#else
|
||||
#if defined(HARDWARE_BOARD_SUPPORTS_RF_BAND_868)
|
||||
#include "efr32xg28/sl_rail_util_pa_curves_14dbm_868M.h"
|
||||
#else
|
||||
#include "efr32xg28/sl_rail_util_pa_curves_14dbm_915M.h"
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#error "No valid PA available for selected chip."
|
||||
#endif
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 4)
|
||||
#if defined(_SILICON_LABS_EFR32_2G4HZ_HP_PA_PRESENT) \
|
||||
&& (_SILICON_LABS_EFR32_2G4HZ_HP_PA_MAX_OUTPUT_DBM > 10)
|
||||
#include "efr32xg24/sl_rail_util_pa_curves_20dbm.h"
|
||||
#else
|
||||
#include "efr32xg24/sl_rail_util_pa_curves_10dbm.h"
|
||||
#endif
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 5)
|
||||
#include "efr32xg25/sl_rail_util_pa_dbm_powersetting_mapping_table.h"
|
||||
#include "efr32xg25/sl_rail_util_pa_curves.h"
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 6)
|
||||
#if defined(_SILICON_LABS_EFR32_2G4HZ_HP_PA_PRESENT) \
|
||||
&& (_SILICON_LABS_EFR32_2G4HZ_HP_PA_MAX_OUTPUT_DBM > 10)
|
||||
#include "efr32xg26/sl_rail_util_pa_curves_20dbm.h"
|
||||
#else
|
||||
#if defined(EFR32MG26B510F3200IL136)
|
||||
#include "efr32xg26/sl_rail_util_pa_curves_BGA.h"
|
||||
#else
|
||||
#include "efr32xg26/sl_rail_util_pa_curves_10dbm.h"
|
||||
#endif
|
||||
#endif
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 7)
|
||||
// EFR32XG27 boards come in two different packaging -- CSP and QFN
|
||||
// These packages have different matching circuits which leads
|
||||
// to different PA curves.
|
||||
// CSP packages have _SILICON_LABS_EFR32_2G4HZ_HP_PA_MAX_OUTPUT_DBM
|
||||
// = 4 whereas for QFN package it is 6 or 8dBm, so this parameter
|
||||
// is used to differentiate it.
|
||||
#if (_SILICON_LABS_EFR32_2G4HZ_HP_PA_MAX_OUTPUT_DBM < 6)
|
||||
#include "efr32xg27/sl_rail_util_pa_curves_CSP.h"
|
||||
#else
|
||||
#include "efr32xg27/sl_rail_util_pa_curves_QFN.h"
|
||||
#endif
|
||||
#elif (_SILICON_LABS_32B_SERIES_2_CONFIG == 9)
|
||||
#include "efr32xg29/sl_rail_util_pa_curves.h"
|
||||
#elif defined(_SILICON_LABS_32B_SERIES_3)
|
||||
#include "sixg301/sl_rail_util_pa_dbm_powersetting_mapping_table.h"
|
||||
#include "sixg301/sl_rail_util_pa_curves.h"
|
||||
#else
|
||||
#ifdef RAIL_INTERNAL_BUILD
|
||||
#include "pa_curves_efr32_internal.h"
|
||||
#else
|
||||
#error "Unsupported platform!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PA_CURVES_EFR32_H
|
||||
Reference in New Issue
Block a user