Skip to content

Commit 09c1b08

Browse files
ankunsrlubos
authored andcommitted
samples: dtm: pass radio_mode to fem_al API
The functions `fem_tx_output_power_prepare`, `fem_tx_output_power_check`, `fem_tx_output_power_min_get` and `fem_tx_output_power_max_get` require `radio_mode` parameter. This commit aligns direct_test_mode sample to this change. Signed-off-by: Andrzej Kuros <[email protected]>
1 parent 4b6d10d commit 09c1b08

File tree

1 file changed

+25
-18
lines changed
  • samples/bluetooth/direct_test_mode/src

1 file changed

+25
-18
lines changed

samples/bluetooth/direct_test_mode/src/dtm.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,20 +1047,21 @@ static nrf_radio_txpower_t dbm_to_nrf_radio_txpower(int8_t tx_power)
10471047
}
10481048

10491049
#if CONFIG_DTM_POWER_CONTROL_AUTOMATIC
1050-
static int8_t dtm_radio_min_power_get(uint16_t frequency)
1050+
static int8_t dtm_radio_min_power_get(nrf_radio_mode_t radio_mode, uint16_t frequency)
10511051
{
1052-
return fem_tx_output_power_min_get(frequency);
1052+
return fem_tx_output_power_min_get(radio_mode, frequency);
10531053
}
10541054

1055-
static int8_t dtm_radio_max_power_get(uint16_t frequency)
1055+
static int8_t dtm_radio_max_power_get(nrf_radio_mode_t radio_mode, uint16_t frequency)
10561056
{
1057-
return fem_tx_output_power_max_get(frequency);
1057+
return fem_tx_output_power_max_get(radio_mode, frequency);
10581058
}
10591059

1060-
static int8_t dtm_radio_nearest_power_get(int8_t tx_power, uint16_t frequency)
1060+
static int8_t dtm_radio_nearest_power_get(int8_t tx_power, nrf_radio_mode_t radio_mode,
1061+
uint16_t frequency)
10611062
{
1062-
int8_t tx_power_floor = fem_tx_output_power_check(tx_power, frequency, false);
1063-
int8_t tx_power_ceiling = fem_tx_output_power_check(tx_power, frequency, true);
1063+
int8_t tx_power_floor = fem_tx_output_power_check(tx_power, radio_mode, frequency, false);
1064+
int8_t tx_power_ceiling = fem_tx_output_power_check(tx_power, radio_mode, frequency, true);
10641065
int8_t output_power;
10651066

10661067
output_power = (abs(tx_power_floor - tx_power) > abs(tx_power_ceiling - tx_power)) ?
@@ -1070,26 +1071,30 @@ static int8_t dtm_radio_nearest_power_get(int8_t tx_power, uint16_t frequency)
10701071
}
10711072

10721073
#else
1073-
static int8_t dtm_radio_min_power_get(uint16_t frequency)
1074+
static int8_t dtm_radio_min_power_get(nrf_radio_mode_t radio_mode, uint16_t frequency)
10741075
{
1076+
ARG_UNUSED(radio_mode);
10751077
ARG_UNUSED(frequency);
10761078

10771079
return dtm_hw_radio_min_power_get();
10781080
}
10791081

1080-
static int8_t dtm_radio_max_power_get(uint16_t frequency)
1082+
static int8_t dtm_radio_max_power_get(nrf_radio_mode_t radio_mode, uint16_t frequency)
10811083
{
1084+
ARG_UNUSED(radio_mode);
10821085
ARG_UNUSED(frequency);
10831086

10841087
return dtm_hw_radio_max_power_get();
10851088
}
10861089

