From adbb64e7ff536bfe27f088c7c00085531c633e1e Mon Sep 17 00:00:00 2001 From: Rafal Kuznia Date: Fri, 7 Nov 2025 15:36:43 +0100 Subject: [PATCH] nrf_802154: rev 38ca430cc7c375dd06db8c66b532cdfbad17783f This commit updates revision of the nrf_802154 component. Signed-off-by: Rafal Kuznia --- nrf_802154/common/include/nrf_802154.h | 41 ++++++++++++++++------- nrf_802154/doc/CHANGELOG.rst | 6 ++++ nrf_802154/driver/src/nrf_802154.c | 11 +++++++ nrf_802154/driver/src/nrf_802154_trx.c | 45 ++++++++++++++++++++------ nrf_802154/driver/src/nrf_802154_trx.h | 17 ++++++++++ 5 files changed, 98 insertions(+), 22 deletions(-) diff --git a/nrf_802154/common/include/nrf_802154.h b/nrf_802154/common/include/nrf_802154.h index a4813f1859..fb1f6c43aa 100644 --- a/nrf_802154/common/include/nrf_802154.h +++ b/nrf_802154/common/include/nrf_802154.h @@ -801,8 +801,8 @@ void nrf_802154_promiscuous_set(bool enabled); /** * @brief Checks if the radio is in the promiscuous mode. * - * @retval True Radio is in the promiscuous mode. - * @retval False Radio is not in the promiscuous mode. + * @retval true Radio is in the promiscuous mode. + * @retval false Radio is not in the promiscuous mode. */ bool nrf_802154_promiscuous_get(void); @@ -833,8 +833,8 @@ void nrf_802154_auto_ack_set(bool enabled); /** * @brief Checks if the auto ACK is enabled. * - * @retval True Auto ACK is enabled. - * @retval False Auto ACK is disabled. + * @retval true Auto ACK is enabled. + * @retval false Auto ACK is disabled. */ bool nrf_802154_auto_ack_get(void); @@ -926,8 +926,8 @@ void nrf_802154_src_addr_matching_method_set(nrf_802154_src_addr_match_t match_m * @param[in] length Length of @p p_data. * @param[in] data_type Type of data to be set. Refer to the @ref nrf_802154_ack_data_t type. * - * @retval True Address successfully added to the list. - * @retval False Not enough memory to store this address in the list. + * @retval true Address successfully added to the list. + * @retval false Not enough memory to store this address in the list. */ bool nrf_802154_ack_data_set(const uint8_t * p_addr, bool extended, @@ -953,8 +953,8 @@ bool nrf_802154_ack_data_set(const uint8_t * p_addr, * @param[in] extended If the given address is an extended MAC address or a short MAC address. * @param[in] data_type Type of data to be removed. Refer to the @ref nrf_802154_ack_data_t type. * - * @retval True Address removed from the list. - * @retval False Address not found in the list. + * @retval true Address removed from the list. + * @retval false Address not found in the list. */ bool nrf_802154_ack_data_clear(const uint8_t * p_addr, bool extended, @@ -1007,8 +1007,8 @@ void nrf_802154_auto_pending_bit_set(bool enabled); * @param[in] p_addr Array of bytes containing the address of the node (little-endian). * @param[in] extended If the given address is an extended MAC address or a short MAC address. * - * @retval True The address is successfully added to the list. - * @retval False Not enough memory to store the address in the list. + * @retval true The address is successfully added to the list. + * @retval false Not enough memory to store the address in the list. */ bool nrf_802154_pending_bit_for_addr_set(const uint8_t * p_addr, bool extended); @@ -1027,8 +1027,8 @@ bool nrf_802154_pending_bit_for_addr_set(const uint8_t * p_addr, bool extended); * @param[in] p_addr Array of bytes containing the address of the node (little-endian). * @param[in] extended If the given address is an extended MAC address or a short MAC address. * - * @retval True The address is successfully removed from the list. - * @retval False No such address in the list. + * @retval true The address is successfully removed from the list. + * @retval false No such address in the list. */ bool nrf_802154_pending_bit_for_addr_clear(const uint8_t * p_addr, bool extended); @@ -1533,6 +1533,23 @@ void nrf_802154_cst_writer_period_set(uint16_t period); */ void nrf_802154_cst_writer_anchor_time_set(uint64_t anchor_time); +/** + * @brief Returns if the radio has PA modulation fix enabled. + * + * @retval true PA modulation fix is enabled. + * @retval false PA modulation fix is disabled. + */ +bool nrf_802154_pa_modulation_fix_get(void); + +/** + * @brief Enables or disables the PA modulation fix. + * + * @note The PA modulation fix is enabled by default on the chips that require it. + * + * @param[in] enabled If the PA modulation fix is to be enabled. + */ +void nrf_802154_pa_modulation_fix_set(bool enable); + /** * @} * @defgroup nrf_802154_test_modes Test modes diff --git a/nrf_802154/doc/CHANGELOG.rst b/nrf_802154/doc/CHANGELOG.rst index 138e55a999..c07ee60331 100644 --- a/nrf_802154/doc/CHANGELOG.rst +++ b/nrf_802154/doc/CHANGELOG.rst @@ -42,6 +42,12 @@ Added * Added a TX diagnostic mode that permits sending arbitrary data payloads. Enable this feature with the :c:macro:`NRF_802154_TX_DIAGNOSTIC_MODE` configuration macro. When enabled, the driver must be built with reduced functionality. (KRKNWK-20784) +* Added support for controlling the PA modulation fix at runtime. (KRKNWK-21006) + + The fix is enabled by default on all SoCs that require it. + You can use the :c:func:`nrf_802154_pa_modulation_fix_set` function to enable or disable the fix at runtime. + + On SoCs that do not require the fix, enabling it has no effect. nRF Connect SDK v3.1.0 - nRF 802.15.4 Radio Driver ************************************************** diff --git a/nrf_802154/driver/src/nrf_802154.c b/nrf_802154/driver/src/nrf_802154.c index 26c91a45c2..1c9244ce91 100644 --- a/nrf_802154/driver/src/nrf_802154.c +++ b/nrf_802154/driver/src/nrf_802154.c @@ -59,6 +59,7 @@ #include "nrf_802154_pib.h" #include "nrf_802154_request.h" #include "nrf_802154_rx_buffer.h" +#include "nrf_802154_trx.h" #include "nrf_802154_tx_power.h" #include "nrf_802154_stats.h" #include "nrf_802154_swi.h" @@ -628,6 +629,16 @@ void nrf_802154_promiscuous_set(bool enabled) nrf_802154_pib_promiscuous_set(enabled); } +bool nrf_802154_pa_modulation_fix_get(void) +{ + return nrf_802154_trx_pa_modulation_fix_get(); +} + +void nrf_802154_pa_modulation_fix_set(bool enable) +{ + nrf_802154_trx_pa_modulation_fix_set(enable); +} + void nrf_802154_rx_on_when_idle_set(bool enabled) { nrf_802154_pib_rx_on_when_idle_set(enabled); diff --git a/nrf_802154/driver/src/nrf_802154_trx.c b/nrf_802154/driver/src/nrf_802154_trx.c index 5e76697fea..e1435728be 100644 --- a/nrf_802154/driver/src/nrf_802154_trx.c +++ b/nrf_802154/driver/src/nrf_802154_trx.c @@ -175,6 +175,11 @@ void nrf_802154_radio_irq_handler(void); ///< Prototype required by internal RAD #define NRF_802154_TRX_TEST_MODE_ALLOW_LATE_TX_ACK 0 #endif +#if !defined(CONFIG_SOC_SERIES_BSIM_NRFXX) && (defined(NRF5340_XXAA) || \ + NRF54L_CONFIGURATION_56_ENABLE) +#define NRF_802154_TRX_PA_MODULATION_FIX +#endif + #if !defined(CONFIG_SOC_SERIES_BSIM_NRFXX) /// System Clock Frequency (Core Clock) provided by nrfx. extern uint32_t SystemCoreClock; @@ -243,6 +248,10 @@ static volatile uint32_t m_timer_value_on_radio_end_event; static volatile bool m_transmit_with_cca; static volatile uint8_t m_remaining_cca_attempts; +#if defined(NRF_802154_TRX_PA_MODULATION_FIX) +static bool m_pa_modulation_fix_enabled = true; +#endif /* NRF_802154_TRX_PA_MODULATION_FIX */ + static void timer_frequency_set_1mhz(void); static void rxframe_finish_disable_ppis(void); @@ -803,14 +812,16 @@ static void pa_modulation_fix_apply(bool enable) volatile uint32_t * p_radio_reg; #if defined(NRF5340_XXAA) +#define PA_MOD_FILTER_VALUE 0x40081B08 p_radio_reg = (volatile uint32_t *)(RADIO_BASE + 0x584UL); -#elif NRF54L_CONFIGURATION_56_ENABLE +#elif NRF54L_CONFIGURATION_56_ENABLE /* MLTPAN-56 */ +#define PA_MOD_FILTER_VALUE 0x01280001ul p_radio_reg = (volatile uint32_t *)(RADIO_BASE + 0x8C4UL); #else #error Unknown SoC #endif - if (enable) + if (enable && m_pa_modulation_fix_enabled) { mpsl_fem_caps_t fem_caps = {}; @@ -818,16 +829,9 @@ static void pa_modulation_fix_apply(bool enable) if ((fem_caps.flags & MPSL_FEM_CAPS_FLAG_PA_SETUP_REQUIRED) != 0) { -#if defined(NRF5340_XXAA) m_pa_mod_filter_latched = *(p_radio_reg); m_pa_mod_filter_is_latched = true; - *(p_radio_reg) = 0x40081B08; -#elif NRF54L_CONFIGURATION_56_ENABLE - // MLTPAN-56 - m_pa_mod_filter_latched = *(p_radio_reg); - m_pa_mod_filter_is_latched = true; - *(p_radio_reg) = 0x01280001ul; -#endif + *(p_radio_reg) = PA_MOD_FILTER_VALUE; } } else if (m_pa_mod_filter_is_latched) @@ -841,12 +845,33 @@ static void pa_modulation_fix_apply(bool enable) #endif /* !defined(CONFIG_SOC_SERIES_BSIM_NRFXX) */ } +void nrf_802154_trx_pa_modulation_fix_set(bool enable) +{ +#if defined(NRF_802154_TRX_PA_MODULATION_FIX) + m_pa_modulation_fix_enabled = enable; +#else + (void)enable; +#endif /* NRF_802154_TRX_PA_MODULATION_FIX */ +} + +bool nrf_802154_trx_pa_modulation_fix_get(void) +{ +#if defined(NRF_802154_TRX_PA_MODULATION_FIX) + return m_pa_modulation_fix_enabled; +#else + return false; +#endif /* NRF_802154_TRX_PA_MODULATION_FIX */ +} + void nrf_802154_trx_module_reset(void) { m_trx_state = TRX_STATE_DISABLED; m_timer_value_on_radio_end_event = 0; m_transmit_with_cca = false; mp_receive_buffer = NULL; +#if defined(NRF_802154_TRX_PA_MODULATION_FIX) + m_pa_modulation_fix_enabled = true; +#endif /* NRF_802154_TRX_PA_MODULATION_FIX */ memset(&m_flags, 0, sizeof(m_flags)); } diff --git a/nrf_802154/driver/src/nrf_802154_trx.h b/nrf_802154/driver/src/nrf_802154_trx.h index 3620b38d63..b58dcf69f3 100644 --- a/nrf_802154/driver/src/nrf_802154_trx.h +++ b/nrf_802154/driver/src/nrf_802154_trx.h @@ -162,6 +162,23 @@ void nrf_802154_trx_enable(void); */ void nrf_802154_trx_disable(void); +/** + * @brief Returns if the radio has PA modulation fix enabled. + * + * @retval True PA modulation fix is enabled. + * @retval False PA modulation fix is disabled. + */ +bool nrf_802154_trx_pa_modulation_fix_get(void); + +/** + * @brief Enables or disables the PA modulation fix. + * + * @note The PA modulation fix is enabled by default on the chips that require it. + * + * @param[in] enabled If the PA modulation fix is to be enabled. + */ +void nrf_802154_trx_pa_modulation_fix_set(bool enable); + /** * @brief Updates currently used antenna. *