Skip to content

Commit 08d1e6f

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]> (cherry picked from commit ff39d5a)
1 parent 79315a8 commit 08d1e6f

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
@@ -83,24 +83,16 @@ LOG_MODULE_REGISTER(esb, CONFIG_ESB_LOG_LEVEL);
8383
/* NRF5340 Radio high voltage gain. */
8484
#define NRF5340_HIGH_VOLTAGE_GAIN 3
8585

86-
/* Fast switching is available for the nRF54H20 SoC.
87-
* The nRF54H20 is a non-RSSISTOP device.
88-
*/
8986
#if defined(RADIO_SHORTS_DISABLED_RSSISTOP_Msk)
90-
#define RADIO_SHORTS_COMMON \
91-
(NRF_RADIO_SHORT_READY_START_MASK | ESB_SHORT_DISABLE_MASK | \
92-
NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK | NRF_RADIO_SHORT_DISABLED_RSSISTOP_MASK)
87+
#define RADIO_RSSI_SHORTS \
88+
(NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK | NRF_RADIO_SHORT_DISABLED_RSSISTOP_MASK)
9389
#else
9490
/* Devices without RSSISTOP task will stop RSSI measurement after specific period. */
95-
#define RADIO_SHORTS_FAST_SWITCHING_NO_RSSISTOP (NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK)
96-
#define RADIO_SHORTS_NO_FAST_SWITCHING_NO_RSSISTOP \
97-
(NRF_RADIO_SHORT_READY_START_MASK | ESB_SHORT_DISABLE_MASK | \
98-
NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK)
91+
#define RADIO_RSSI_SHORTS (NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK)
92+
#endif /* !defined(RADIO_SHORTS_DISABLED_RSSISTOP_Msk) */
9993

100-
#define RADIO_SHORTS_COMMON \
101-
(IS_ENABLED(CONFIG_ESB_FAST_SWITCHING) ? RADIO_SHORTS_FAST_SWITCHING_NO_RSSISTOP : \
102-
RADIO_SHORTS_NO_FAST_SWITCHING_NO_RSSISTOP)
103-
#endif /* !defined(RADIO_SHORTS_DISABLED_RSSISTOP_Msk) */
94+
#define RADIO_NORMAL_SW_SHORTS \
95+
(RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_READY_START_MASK | ESB_RADIO_SHORT_END_DISABLE)
10496

10597
#if defined(CONFIG_SOC_SERIES_NRF54LX)
10698
#define RADIO_SHORTS_MONITOR \
@@ -305,7 +297,6 @@ static volatile uint32_t retransmits_remaining;
305297
static volatile uint32_t last_tx_attempts;
306298
static volatile uint32_t wait_for_ack_timeout_us;
307299

308-
static uint32_t radio_shorts_common = RADIO_SHORTS_COMMON;
309300
static const bool fast_switching = IS_ENABLED(CONFIG_ESB_FAST_SWITCHING);
310301