1087-
static int8_t dtm_radio_nearest_power_get(int8_t tx_power, uint16_t frequency)
1090+
static int8_t dtm_radio_nearest_power_get(int8_t tx_power, nrf_radio_mode_t radio_mode,
1091+
uint16_t frequency)
10881092
{
10891093
int8_t output_power = INT8_MAX;
10901094
const size_t size = dtm_hw_radio_power_array_size_get();
10911095
const int8_t *power = dtm_hw_radio_power_array_get();
10921096

1097+
ARG_UNUSED(radio_mode);
10931098
ARG_UNUSED(frequency);
10941099

10951100
for (size_t i = 1; i < size; i++) {
@@ -1122,7 +1127,7 @@ static uint16_t radio_frequency_get(uint8_t channel)
11221127
return (channel << 1) + base_frequency;
11231128
}
11241129

1125-
static void radio_tx_power_set(uint8_t channel, int8_t tx_power)
1130+
static void radio_tx_power_set(uint8_t channel, int8_t tx_power, nrf_radio_mode_t radio_mode)
11261131
{
11271132
int8_t radio_power = tx_power;
11281133

@@ -1137,11 +1142,12 @@ static void radio_tx_power_set(uint8_t channel, int8_t tx_power)
11371142
* Tx output power level for channel 0. That is why output Tx power needs to be
11381143
* aligned for final transmission channel.
11391144
*/
1140-
tx_power = dtm_radio_nearest_power_get(tx_power, frequency);
1141-
(void)fem_tx_output_power_prepare(tx_power, &radio_power, frequency);
1145+
tx_power = dtm_radio_nearest_power_get(tx_power, radio_mode, frequency);
1146+
(void)fem_tx_output_power_prepare(tx_power, &radio_power, radio_mode, frequency);
11421147
}
11431148
#else
11441149
ARG_UNUSED(channel);
1150+
ARG_UNUSED(radio_mode);
11451151
#endif /* CONFIG_FEM */
11461152

11471153
#ifdef NRF53_SERIES
@@ -1195,7 +1201,7 @@ static int radio_init(void)
11951201
/* Turn off radio before configuring it */
11961202
radio_reset();
11971203

1198-
radio_tx_power_set(dtm_inst.phys_ch, dtm_inst.txpower);
1204+
radio_tx_power_set(dtm_inst.phys_ch, dtm_inst.txpower, dtm_inst.radio_mode);
11991205
nrf_radio_mode_set(NRF_RADIO, dtm_inst.radio_mode);
12001206
nrf_radio_fast_ramp_up_enable_set(NRF_RADIO, IS_ENABLED(CONFIG_DTM_FAST_RAMP_UP));
12011207

@@ -1821,7 +1827,7 @@ static void radio_prepare(bool rx)
18211827

18221828
radio_start(rx, false);
18231829
} else { /* tx */
1824-
radio_tx_power_set(dtm_inst.phys_ch, dtm_inst.txpower);
1830+
radio_tx_power_set(dtm_inst.phys_ch, dtm_inst.txpower, dtm_inst.radio_mode);
18251831

18261832
#if NRF52_ERRATA_172_PRESENT
18271833
/* Stop the timer used by anomaly 172 */
@@ -2306,8 +2312,8 @@ struct dtm_tx_power dtm_setup_set_transmit_power(enum dtm_tx_power_request power
23062312
uint8_t channel)
23072313
{
23082314
uint16_t frequency = radio_frequency_get(channel);
2309-
const int8_t tx_power_min = dtm_radio_min_power_get(frequency);
2310-
const int8_t tx_power_max = dtm_radio_max_power_get(frequency);
2315+
const int8_t tx_power_min = dtm_radio_min_power_get(dtm_inst.radio_mode, frequency);
2316+
const int8_t tx_power_max = dtm_radio_max_power_get(dtm_inst.radio_mode, frequency);
23112317
struct dtm_tx_power tmp = {
23122318
.power = 0,
23132319
.min = false,
@@ -2329,7 +2335,8 @@ struct dtm_tx_power dtm_setup_set_transmit_power(enum dtm_tx_power_request power
23292335
} else if (val >= tx_power_max) {
23302336
dtm_inst.txpower = tx_power_max;
23312337
} else {
2332-
dtm_inst.txpower = dtm_radio_nearest_power_get(val, frequency);
2338+
dtm_inst.txpower = dtm_radio_nearest_power_get(val, dtm_inst.radio_mode,
2339+
frequency);
23332340
}
23342341

23352342
break;

0 commit comments

Comments
 (0)