Skip to content

Commit f07d49e

Browse files
ankunsrlubos
authored andcommitted
libs: fem_al: align to mpsl_fem_tx_power_split with phy
In the MPSL the `mpsl_fem_tx_power_split` function will change soon. It will have the `phy` parameter. To smoothly transition through the change in public API for FEM the new MPSL version will define a macro `_MPSL_FEM_TX_POWER_SPLIT_HAS_PHY`. This commit aligns the fem_al lib to the new MPSL API. For short transitional period both APIs are supprted. The `fem_tx_output_power_prepare` and `fem_tx_output_power_check` now require an additional parameter `radio_mode`. Signed-off-by: Andrzej Kuros <[email protected]>
1 parent da8f299 commit f07d49e

File tree

2 files changed

+75
-10
lines changed

2 files changed

+75
-10
lines changed

include/fem_al/fem_al.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ uint32_t fem_radio_rx_ramp_up_delay_get(bool fast, nrf_radio_mode_t mode);
163163
*
164164
* @param[in] power TX power requested for transmission on air.
165165
* @param[out] radio_tx_power Tx power value to be set on the radio peripheral.
166+
* @param[in] radio_mode The mode of the RADIO.
166167
* @param[in] freq_mhz Frequency in MHz. The output power is valid only for this frequency.
167168
*
168169
* @return The power in dBm that is achieved as device output power. It can be different from
169170
* the value requested by @p power.
170171
*/
171-
int8_t fem_tx_output_power_prepare(int8_t power, int8_t *radio_tx_power, uint16_t freq_mhz);
172+
int8_t fem_tx_output_power_prepare(int8_t power, int8_t *radio_tx_power,
173+
nrf_radio_mode_t radio_mode, uint16_t freq_mhz);
172174

173175
/**@brief Check a real Tx output power, for the SoC with the front-end module for given parameters.
174176
*
@@ -177,6 +179,7 @@ int8_t fem_tx_output_power_prepare(int8_t power, int8_t *radio_tx_power, uint16_
177179
* requested output power.
178180
*
179181
* @param[in] power Tx power level to check.
182+
* @param[in] radio_mode The mode of the RADIO.
180183
* @param[in] freq_mhz Frequency in MHz. The output power check is valid only for this frequency.
181184
* @param[in] tx_power_ceiling Flag to get the ceiling or floor of the requested transmit power
182185
* level.
@@ -185,30 +188,33 @@ int8_t fem_tx_output_power_prepare(int8_t power, int8_t *radio_tx_power, uint16_
185188
* be different than @p power and depending on @p tx_power_ceiling it can be greater or
186189
* lower than the requested one.
187190
*/
188-
int8_t fem_tx_output_power_check(int8_t power, uint16_t freq_mhz, bool tx_power_ceiling);
191+
int8_t fem_tx_output_power_check(int8_t power, nrf_radio_mode_t radio_mode, uint16_t freq_mhz,
192+
bool tx_power_ceiling);
189193

190194
/**@brief Get the minimum Tx output power for the SoC with the front-end module.
191195
*
196+
* @param[in] radio_mode The mode of the RADIO.
192197
* @param[in] freq_mhz Frequency in MHz. The minimum output power is valid only for this frequency.
193198
*
194199
* @return The minimum output power in dBm.
195200
*/
196-
static inline int8_t fem_tx_output_power_min_get(uint16_t freq_mhz)
201+
static inline int8_t fem_tx_output_power_min_get(nrf_radio_mode_t radio_mode, uint16_t freq_mhz)
197202
{
198203
/* Using INT8_MIN returns the minimum supported Tx output power value. */
199-
return fem_tx_output_power_check(INT8_MIN, freq_mhz, false);
204+
return fem_tx_output_power_check(INT8_MIN, radio_mode, freq_mhz, false);
200205
}
201206

202207
/**@brief Get the maximum Tx output power for the SoC with the front-end module.
203208
*
209+
* @param[in] radio_mode The mode of the RADIO.
204210
* @param[in] freq_mhz Frequency in MHz. The maximum output power is valid only for this frequency.
205211
*
206212
* @return The maximum output power in dBm.
207213
*/
208-
static inline int8_t fem_tx_output_power_max_get(uint16_t freq_mhz)
214+
static inline int8_t fem_tx_output_power_max_get(nrf_radio_mode_t radio_mode, uint16_t freq_mhz)
209215
{
210216
/* Using INT8_MAX returns the maximum supported Tx output power value. */
211-
return fem_tx_output_power_check(INT8_MAX, freq_mhz, true);
217+
return fem_tx_output_power_check(INT8_MAX, radio_mode, freq_mhz, true);
212218
}
213219

