Skip to content

Commit ff39d5a

Browse files
Szynkaarlubos
authored andcommitted
esb: rework radio shorts
Simplify common radio shorts to not depend on fast switching configuration. Rename alias for short between END/PHYEND and DISABLE. Signed-off-by: Szymon Antkowiak <[email protected]>
1 parent 1ed975b commit ff39d5a

File tree

2 files changed

+42
-52
lines changed

2 files changed

+42
-52
lines changed

subsys/esb/esb.c

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,16 @@ LOG_MODULE_REGISTER(esb, CONFIG_ESB_LOG_LEVEL);
8181
/* NRF5340 Radio high voltage gain. */
8282
#define NRF5340_HIGH_VOLTAGE_GAIN 3
8383

84-
/* Fast switching is available for the nRF54H20 SoC.
85-
* The nRF54H20 is a non-RSSISTOP device.
86-
*/
8784
#if defined(RADIO_SHORTS_DISABLED_RSSISTOP_Msk)
88-
#define RADIO_SHORTS_COMMON \
89-
(NRF_RADIO_SHORT_READY_START_MASK | ESB_SHORT_DISABLE_MASK | \
90-
NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK | NRF_RADIO_SHORT_DISABLED_RSSISTOP_MASK)
85+
#define RADIO_RSSI_SHORTS \
86+
(NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK | NRF_RADIO_SHORT_DISABLED_RSSISTOP_MASK)
9187
#else
9288
/* Devices without RSSISTOP task will stop RSSI measurement after specific period. */
93-
#define RADIO_SHORTS_FAST_SWITCHING_NO_RSSISTOP (NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK)
94-
#define RADIO_SHORTS_NO_FAST_SWITCHING_NO_RSSISTOP \
95-
(NRF_RADIO_SHORT_READY_START_MASK | ESB_SHORT_DISABLE_MASK | \
96-
NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK)
89+
#define RADIO_RSSI_SHORTS (NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK)
90+
#endif /* !defined(RADIO_SHORTS_DISABLED_RSSISTOP_Msk) */
9791

98-
#define RADIO_SHORTS_COMMON \
99-
(IS_ENABLED(CONFIG_ESB_FAST_SWITCHING) ? RADIO_SHORTS_FAST_SWITCHING_NO_RSSISTOP : \
100-
RADIO_SHORTS_NO_FAST_SWITCHING_NO_RSSISTOP)
101-
#endif /* !defined(RADIO_SHORTS_DISABLED_RSSISTOP_Msk) */
92+
#define RADIO_NORMAL_SW_SHORTS \
93+
(RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_READY_START_MASK | ESB_RADIO_SHORT_END_DISABLE)
10294

10395
#if defined(CONFIG_SOC_SERIES_NRF54LX)
10496
#define RADIO_SHORTS_MONITOR \
@@ -296,7 +288,6 @@ static volatile uint32_t retransmits_remaining;
296288
static volatile uint32_t last_tx_attempts;
297289
static volatile uint32_t wait_for_ack_timeout_us;
298290

299-
static uint32_t radio_shorts_common = RADIO_SHORTS_COMMON;
300291
static const bool fast_switching = IS_ENABLED(CONFIG_ESB_FAST_SWITCHING);
301292

