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_CURVE_DEFAULT_MAX (( RAIL_TxPower_t )200) |
The maximum power in deci-dBm the curve supports.
|
|
#define | RAIL_TX_POWER_CURVE_DEFAULT_INCREMENT (( RAIL_TxPower_t )40) |
The increment step in deci-dBm for calculating powerlevel.
|
|
#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) |
Initialize TxPower Settings.
|
|
RAIL_Status_t | RAIL_GetTxPowerConfig ( RAIL_Handle_t railHandle, RAIL_TxPowerConfig_t *config) |
Get the TX power settings currently used in the amplifier.
|
|
RAIL_Status_t | RAIL_SetTxPower ( RAIL_Handle_t railHandle, RAIL_TxPowerLevel_t powerLevel) |
Set 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) |
Return the current power setting of the PA.
|
|
RAIL_TxPower_t | RAIL_ConvertRawToDbm ( RAIL_Handle_t railHandle, RAIL_TxPowerMode_t mode, RAIL_TxPowerLevel_t powerLevel) |
Convert 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) |
Convert 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) |
Verify the TX Power Curves on modules.
|
|
RAIL_Status_t | RAIL_SetTxPowerDbm ( RAIL_Handle_t railHandle, RAIL_TxPower_t power) |
Set the TX power in terms of deci-dBm instead of raw power level.
|
|
RAIL_TxPower_t | RAIL_GetTxPowerDbm ( RAIL_Handle_t railHandle) |
Get the TX power in terms of deci-dBm instead of raw power level.
|
|
RAIL_Status_t | RAIL_EnablePaAutoMode ( RAIL_Handle_t railHandle, bool enable) |
Enable automatic switching between PAs internally to the RAIL library.
|
|
bool | RAIL_IsPaAutoModeEnabled ( RAIL_Handle_t railHandle) |
Query status of PA Auto Mode.
|
|
RAIL_Status_t | RAILCb_PaAutoModeDecision ( RAIL_Handle_t railHandle, RAIL_TxPower_t *power, RAIL_TxPowerMode_t *mode, const RAIL_ChannelConfigEntry_t *chCfgEntry) |
Callback that is used to decide which PA and power level should be used while in PA auto mode.
|
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 ideal, 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. To stop the library from coercing the power based on channels, overwrite RAIL_ConvertRawToDbm to always return 0 and overwrite RAIL_ConvertDbmToRaw 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
◆ RAIL_TX_POWER_DBM_SCALING_FACTOR
#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
1226
of file
rail_types.h
.
◆ RAIL_TX_POWER_MAX
#define RAIL_TX_POWER_MAX (( RAIL_TxPower_t )0x7FFF) |
The maximum valid value for a RAIL_TxPower_t .
Definition at line
1211
of file
rail_types.h
.
◆ RAIL_TX_POWER_MIN
#define RAIL_TX_POWER_MIN (( RAIL_TxPower_t )0x8000) |
The minimum valid value for a RAIL_TxPower_t .
Definition at line
1213
of file
rail_types.h
.
◆ RAIL_TX_POWER_VOLTAGE_SCALING_FACTOR
#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
1222
of file
rail_types.h
.
Typedef Documentation
◆ RAIL_TxPower_t
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
1208
of file
rail_types.h
.
Function Documentation
◆ RAIL_ConfigTxPower()
RAIL_Status_t RAIL_ConfigTxPower | ( | RAIL_Handle_t |
railHandle,
|
const RAIL_TxPowerConfig_t * |
config
|
||
) |
Initialize 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 RAIL_TX_POWER_LEVEL_INVALID , 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. A change in RAIL_TxPowerConfig_t::rampTime may affect the minimum timings that can be acheived in RAIL_StateTiming_t::idleToTx and RAIL_StateTiming_t::rxToTx . Call RAIL_SetStateTiming() again to check whether these times have changed.
◆ RAIL_ConvertDbmToRaw()
RAIL_TxPowerLevel_t RAIL_ConvertDbmToRaw | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPowerMode_t |
mode,
|
||
RAIL_TxPower_t |
power
|
||
) |
Convert 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 configuration entries is RAIL_TX_POWER_MAX or above, or override this function to always return 255.
◆ RAIL_ConvertRawToDbm()
RAIL_TxPower_t RAIL_ConvertRawToDbm | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPowerMode_t |
mode,
|
||
RAIL_TxPowerLevel_t |
powerLevel
|
||
) |
Convert 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_EnablePaAutoMode()
RAIL_Status_t RAIL_EnablePaAutoMode | ( | RAIL_Handle_t |
railHandle,
|
bool |
enable
|
||
) |
Enable automatic switching between PAs internally to the RAIL library.
While PA Automode is enabled, the PA will be chosen and set automatically whenever RAIL_SetTxPowerDbm is called, or whenever powers are coerced automatically, internally to the RAIL library during a channel change. While PA Auto Mode is enabled, users cannot call RAIL_ConfigTxPower or RAIL_SetTxPower . When entering auto mode, RAIL_SetTxPowerDbm must be called to specify the desired power. When leaving auto mode, RAIL_ConfigTxPower as well as one of RAIL_SetTxPower or RAIL_SetTxPowerDbm must be called to re-specify the desired PA and power level combination.
- Note
- : Power conversion curves must be initialized before calling this function. That is, RAIL_ConvertDbmToRaw and RAIL_ConvertRawToDbm most both be able to operate properly in order for PA Auto Mode to function correctly. See the PA Conversions plugin or AN1127 for more details on that.
- Parameters
-
[in] railHandle
A RAIL instance handle. [in] enable
Enable or disable PA Auto Mode.
- Returns
- Status parameter indicating success of function call.
◆ RAIL_GetTxPower()
RAIL_TxPowerLevel_t RAIL_GetTxPower | ( | RAIL_Handle_t |
railHandle
|
) |
Return 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_GetTxPowerConfig()
RAIL_Status_t RAIL_GetTxPowerConfig | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPowerConfig_t * |
config
|
||
) |
Get 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 configuration 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_GetTxPowerDbm()
RAIL_TxPower_t RAIL_GetTxPowerDbm | ( | RAIL_Handle_t |
railHandle
|
) |
Get 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_IsPaAutoModeEnabled()
bool RAIL_IsPaAutoModeEnabled | ( | RAIL_Handle_t |
railHandle
|
) |
Query status of PA Auto Mode.
- Parameters
-
[in] railHandle
A RAIL instance handle on which to query PA Auto Mode status.
- Returns
- Indicator of whether Auto Mode is enabled (true) or not (false).
◆ RAIL_SetTxPower()
RAIL_Status_t RAIL_SetTxPower | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPowerLevel_t |
powerLevel
|
||
) |
Set 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_SetTxPowerDbm()
RAIL_Status_t RAIL_SetTxPowerDbm | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPower_t |
power
|
||
) |
Set 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.
◆ RAIL_VerifyTxPowerCurves()
void RAIL_VerifyTxPowerCurves | ( | const struct RAIL_TxPowerCurvesConfigAlt * |
config
|
) |
Verify 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.
◆ RAILCb_PaAutoModeDecision()
RAIL_Status_t RAILCb_PaAutoModeDecision | ( | RAIL_Handle_t |
railHandle,
|
RAIL_TxPower_t * |
power,
|
||
RAIL_TxPowerMode_t * |
mode,
|
||
const RAIL_ChannelConfigEntry_t * |
chCfgEntry
|
||
) |
Callback that is used to decide which PA and power level should be used while in PA auto mode.
- Parameters
-
[in] railHandle
A RAIL instance handle. [in,out] power
Pointer to the dBm output power (in deci-dBm, 10*dBm) being requested. The value this points to when the function returns will be applied to the radio. [out] mode
Pointer to the RAIL_TxPowerMode_t to be used to achieve the requested power. The value this points to when the function returns will be applied to the radio. [in] chCfgEntry
Pointer to a RAIL_ChannelConfigEntry_t . While switching channels, it will be the entry RAIL is switch to , during a call to RAIL_SetTxPowerDbm , it will be the entry RAIL is already on . Can be NULL if a channel configuration was not set or no valid channels are present.
- Returns
- Return status indicating result of function call. If this is anything except RAIL_STATUS_NO_ERROR , neither PA's nor their powers will be configured automatically.
Whatever values mode and powerLevel point to when this function return will be applied to the PA hardware and used for transmits.