214220
/**@brief Get the front-end module default Tx output power.

lib/fem_al/fem_al.c

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,62 @@ void fem_txrx_stop(void)
279279
mpsl_fem_deactivate_now(MPSL_FEM_ALL);
280280
}
281281

282-
int8_t fem_tx_output_power_prepare(int8_t power, int8_t *radio_tx_power, uint16_t freq_mhz)
282+
#if defined(_MPSL_FEM_TX_POWER_SPLIT_HAS_PHY)
283+
static mpsl_phy_t convert_radio_mode_to_mpsl_phy(nrf_radio_mode_t radio_mode)
284+
{
285+
switch (radio_mode) {
286+
case NRF_RADIO_MODE_NRF_1MBIT: return MPSL_PHY_BLE_1M;
287+
case NRF_RADIO_MODE_NRF_2MBIT: return MPSL_PHY_BLE_2M;
288+
#if defined(RADIO_MODE_MODE_Nrf_250Kbit)
289+
case NRF_RADIO_MODE_NRF_250KBIT: return MPSL_PHY_NRF_250Kbit;
290+
#endif
291+
#if defined(RADIO_MODE_MODE_Nrf_4Mbit0_5)
292+
case NRF_RADIO_MODE_NRF_4MBIT_H_0_5: return MPSL_PHY_NRF_4Mbit0_5;
293+
#endif
294+
#if defined(RADIO_MODE_MODE_Nrf_4Mbit0_25)
295+
case NRF_RADIO_MODE_NRF_4MBIT_H_0_25: return MPSL_PHY_NRF_4Mbit0_25;
296+
#endif
297+
#if defined(RADIO_MODE_MODE_Nrf_4Mbit_0BT6)
298+
case NRF_RADIO_MODE_NRF_4MBIT_BT_0_6: return MPSL_PHY_NRF_4Mbit_0BT6;
299+
#endif
300+
#if defined(RADIO_MODE_MODE_Nrf_4Mbit_0BT4)
301+
case NRF_RADIO_MODE_NRF_4MBIT_BT_0_4: return MPSL_PHY_NRF_4Mbit_0BT4;
302+
#endif
303+
case NRF_RADIO_MODE_BLE_1MBIT: return MPSL_PHY_BLE_1M;
304+
#if defined(RADIO_MODE_MODE_Ble_2Mbit)
305+
case NRF_RADIO_MODE_BLE_2MBIT: return MPSL_PHY_BLE_2M;
306+
#endif
307+
#if defined(RADIO_MODE_MODE_Ble_LR125Kbit)
308+
case NRF_RADIO_MODE_BLE_LR125KBIT: return MPSL_PHY_BLE_LR125Kbit;
309+
#endif
310+
#if defined(RADIO_MODE_MODE_Ble_LR500Kbit)
311+
case NRF_RADIO_MODE_BLE_LR500KBIT: return MPSL_PHY_BLE_LR500Kbit;
312+
#endif
313+
#if defined(RADIO_MODE_MODE_Ieee802154_250Kbit)
314+
case NRF_RADIO_MODE_IEEE802154_250KBIT: return MPSL_PHY_Ieee802154_250Kbit;
315+
#endif
316+
default: return MPSL_PHY_BLE_1M;
317+
}
318+
}
319+
#endif
320+
321+
int8_t fem_tx_output_power_prepare(int8_t power, int8_t *radio_tx_power,
322+
nrf_radio_mode_t radio_mode, uint16_t freq_mhz)
283323
{
284324
int8_t output_power;
285325
int32_t err;
286326
mpsl_tx_power_split_t power_split = { 0 };
327+
#if defined(_MPSL_FEM_TX_POWER_SPLIT_HAS_PHY)
328+
mpsl_phy_t mpsl_phy = convert_radio_mode_to_mpsl_phy(radio_mode);
329+
#else
330+
(void)radio_mode;
331+
#endif
287332

288-
output_power = mpsl_fem_tx_power_split(power, &power_split, freq_mhz, false);
333+
output_power = mpsl_fem_tx_power_split(power, &power_split,
334+
#if defined(_MPSL_FEM_TX_POWER_SPLIT_HAS_PHY)
335+
mpsl_phy,
336+
#endif
337+
freq_mhz, false);
289338

290339
*radio_tx_power = power_split.radio_tx_power;
291340

@@ -299,11 +348,21 @@ int8_t fem_tx_output_power_prepare(int8_t power, int8_t *radio_tx_power, uint16_
299348
return output_power;
300349
}
301350

302-
int8_t fem_tx_output_power_check(int8_t power, uint16_t freq_mhz, bool tx_power_ceiling)
351+
int8_t fem_tx_output_power_check(int8_t power, nrf_radio_mode_t radio_mode, uint16_t freq_mhz,
352+
bool tx_power_ceiling)
303353
{
354+
#if defined(_MPSL_FEM_TX_POWER_SPLIT_HAS_PHY)
355+
mpsl_phy_t mpsl_phy = convert_radio_mode_to_mpsl_phy(radio_mode);
356+
#else
357+
(void)radio_mode;
358+
#endif
304359
mpsl_tx_power_split_t power_split = { 0 };
305360

306-
return mpsl_fem_tx_power_split(power, &power_split, freq_mhz, tx_power_ceiling);
361+
return mpsl_fem_tx_power_split(power, &power_split,
362+
#if defined(_MPSL_FEM_TX_POWER_SPLIT_HAS_PHY)
363+
mpsl_phy,
364+
#endif
365+
freq_mhz, tx_power_ceiling);
307366
}
308367

309368
int8_t fem_default_tx_output_power_get(void)

0 commit comments

Comments
 (0)