311302
static const mpsl_fem_event_t rx_event = {
@@ -1288,13 +1279,13 @@ static void start_tx_transaction(void)
12881279
memcpy(pdu->data, current_payload->data, current_payload->length);
12891280

12901281
if (fast_switching) {
1291-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1282+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_RSSI_SHORTS |
12921283
NRF_RADIO_SHORT_TXREADY_START_MASK));
12931284
nrf_radio_event_clear(NRF_RADIO, ESB_RADIO_EVENT_END);
12941285
nrf_radio_int_enable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
12951286
} else {
1296-
nrf_radio_shorts_set(NRF_RADIO,
1297-
(radio_shorts_common | NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
1287+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_NORMAL_SW_SHORTS |
1288+
NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
12981289
}
12991290
nrf_radio_int_enable(NRF_RADIO, NRF_RADIO_INT_DISABLED_MASK);
13001291

@@ -1317,13 +1308,15 @@ static void start_tx_transaction(void)
13171308
/* Handling ack if noack is set to false or if selective auto ack is turned off */
13181309
if (ack) {
13191310
if (fast_switching) {
1320-
nrf_radio_shorts_set(NRF_RADIO,
1321-
(radio_shorts_common | NRF_RADIO_SHORT_TXREADY_START_MASK));
1311+
nrf_radio_shorts_set(
1312+
NRF_RADIO,
1313+
(RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_TXREADY_START_MASK));
13221314
nrf_radio_event_clear(NRF_RADIO, ESB_RADIO_EVENT_END);
13231315
nrf_radio_int_enable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
13241316
} else {
13251317
nrf_radio_shorts_set(NRF_RADIO,
1326-
(radio_shorts_common | NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
1318+
(RADIO_NORMAL_SW_SHORTS |
1319+
NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
13271320
}
13281321

13291322
/* Configure the retransmit counter */
@@ -1332,8 +1325,8 @@ static void start_tx_transaction(void)
13321325
esb_state = ESB_STATE_PTX_TX_ACK;
13331326
nrf_radio_int_enable(NRF_RADIO, NRF_RADIO_INT_DISABLED_MASK);
13341327
} else if (IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX)) {
1335-
nrf_radio_shorts_set(NRF_RADIO, radio_shorts_common &
1336-
~ESB_SHORT_DISABLE_MASK);
1328+
nrf_radio_shorts_set(
1329+
NRF_RADIO, (RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_READY_START_MASK));
13371330
nrf_timer_shorts_set(esb_timer.p_reg,
13381331
(NRF_TIMER_SHORT_COMPARE1_STOP_MASK |
13391332
NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK));
@@ -1352,9 +1345,7 @@ static void start_tx_transaction(void)
13521345
(esb_state == ESB_STATE_PTX_TX));
13531346
esb_state = ESB_STATE_PTX_TX;
13541347
} else {
1355-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1356-
NRF_RADIO_SHORT_READY_START_MASK |
1357-
ESB_SHORT_DISABLE_MASK));
1348+
nrf_radio_shorts_set(NRF_RADIO, RADIO_NORMAL_SW_SHORTS);
13581349

13591350
on_radio_disabled = on_radio_disabled_tx_noack;
13601351
esb_state = ESB_STATE_PTX_TX;
@@ -1451,7 +1442,7 @@ static void on_radio_disabled_tx(void)
14511442
/* Remove the DISABLED -> RXEN shortcut, to make sure the radio stays
14521443
* disabled after the RX window
14531444
*/
1454-
nrf_radio_shorts_set(NRF_RADIO, radio_shorts_common);
1445+
nrf_radio_shorts_set(NRF_RADIO, RADIO_NORMAL_SW_SHORTS);
14551446

14561447
/* Make sure the timer is started the next time the radio is ready,
14571448
* and that it will disable the radio automatically if no packet is
@@ -1493,8 +1484,6 @@ static void on_radio_disabled_tx(void)
14931484
nrf_radio_packetptr_set(NRF_RADIO, rx_payload_buffer);
14941485
if (fast_switching) {
14951486
nrf_radio_int_disable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
1496-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common | ESB_SHORT_DISABLE_MASK |
1497-
NRF_RADIO_SHORT_RXREADY_START_MASK));
14981487
nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_START);
14991488
}
15001489
on_radio_disabled = on_radio_disabled_tx_wait_for_ack;
@@ -1530,10 +1519,6 @@ static void on_radio_disabled_tx_wait_for_ack(void)
15301519
}
15311520
}
15321521

1533-
if (fast_switching) {
1534-
nrf_radio_shorts_set(NRF_RADIO, radio_shorts_common);
1535-
}
1536-
15371522
if ((atomic_get(&tx_fifo.count) == 0) || (esb_cfg.tx_mode == ESB_TXMODE_MANUAL)) {
15381523
esb_state = ESB_STATE_IDLE;
15391524
errata_216_off();
@@ -1566,13 +1551,13 @@ static void on_radio_disabled_tx_wait_for_ack(void)
15661551
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_READY);
15671552

15681553
if (fast_switching) {
1569-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1554+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_RSSI_SHORTS |
15701555
NRF_RADIO_SHORT_TXREADY_START_MASK));
15711556
nrf_radio_event_clear(NRF_RADIO, ESB_RADIO_EVENT_END);
15721557
nrf_radio_int_enable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
15731558
} else {
1574-
nrf_radio_shorts_set(NRF_RADIO,
1575-
(radio_shorts_common | NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
1559+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_NORMAL_SW_SHORTS |
1560+
NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
15761561
}
15771562

15781563
if (esb_cfg.protocol == ESB_PROTOCOL_ESB) {
@@ -1637,12 +1622,12 @@ static void start_rx_listening(void)
16371622
on_radio_disabled = NULL;
16381623
} else {
16391624
if (fast_switching) {
1640-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1641-
NRF_RADIO_SHORT_READY_START_MASK));
1625+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_RSSI_SHORTS |
1626+
NRF_RADIO_SHORT_RXREADY_START_MASK));
16421627
nrf_radio_event_clear(NRF_RADIO, ESB_RADIO_EVENT_END);
16431628
nrf_radio_int_enable(NRF_RADIO, ESB_RADIO_INT_END_MASK);
16441629
} else {
1645-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1630+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_NORMAL_SW_SHORTS |
16461631
NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
16471632
}
16481633

@@ -1675,7 +1660,7 @@ static void clear_events_restart_rx(void)
16751660
esb_fem_lna_reset();
16761661
esb_ppi_for_txrx_clear(true, false);
16771662

1678-
nrf_radio_shorts_set(NRF_RADIO, radio_shorts_common);
1663+
nrf_radio_shorts_set(NRF_RADIO, 0);
16791664

16801665
if (esb_cfg.protocol == ESB_PROTOCOL_ESB) {
16811666
update_rf_payload_format_esb(0);
@@ -1692,8 +1677,13 @@ static void clear_events_restart_rx(void)
16921677

16931678
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
16941679

1695-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common | NRF_RADIO_SHORT_READY_START_MASK |
1696-
NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
1680+
if (fast_switching) {
1681+
nrf_radio_shorts_set(NRF_RADIO,
1682+
(RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_RXREADY_START_MASK));
1683+
} else {
1684+
nrf_radio_shorts_set(NRF_RADIO,
1685+
(RADIO_NORMAL_SW_SHORTS | NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
1686+
}
16971687

16981688
esb_ppi_for_txrx_set(true, false);
16991689
esb_fem_for_rx_set();
@@ -1801,12 +1791,12 @@ static void on_radio_disabled_rx(void)
18011791
nrf_radio_packetptr_set(NRF_RADIO, tx_pdu);
18021792

18031793
if (fast_switching) {
1804-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1805-
NRF_RADIO_SHORT_READY_START_MASK));
1794+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_RSSI_SHORTS |
1795+
NRF_RADIO_SHORT_TXREADY_START_MASK));
18061796
nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_TXEN);
18071797
} else {
1808-
nrf_radio_shorts_set(NRF_RADIO,
1809-
(radio_shorts_common | NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
1798+
nrf_radio_shorts_set(NRF_RADIO, (RADIO_NORMAL_SW_SHORTS |
1799+
NRF_RADIO_SHORT_DISABLED_RXEN_MASK));
18101800
}
18111801

18121802
on_radio_disabled = on_radio_disabled_rx_send_ack;
@@ -1837,11 +1827,11 @@ static void on_radio_disabled_rx_send_ack(void)
18371827
nrf_radio_packetptr_set(NRF_RADIO, rx_payload_buffer);
18381828
if (fast_switching) {
18391829
nrf_radio_shorts_set(NRF_RADIO,
1840-
(radio_shorts_common | NRF_RADIO_SHORT_READY_START_MASK));
1830+
(RADIO_RSSI_SHORTS | NRF_RADIO_SHORT_RXREADY_START_MASK));
18411831
nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_RXEN);
18421832
} else {
1843-
nrf_radio_shorts_set(NRF_RADIO, (radio_shorts_common |
1844-
NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
1833+
nrf_radio_shorts_set(NRF_RADIO,
1834+
(RADIO_NORMAL_SW_SHORTS | NRF_RADIO_SHORT_DISABLED_TXEN_MASK));
18451835
}
18461836
on_radio_disabled = on_radio_disabled_rx;
18471837

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)