APIs for interacting with one of the on chip PAs.
Modules |
|
EFR32 | |
Types specific to the EFR32 for dealing with the on-chip PAs.
|
Macros |
|
#define | RAIL_TX_POWER_MAX (( RAIL_TxPower_t )0x7FFF) |
The maximum valid value for a
RAIL_TxPower_t
.
|
|
#define | RAIL_TX_POWER_MIN (( RAIL_TxPower_t )0x8000) |
The minimum valid value for a
RAIL_TxPower_t
.
|
|
#define | RAIL_TX_POWER_VOLTAGE_SCALING_FACTOR 1000 |
mV are used for all TX power voltage values.
|
|
#define | RAIL_TX_POWER_DBM_SCALING_FACTOR 10 |
deci-dBm are used for all TX power dBm values.
|
Typedefs |
|
typedef int16_t | RAIL_TxPower_t |
The transmit power in deci-dBm units (e.g., 4.5 dBm -> 45 deci-dBm).
|
Functions |
|
RAIL_Status_t | RAIL_ConfigTxPower ( RAIL_Handle_t railHandle, const RAIL_TxPowerConfig_t *config) |
Initializes TxPower Settings.
|
|
RAIL_Status_t | RAIL_GetTxPowerConfig ( RAIL_Handle_t railHandle, RAIL_TxPowerConfig_t *config) |
Gets the TX power settings currently used in the amplifier.
|
|
RAIL_Status_t | RAIL_SetTxPower ( RAIL_Handle_t railHandle, RAIL_TxPowerLevel_t powerLevel) |
Sets the TX power in units of raw units (see
rail_chip_specific.h
for value ranges).
|
|
RAIL_TxPowerLevel_t | RAIL_GetTxPower ( RAIL_Handle_t railHandle) |
Returns the current power setting of the PA.
|
|
RAIL_TxPower_t | RAIL_ConvertRawToDbm ( RAIL_Handle_t railHandle, RAIL_TxPowerMode_t mode, RAIL_TxPowerLevel_t powerLevel) |
Converts raw values written to registers to decibel value (in units of deci-dBm).
|
|
RAIL_TxPowerLevel_t | RAIL_ConvertDbmToRaw ( RAIL_Handle_t railHandle, RAIL_TxPowerMode_t mode, RAIL_TxPower_t power) |
Converts the desired decibel value (in units of deci-dBm) to raw integer values used by the TX amplifier registers.
|
|
void | RAIL_VerifyTxPowerCurves (const struct RAIL_TxPowerCurvesConfigAlt *config) |
Verifies the TX Power Curves on modules.
|
|
RAIL_Status_t | RAIL_SetTxPowerDbm ( RAIL_Handle_t railHandle, RAIL_TxPower_t power) |
Sets the TX power in terms of deci-dBm instead of raw power level.
|
|
RAIL_TxPower_t | RAIL_GetTxPowerDbm ( RAIL_Handle_t railHandle) |
Gets the TX power in terms of deci-dBm instead of raw power level.
|
Detailed Description
APIs for interacting with one of the on chip PAs.
These APIs let you configure the on-chip PA to get the appropriate output power.
These are the function types: 1) Configuration functions: These functions set and get configuration for the PA. In this case, "configuration" refers to a) indicating which PA to use, b) the voltage supplied by your board to the PA, and c) the ramp time over which to ramp the PA up to its full power. 2) Power-setting functions: These functions consume the actual values written to the PA registers and write them appropriately. These values are referred to as "(raw) power levels". The range of acceptable values for these functions depends on which PA is currently active. The higher the power level set, the higher the dBm power output by the chip. However, the mapping between dBm and these power levels can vary greatly between modules/boards. 3) Conversion functions: These functions convert between the "power levels" discussed previously and the dBm values output by the chip. Continue reading for more information about unit conversion.
The accuracy of the chip output power is application-specific. For some protocols or channels, the protocol itself or legal limitations require applications to know exactly what power they're transmitting at, in dBm. Other applications do not have these restrictions, and users determine power level(s) that fit their criteria for the trade-off between radio range and power savings, regardless of what dBm power that maps to.
RAIL_ConvertRawToDbm and RAIL_ConvertDbmToRaw , which convert between the dBm power and the raw power levels, provide a solution that fits all these applications. The levels of customizability are outlined below: 1) No customizability needed: for a given dBm value, the result of RAIL_ConvertDbmToRaw provides an appropriate raw power level that, when written to the registers via RAIL_SetPowerLevel, causes the chip to output at that dBm power. In this case, no action is needed by the user, the WEAK versions of the conversion functions can be used and the default include paths in pa_conversions_efr32.h can be used. 2) The mapping of power level to dBm is not good, but the level of precision is sufficient: In pa_conversions_efr32.c, the WEAK versions of the conversion functions work by using 8-segment piecewise linear curves to convert between dBm and power levels for PA's with hundreds of power levels and simple mapping tables for use with PA's with only a few levels. If this method is sufficiently precise, but the mapping between power levels and dBm is incorrect, copy pa_curves_efr32.h into a new file, updating the segments to form a better fit (_DCDC_CURVES or _VBAT_CURVES defines) and then add the RAIL_PA_CURVES define to your build with the path to the new file. 3) A different level of precision is needed and the fit is bad: If the piecewise-linear line segment fit is not appropriate for your solution, the functions in pa_conversions_efr32.c can be totally rewritten, as long as RAIL_ConvertDbmToRaw and RAIL_ConvertRawToDbm have the same signatures. It is completely acceptable to re-write these in a way that makes the pa_curves_efr32.h and pa_curve_types_efr32.h files referenced in pa_conversions_efr32.h unnecessary. Those files are needed solely for the provided conversion methods. 4) dBm values are not necessary: If the application does not require dBm values at all, overwrite RAIL_ConvertDbmToRaw and RAIL_ConvertRawToDbm with smaller functions (i.e., return 0 or whatever was input). These functions are called from within the RAIL library, so they can never be deadstripped, but making them as small as possible is the best way to reduce code size. From there, call RAIL_SetTxPower, without converting from a dBm value. If you never want the library to coerce the power based on channels, RAIL_ConvertRawToDbm should be overwritten to always return 0 and RAIL_ConvertDbmToRaw should be overwritten to always return 255.
The following is example code that shows how to initialize your PA
- Note
- : All lines following "RAIL_TxPower_t power = 100;" can be replaced with the provided utility function, RAIL_SetTxPowerDbm . However, the full example here was provided for clarity. See the documentation on RAIL_SetTxPowerDbm for more details.
Macro Definition Documentation
#define RAIL_TX_POWER_DBM_SCALING_FACTOR 10 |
deci-dBm are used for all TX power dBm values.
All dBm inputs to TX power functions take dBm power times this factor.
Definition at line
990
of file
rail_types.h
.
#define RAIL_TX_POWER_MAX (( RAIL_TxPower_t )0x7FFF) |
The maximum valid value for a RAIL_TxPower_t .
Definition at line
980
of file
rail_types.h
.
#define RAIL_TX_POWER_MIN (( RAIL_TxPower_t )0x8000) |
The minimum valid value for a RAIL_TxPower_t .
Definition at line
982
of file
rail_types.h
.
#define RAIL_TX_POWER_VOLTAGE_SCALING_FACTOR 1000 |
mV are used for all TX power voltage values.
TX power voltages take and return voltages multiplied by this factor.
Definition at line
986
of file
rail_types.h
.
Typedef Documentation
typedef int16_t RAIL_TxPower_t |
The transmit power in deci-dBm units (e.g., 4.5 dBm -> 45 deci-dBm).
These values are used by the conversion functions to convert a RAIL_TxPowerLevel_t to deci-dBm for the application consumption. On EFR32, they can range from RAIL_TX_POWER_MIN to RAIL_TX_POWER_MAX .
Definition at line
978
of file
rail_types.h
.
Function Documentation
RAIL_Status_t RAIL_ConfigTxPower | ( | RAIL_Handle_t |
railHandle,
|
const RAIL_TxPowerConfig_t * |
config
|
||
) |
Initializes TxPower Settings.
- Parameters
-
[in] railHandle
A RAIL instance handle. [in] config
An instance which contains desired initial settings for the TX amplifier.
- Returns
- RAIL_Status_t indicating success or an error.
These settings include the selection between the multiple TX amplifiers, voltage supplied to the TX power amplifier, and ramp times. This must be called before any transmit occurs, or RAIL_SetTxPower is called. While this function should always be called during initialization, it can also be called any time if these settings need to change to adapt to a different application/protocol. This API will also reset TX Power to its minimum value, so RAIL_SetTxPower must be called afterwards.
At times, certain combinations of configurations cannot be achieved. This API attempts to get as close as possible to the requested settings. The following "RAIL_Get..." API can be used to determine what values were set.
RAIL_TxPowerLevel_t RAIL_ConvertDbmToRaw | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPowerMode_t |
mode,
|
||
RAIL_TxPower_t |
power
|
||
) |
Converts the desired decibel value (in units of deci-dBm) to raw integer values used by the TX amplifier registers.
- Parameters
-
[in] railHandle
A RAIL instance handle. [in] mode
PA mode for which to do the conversion. [in] power
Desired dBm values in units of deci-dBm.
- Returns
- deci-dBm value converted to a raw integer value that can be used directly with RAIL_SetTxPower .
A weak version of this function is provided that is tuned to provide accurate values for our boards. For a custom board, the relationship between what is written to the TX amplifier and the actual output power should be characterized and implemented in an overriding version of RAIL_ConvertDbmToRaw . For minimum code size and best speed use only raw values with the TxPower API and override this function with a smaller function. In the weak version provided with the RAIL library, railHandle is only used to indicate to the user from where the function was called, so it is OK to use either a real protocol handle, or one of the chip-specific ones, such as RAIL_EFR32_HANDLE .
Although the definitions of this function may change, the signature must be as declared here.
- Note
- This function is called from within the RAIL library for comparison between channel limitations and current power. It will throw an assert if you haven't called RAIL_InitTxPowerCurves which initializes the mappings between raw power levels and actual dBm powers. To avoid the assert, ensure that the maxPower of all channel config entries is RAIL_TX_POWER_MAX or above, or override this function to always return 255.
RAIL_TxPower_t RAIL_ConvertRawToDbm | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPowerMode_t |
mode,
|
||
RAIL_TxPowerLevel_t |
powerLevel
|
||
) |
Converts raw values written to registers to decibel value (in units of deci-dBm).
- Parameters
-
[in] railHandle
A RAIL instance handle. [in] mode
PA mode for which to convert. [in] powerLevel
A raw amplifier register value to be converted to deci-dBm.
- Returns
- raw amplifier values converted to units of deci-dBm.
A weak version of this function is provided that is tuned to provide accurate values for our boards. For a custom board, the relationship between what is written to the TX amplifier and the actual output power should be re-characterized and implemented in an overriding version of RAIL_ConvertRawToDbm . For minimum code size and best speed, use only raw values with the TxPower API and override this function with a smaller function. In the weak version provided with the RAIL library, railHandle is only used to indicate to the user from where the function was called, so it is OK to use either a real protocol handle, or one of the chip-specific ones, such as RAIL_EFR32_HANDLE .
Although the definitions of this function may change, the signature must be as declared here.
RAIL_TxPowerLevel_t RAIL_GetTxPower | ( | RAIL_Handle_t |
railHandle
|
) |
Returns the current power setting of the PA.
- Parameters
-
[in] railHandle
A RAIL instance handle.
- Returns
- The chip-specific RAIL_TxPowerLevel_t value of the current transmit power.
This API returns the raw value that was set by RAIL_SetTxPower . A weak version of RAIL_ConvertRawToDbm that works with our boards to convert the raw values into actual output dBm values is provided. However, customers using a custom board need to re-characterize the relationship between raw and decibel values and rewrite the provided function.
Calling this function before configuring the PA (i.e., before a successful call to RAIL_ConfigTxPower ) will return an error (RAIL_TX_POWER_LEVEL_INVALID).
RAIL_Status_t RAIL_GetTxPowerConfig | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPowerConfig_t * |
config
|
||
) |
Gets the TX power settings currently used in the amplifier.
- Parameters
-
[in] railHandle
A RAIL instance handle. [out] config
A pointer to memory allocated to hold the current TxPower configuration structure. A NULL config will produce undefined behavior.
- Returns
- RAIL status variable indicating whether or not the get was successful.
Note that this API does not return the current TX power, which is separately managed by the RAIL_GetTxPower / RAIL_SetTxPower APIs. This API should be used to determine which values were set as a result of RAIL_ConfigTxPower .
RAIL_TxPower_t RAIL_GetTxPowerDbm | ( | RAIL_Handle_t |
railHandle
|
) |
Gets the TX power in terms of deci-dBm instead of raw power level.
- Parameters
-
[in] railHandle
A RAIL instance handle.
- Returns
- The current output power in deci-dBm.
This is a utility function for user convenience. Normally, to get TX power in dBm, the user would have to do the following:
This function wraps all those calls in a single function with power returned as the result.
RAIL_Status_t RAIL_SetTxPower | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPowerLevel_t |
powerLevel
|
||
) |
Sets the TX power in units of raw units (see
rail_chip_specific.h
for value ranges).
- Parameters
-
[in] railHandle
A RAIL instance handle. [in] powerLevel
Power in chip-specific RAIL_TxPowerLevel_t units.
- Returns
- RAIL_Status_t indicating success or an error.
To convert between decibels and the integer values that the registers take, call RAIL_ConvertDbmToRaw . A weak version of this function, which works well with our boards is provided. However, customers using a custom board need to characterize chip operation on that board and override the function to convert appropriately from the desired dB values to raw integer values.
Depending on the configuration used in RAIL_ConfigTxPower , not all power levels are achievable. This API will get as close as possible to the desired power without exceeding it, and calling RAIL_GetTxPower is the only way to know the exact value written.
Calling this function before configuring the PA (i.e., before a successful call to RAIL_ConfigTxPower ) will return an error.
RAIL_Status_t RAIL_SetTxPowerDbm | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPower_t |
power
|
||
) |
Sets the TX power in terms of deci-dBm instead of raw power level.
- Parameters
-
[in] railHandle
A RAIL instance handle. [in] power
A desired deci-dBm power to be set.
- Returns
- RAIL Status variable indicate whether setting the power was successful.
This is a utility function for user convenience. Normally, to set TX power in dBm, the user would have to do the following:
This function wraps all those calls in a single function with power passed in as a parameter.
void RAIL_VerifyTxPowerCurves | ( | const struct RAIL_TxPowerCurvesConfigAlt * |
config
|
) |
Verifies the TX Power Curves on modules.
- Parameters
-
[in] config
TX Power Curves to use on this module
This function only needs to be called when using a module, and has no effect otherwise. Transmit will not work before this function is called.