Skip to content

Commit 09758f2

Browse files
edmontfabiobaltieri
authored andcommitted
drivers: ieee802154: nrf: limit number of serialized calls
For serialized nRF IEEE 802.15.4 Driver host, avoid using `nrf_802154_csl_writer_anchor_time_set` too often by caching the CSL RX time and period and using them to detect any shift on the periodic pattern. This improves power consumption by limiting the number of serialized calls. Signed-off-by: Eduardo Montoya <[email protected]>
1 parent e2b01a3 commit 09758f2

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ static struct nrf5_802154_data nrf5_data;
6565

6666
#define DRX_SLOT_RX 0 /* Delayed reception window ID */
6767

68+
#define NSEC_PER_TEN_SYMBOLS (10 * IEEE802154_PHY_OQPSK_780_TO_2450MHZ_SYMBOL_PERIOD_NS)
69+
6870
#if defined(CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE)
6971
#if defined(CONFIG_SOC_NRF5340_CPUAPP)
7072
#if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
@@ -925,8 +927,20 @@ static int nrf5_configure(const struct device *dev,
925927

926928
#if defined(CONFIG_IEEE802154_CSL_ENDPOINT)
927929
case IEEE802154_CONFIG_EXPECTED_RX_TIME: {
928-
nrf_802154_csl_writer_anchor_time_set(nrf_802154_timestamp_phr_to_mhr_convert(
929-
config->expected_rx_time / NSEC_PER_USEC));
930+
931+
#if defined(CONFIG_NRF_802154_SER_HOST)
932+
net_time_t period_ns = nrf5_data.csl_period * NSEC_PER_TEN_SYMBOLS;
933+
bool changed = (config->csl_rx_time - nrf5_data.csl_rx_time) % period_ns;
934+
935+
nrf5_data.csl_rx_time = config->csl_rx_time;
936+
937+
if (changed)
938+
#endif /* CONFIG_NRF_802154_SER_HOST */
939+
{
940+
nrf_802154_csl_writer_anchor_time_set(
941+
nrf_802154_timestamp_phr_to_mhr_convert(config->expected_rx_time /
942+
NSEC_PER_USEC));
943+
}
930944
} break;
931945

932946
case IEEE802154_CONFIG_RX_SLOT: {
@@ -942,9 +956,12 @@ static int nrf5_configure(const struct device *dev,
942956
config->rx_slot.channel, DRX_SLOT_RX);
943957
} break;
944958

945-
case IEEE802154_CONFIG_CSL_PERIOD:
959+
case IEEE802154_CONFIG_CSL_PERIOD: {
946960
nrf_802154_csl_writer_period_set(config->csl_period);
947-
break;
961+
#if defined(CONFIG_NRF_802154_SER_HOST)
962+
nrf5_data.csl_period = config->csl_period;
963+
#endif
964+
} break;
948965
#endif /* CONFIG_IEEE802154_CSL_ENDPOINT */
949966

950967
#if defined(CONFIG_IEEE802154_NRF5_MULTIPLE_CCA)

drivers/ieee802154/ieee802154_nrf5.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ struct nrf5_802154_data {
9292
/* The maximum number of extra CCA attempts to be performed before transmission. */
9393
uint8_t max_extra_cca_attempts;
9494
#endif
95+
96+
#if defined(CONFIG_NRF_802154_SER_HOST) && defined(CONFIG_IEEE802154_CSL_ENDPOINT)
97+
/* The last configured value of CSL period in units of 10 symbols. */
98+
uint32_t csl_period;
99+
100+
/* The last configured value of CSL phase time in nanoseconds. */
101+
net_time_t csl_rx_time;
102+
#endif /* CONFIG_NRF_802154_SER_HOST && CONFIG_IEEE802154_CSL_ENDPOINT */
95103
};
96104

97105
#endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_NRF5_H_ */

0 commit comments

Comments
 (0)