302293
static const mpsl_fem_event_t rx_event = {
@@ -1189,13 +1180,13 @@ static void start_tx_transaction(void)
11891180
memcpy(pdu->data, current_payload->data, current_payload->length);
11901181

11911182
if (fast_switching) {
1192-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1183+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_RSSI_SHORTS |
11931184
NRF_RADIO_SHORT_TXREADY_START_MASK));
11941185
nrf_radio_event_clear(NRF_RADIO, ESB_RADIO_EVENT_END);
11951186
nrf_radio_int_enable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
11961187
} else {
1197-
nrf_radio_shorts_set(NRF_RADIO,
1198-
(radio_shorts_common | NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
1188+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_NORMAL_SW_SHORTS |
1189+
NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
11991190
}
12001191
nrf_radio_int_enable(NRF_RADIO, NRF_RADIO_INT_DISABLED_MASK);
12011192

@@ -1218,13 +1209,15 @@ static void start_tx_transaction(void)
12181209
/* Handling ack if noack is set to false or if selective auto ack is turned off */
12191210
if (ack) {
12201211
if (fast_switching) {
1221-
nrf_radio_shorts_set(NRF_RADIO,
1222-
(radio_shorts_common | NRF_RADIO_SHORT_TXREADY_START_MASK));
1212+
nrf_radio_shorts_set(
1213+
NRF_RADIO,
1214+
(RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_TXREADY_START_MASK));
12231215
nrf_radio_event_clear(NRF_RADIO, ESB_RADIO_EVENT_END);
12241216
nrf_radio_int_enable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
12251217
} else {
12261218
nrf_radio_shorts_set(NRF_RADIO,
1227-
(radio_shorts_common | NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
1219+
(RADIO_NORMAL_SW_SHORTS |
1220+
NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
12281221
}
12291222

12301223
/* Configure the retransmit counter */
@@ -1233,8 +1226,8 @@ static void start_tx_transaction(void)
12331226
esb_state = ESB_STATE_PTX_TX_ACK;
12341227
nrf_radio_int_enable(NRF_RADIO, NRF_RADIO_INT_DISABLED_MASK);
12351228
} else if (IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX)) {
1236-
nrf_radio_shorts_set(NRF_RADIO, radio_shorts_common &
1237-
~ESB_SHORT_DISABLE_MASK);
1229+
nrf_radio_shorts_set(
1230+
NRF_RADIO, (RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_READY_START_MASK));
12381231
nrf_timer_shorts_set(esb_timer.p_reg,
12391232
(NRF_TIMER_SHORT_COMPARE1_STOP_MASK |
12401233
NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK));
@@ -1253,9 +1246,7 @@ static void start_tx_transaction(void)
12531246
(esb_state == ESB_STATE_PTX_TX));
12541247
esb_state = ESB_STATE_PTX_TX;
12551248
} else {
1256-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1257-
NRF_RADIO_SHORT_READY_START_MASK |
1258-
ESB_SHORT_DISABLE_MASK));
1249+
nrf_radio_shorts_set(NRF_RADIO, RADIO_NORMAL_SW_SHORTS);
12591250

12601251
on_radio_disabled = on_radio_disabled_tx_noack;
12611252
esb_state = ESB_STATE_PTX_TX;
@@ -1352,7 +1343,7 @@ static void on_radio_disabled_tx(void)
13521343
/* Remove the DISABLED -> RXEN shortcut, to make sure the radio stays
13531344
* disabled after the RX window
13541345
*/
1355-
nrf_radio_shorts_set(NRF_RADIO, radio_shorts_common);
1346+
nrf_radio_shorts_set(NRF_RADIO, RADIO_NORMAL_SW_SHORTS);
13561347

13571348
/* Make sure the timer is started the next time the radio is ready,
13581349
* and that it will disable the radio automatically if no packet is
@@ -1394,8 +1385,6 @@ static void on_radio_disabled_tx(void)
13941385
nrf_radio_packetptr_set(NRF_RADIO, rx_payload_buffer);
13951386
if (fast_switching) {
13961387
nrf_radio_int_disable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
1397-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common | ESB_SHORT_DISABLE_MASK |
1398-
NRF_RADIO_SHORT_RXREADY_START_MASK));
13991388
nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_START);
14001389
}
14011390
on_radio_disabled = on_radio_disabled_tx_wait_for_ack;
@@ -1431,10 +1420,6 @@ static void on_radio_disabled_tx_wait_for_ack(void)
14311420
}
14321421
}
14331422

1434-
if (fast_switching) {
1435-
nrf_radio_shorts_set(NRF_RADIO, radio_shorts_common);
1436-
}
1437-
14381423
if ((atomic_get(&tx_fifo.count) == 0) || (esb_cfg.tx_mode == ESB_TXMODE_MANUAL)) {
14391424
esb_state = ESB_STATE_IDLE;
14401425
errata_216_off();
@@ -1467,13 +1452,13 @@ static void on_radio_disabled_tx_wait_for_ack(void)
14671452
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_READY);
14681453

14691454
if (fast_switching) {
1470-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1455+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_RSSI_SHORTS |
14711456
NRF_RADIO_SHORT_TXREADY_START_MASK));
14721457
nrf_radio_event_clear(NRF_RADIO, ESB_RADIO_EVENT_END);
14731458
nrf_radio_int_enable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
14741459
} else {
1475-
nrf_radio_shorts_set(NRF_RADIO,
1476-
(radio_shorts_common | NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
1460+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_NORMAL_SW_SHORTS |
1461+
NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
14771462
}
14781463

14791464
if (esb_cfg.protocol == ESB_PROTOCOL_ESB) {
@@ -1538,12 +1523,12 @@ static void start_rx_listening(void)
15381523
on_radio_disabled = NULL;
15391524
} else {
15401525
if (fast_switching) {
1541-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1542-
NRF_RADIO_SHORT_READY_START_MASK));
1526+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_RSSI_SHORTS |
1527+
NRF_RADIO_SHORT_RXREADY_START_MASK));
15431528
nrf_radio_event_clear(NRF_RADIO, ESB_RADIO_EVENT_END);
15441529
nrf_radio_int_enable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
15451530
} else {
1546-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1531+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_NORMAL_SW_SHORTS |
15471532
NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
15481533
}
15491534

@@ -1576,7 +1561,7 @@ static void clear_events_restart_rx(void)
15761561
esb_fem_lna_reset();
15771562
esb_ppi_for_txrx_clear(true, false);
15781563

1579-
nrf_radio_shorts_set(NRF_RADIO, radio_shorts_common);
1564+
nrf_radio_shorts_set(NRF_RADIO, 0);
15801565

15811566
if (esb_cfg.protocol == ESB_PROTOCOL_ESB) {
15821567
update_rf_payload_format_esb(0);
@@ -1593,8 +1578,13 @@ static void clear_events_restart_rx(void)
15931578

15941579
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
15951580

1596-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common | NRF_RADIO_SHORT_READY_START_MASK |
1597-
NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
1581+
if (fast_switching) {
1582+
nrf_radio_shorts_set(NRF_RADIO,
1583+
(RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_RXREADY_START_MASK));
1584+
} else {
1585+
nrf_radio_shorts_set(NRF_RADIO,
1586+
(RADIO_NORMAL_SW_SHORTS | NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
1587+
}
15981588

15991589
esb_ppi_for_txrx_set(true, false);
16001590
esb_fem_for_rx_set();
@@ -1702,12 +1692,12 @@ static void on_radio_disabled_rx(void)
17021692
nrf_radio_packetptr_set(NRF_RADIO, tx_pdu);
17031693

17041694
if (fast_switching) {
1705-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1706-
NRF_RADIO_SHORT_READY_START_MASK));
1695+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_RSSI_SHORTS |
1696+
NRF_RADIO_SHORT_TXREADY_START_MASK));
17071697
nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_TXEN);
17081698
} else {
1709-
nrf_radio_shorts_set(NRF_RADIO,
1710-
(radio_shorts_common | NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
1699+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_NORMAL_SW_SHORTS |
1700+
NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
17111701
}
17121702

17131703
on_radio_disabled = on_radio_disabled_rx_send_ack;
@@ -1738,11 +1728,11 @@ static void on_radio_disabled_rx_send_ack(void)
17381728
nrf_radio_packetptr_set(NRF_RADIO, rx_payload_buffer);
17391729
if (fast_switching) {
17401730
nrf_radio_shorts_set(NRF_RADIO,
1741-
(radio_shorts_common | NRF_RADIO_SHORT_READY_START_MASK));
1731+
(RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_RXREADY_START_MASK));
17421732
nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_RXEN);
17431733
} else {
1744-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1745-
NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
1734+
nrf_radio_shorts_set(NRF_RADIO,
1735+
(RADIO_NORMAL_SW_SHORTS | NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
17461736
}
17471737
on_radio_disabled = on_radio_disabled_rx;
17481738

subsys/esb/esb_peripherals.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C" {
3434

3535
/** Use end of packet send/received over the air for nRF54 devices. */
3636
#define ESB_RADIO_EVENT_END NRF_RADIO_EVENT_PHYEND
37-
#define ESB_SHORT_DISABLE_MASK NRF_RADIO_SHORT_PHYEND_DISABLE_MASK
37+
#define ESB_RADIO_SHORT_END_DISABLE NRF_RADIO_SHORT_PHYEND_DISABLE_MASK
3838

3939
#define ESB_RADIO_INT_END_MASK NRF_RADIO_INT_PHYEND_MASK
4040

@@ -55,7 +55,7 @@ extern "C" {
5555

5656
/** Use end of packet send/received over the air for nRF54 devices. */
5757
#define ESB_RADIO_EVENT_END NRF_RADIO_EVENT_PHYEND
58-
#define ESB_SHORT_DISABLE_MASK NRF_RADIO_SHORT_PHYEND_DISABLE_MASK
58+
#define ESB_RADIO_SHORT_END_DISABLE NRF_RADIO_SHORT_PHYEND_DISABLE_MASK
5959

6060
#define ESB_RADIO_INT_END_MASK NRF_RADIO_INT_PHYEND_MASK
6161
#else
@@ -71,7 +71,7 @@ extern "C" {
7171

7272
/** nRF52 and nRF53 device has just one kind of end event. */
7373
#define ESB_RADIO_EVENT_END NRF_RADIO_EVENT_END
74-
#define ESB_SHORT_DISABLE_MASK NRF_RADIO_SHORT_END_DISABLE_MASK
74+
#define ESB_RADIO_SHORT_END_DISABLE NRF_RADIO_SHORT_END_DISABLE_MASK
7575

7676
#define ESB_RADIO_INT_END_MASK NRF_RADIO_INT_END_MASK
7777

0 commit comments

Comments
 (0)