From 3c019a5d5914b622b8d077bc930dd56e9924c1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Mi=C5=9B?= Date: Tue, 27 Mar 2018 18:31:31 +0200 Subject: [PATCH] [nrf52840] update radio driver to f36aa41 and provide temperature (#2638) --- examples/platforms/nrf52840/Makefile.am | 261 +++---- examples/platforms/nrf52840/platform-config.h | 14 + examples/platforms/nrf52840/platform-nrf5.h | 6 + examples/platforms/nrf52840/platform.c | 1 + examples/platforms/nrf52840/temp.c | 69 +- .../drivers/radio/nrf_802154.c | 47 +- .../drivers/radio/nrf_802154.h | 673 +++++++++--------- .../drivers/radio/nrf_802154_config.h | 129 ++-- .../drivers/radio/nrf_802154_core.c | 19 +- .../drivers/radio/nrf_802154_debug.h | 11 +- .../drivers/radio/nrf_802154_rssi.c | 96 +++ .../drivers/radio/nrf_802154_rssi.h | 90 +++ .../drivers/radio/nrf_802154_types.h | 66 +- .../temperature/nrf_802154_temperature.h | 87 +++ .../temperature/nrf_802154_temperature_none.c | 60 ++ .../raal/softdevice/nrf_raal_softdevice.c | 408 ++++++----- .../timer_scheduler/nrf_802154_timer_sched.c | 4 + 17 files changed, 1279 insertions(+), 762 deletions(-) create mode 100644 third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.c create mode 100644 third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.h create mode 100644 third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature.h create mode 100644 third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature_none.c diff --git a/examples/platforms/nrf52840/Makefile.am b/examples/platforms/nrf52840/Makefile.am index 089010781..fb02711b1 100644 --- a/examples/platforms/nrf52840/Makefile.am +++ b/examples/platforms/nrf52840/Makefile.am @@ -146,6 +146,7 @@ RADIO_DRIVER_SOURCES @top_builddir@/third_party/NordicSemiconductor/drivers/radio/nrf_802154_debug.c \ @top_builddir@/third_party/NordicSemiconductor/drivers/radio/nrf_802154_pib.c \ @top_builddir@/third_party/NordicSemiconductor/drivers/radio/nrf_802154_revision.c \ + @top_builddir@/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.c \ @top_builddir@/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rx_buffer.c \ @top_builddir@/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_control.c \ @top_builddir@/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_filter.c \ @@ -212,135 +213,137 @@ libopenthread_nrf52840_softdevice_sdk_a_SOURCES $(SOFTDEVICE_SOURCES) \ $(NULL) -noinst_HEADERS = \ - $(top_srcdir)/third_party/NordicSemiconductor/cmsis/arm_math.h \ - $(top_srcdir)/third_party/NordicSemiconductor/cmsis/cmsis_armcc_V6.h \ - $(top_srcdir)/third_party/NordicSemiconductor/cmsis/cmsis_armcc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/cmsis/cmsis_gcc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cm4.h \ - $(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmFunc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmInstr.h \ - $(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmSimd.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/app_util_platform.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/app_util.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/apply_old_config.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nordic_common.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_assert.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_error.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_instance.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_internal.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_types.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_section.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_config.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_glue.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_log.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_common.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_config.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_errors.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_macros.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_os.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_resources.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/common/nrf_drv_common.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/systick/nrf_drv_systick.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd_errata.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_ack_pending_bit.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core_hooks.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_config.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_const.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_critical_section.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_debug.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_notification.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_pib.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_priority_drop.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_procedures_duration.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_request.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_revision.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rx_buffer.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_swi.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_control_api.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_control_config.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/hal/nrf_radio.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_ack_timeout.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_csma_ca.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_filter.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/clock/nrf_802154_clock.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/timer/nrf_802154_timer.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/raal/nrf_raal_api.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/raal/nrf_raal_config.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/raal/softdevice/nrf_raal_softdevice.h \ - $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error/app_error_weak.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error/app_error.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo_internal.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic_internal.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_class_base.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_descriptor.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_langid.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_request.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_types.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_desc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_types.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm_internal.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.h \ - $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config/app_usbd_string_config.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/nrfx_common.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/nrfx_errors.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_clock.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_power_clock.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_power.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_systick.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_clock.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_gpio.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_gpiote.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_egu.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_nvmc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_ppi.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_power.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_rng.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_uart.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_usbd.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/compiler_abstraction.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf_peripherals.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf51_to_nrf52.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf51_to_nrf52840.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52_to_nrf52840.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52840.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52840_bitfields.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52840_peripherals.h \ - $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/system_nrf52840.h \ - $(top_srcdir)/third_party/NordicSemiconductor/segger_rtt/SEGGER_RTT.h \ - $(top_srcdir)/third_party/NordicSemiconductor/segger_rtt/SEGGER_RTT_Conf.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_err.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gap.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gatt.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gattc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gatts.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_hci.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_l2cap.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_ranges.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_types.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_error.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_error_sdm.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_error_soc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_nvic.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_sdm.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_soc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_svc.h \ - $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf52/nrf_mbr.h \ +noinst_HEADERS = \ + $(top_srcdir)/third_party/NordicSemiconductor/cmsis/arm_math.h \ + $(top_srcdir)/third_party/NordicSemiconductor/cmsis/cmsis_armcc_V6.h \ + $(top_srcdir)/third_party/NordicSemiconductor/cmsis/cmsis_armcc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/cmsis/cmsis_gcc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cm4.h \ + $(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmFunc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmInstr.h \ + $(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmSimd.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/app_util_platform.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/app_util.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/apply_old_config.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nordic_common.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_assert.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_error.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_instance.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_internal.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_types.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_section.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_config.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_glue.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_log.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_common.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_config.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_errors.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_macros.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_os.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_resources.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/common/nrf_drv_common.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/systick/nrf_drv_systick.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd_errata.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_ack_pending_bit.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core_hooks.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_config.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_const.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_critical_section.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_debug.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_notification.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_pib.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_priority_drop.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_procedures_duration.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_request.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_revision.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rx_buffer.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_swi.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_control_api.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_control_config.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/hal/nrf_radio.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_ack_timeout.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_csma_ca.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_filter.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/clock/nrf_802154_clock.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/timer/nrf_802154_timer.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/raal/nrf_raal_api.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/raal/nrf_raal_config.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/raal/softdevice/nrf_raal_softdevice.h \ + $(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error/app_error_weak.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error/app_error.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo_internal.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic_internal.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_class_base.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_descriptor.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_langid.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_request.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_types.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_desc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_types.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm_internal.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config/app_usbd_string_config.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/nrfx_common.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/nrfx_errors.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_clock.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_power_clock.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_power.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_systick.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_clock.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_gpio.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_gpiote.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_egu.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_nvmc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_ppi.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_power.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_rng.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_uart.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_usbd.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/compiler_abstraction.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf_peripherals.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf51_to_nrf52.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf51_to_nrf52840.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52_to_nrf52840.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52840.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52840_bitfields.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52840_peripherals.h \ + $(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/system_nrf52840.h \ + $(top_srcdir)/third_party/NordicSemiconductor/segger_rtt/SEGGER_RTT.h \ + $(top_srcdir)/third_party/NordicSemiconductor/segger_rtt/SEGGER_RTT_Conf.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_err.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gap.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gatt.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gattc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gatts.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_hci.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_l2cap.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_ranges.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_types.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_error.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_error_sdm.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_error_soc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_nvic.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_sdm.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_soc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_svc.h \ + $(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf52/nrf_mbr.h \ $(NULL) PRETTY_FILES = \ diff --git a/examples/platforms/nrf52840/platform-config.h b/examples/platforms/nrf52840/platform-config.h index 4e473ca56..92a95b5d8 100644 --- a/examples/platforms/nrf52840/platform-config.h +++ b/examples/platforms/nrf52840/platform-config.h @@ -392,4 +392,18 @@ #define NRF_802154_ACK_TIMEOUT_ENABLED 1 #endif +/******************************************************************************* + * @section Temperature sensor driver configuration. + ******************************************************************************/ + +/** + * @def TEMP_MEASUREMENT_INTERVAL + * + * Interval of consecutive temperature measurements [s]. + * + */ +#ifndef TEMP_MEASUREMENT_INTERVAL +#define TEMP_MEASUREMENT_INTERVAL 30 +#endif + #endif // PLATFORM_CONFIG_H_ diff --git a/examples/platforms/nrf52840/platform-nrf5.h b/examples/platforms/nrf52840/platform-nrf5.h index 0403ef0cd..629793139 100644 --- a/examples/platforms/nrf52840/platform-nrf5.h +++ b/examples/platforms/nrf52840/platform-nrf5.h @@ -179,6 +179,12 @@ void nrf5TempInit(void); */ void nrf5TempDeinit(void); +/** + * Function for processing temperature controller. + * + */ +void nrf5TempProcess(void); + /** * Function for measuring internal temperature. * diff --git a/examples/platforms/nrf52840/platform.c b/examples/platforms/nrf52840/platform.c index 7dfe60bd8..82858a809 100644 --- a/examples/platforms/nrf52840/platform.c +++ b/examples/platforms/nrf52840/platform.c @@ -110,6 +110,7 @@ void PlatformProcessDrivers(otInstance *aInstance) nrf5AlarmProcess(aInstance); nrf5RadioProcess(aInstance); nrf5UartProcess(); + nrf5TempProcess(); } __WEAK void PlatformEventSignalPending(void) diff --git a/examples/platforms/nrf52840/temp.c b/examples/platforms/nrf52840/temp.c index bba02e1f6..3faf0af80 100644 --- a/examples/platforms/nrf52840/temp.c +++ b/examples/platforms/nrf52840/temp.c @@ -34,11 +34,17 @@ #include #include "platform-nrf5.h" +#include #if SOFTDEVICE_PRESENT #include "softdevice.h" #endif +#define US_PER_S 1000000ULL + +static uint64_t sLastReadTimestamp; +static int32_t sTemperature; + #if !SOFTDEVICE_PRESENT __STATIC_INLINE void dataReadyEventClear(void) { @@ -52,6 +58,8 @@ void nrf5TempInit(void) { #if !SOFTDEVICE_PRESENT nrf_temp_init(); + + NRF_TEMP->TASKS_START = 1; #endif } @@ -62,25 +70,60 @@ void nrf5TempDeinit(void) #endif } -int32_t nrf5TempGet(void) +void nrf5TempProcess(void) { -#if SOFTDEVICE_PRESENT - int32_t temperature; - (void)sd_temp_get(&temperature); -#else - NRF_TEMP->TASKS_START = 1; + int32_t prevTemperature = sTemperature; + uint64_t now; - while (NRF_TEMP->EVENTS_DATARDY == 0) +#if SOFTDEVICE_PRESENT + now = nrf5AlarmGetCurrentTime(); + + if (now - sLastReadTimestamp > (TEMP_MEASUREMENT_INTERVAL * US_PER_S)) { - ; + (void)sd_temp_get(&sTemperature); + sLastReadTimestamp = now; + } +#else + if (NRF_TEMP->EVENTS_DATARDY) + { + dataReadyEventClear(); + + sTemperature = nrf_temp_read(); } - dataReadyEventClear(); + now = nrf5AlarmGetCurrentTime(); - int32_t temperature = nrf_temp_read(); - - NRF_TEMP->TASKS_STOP = 1; + if (now - sLastReadTimestamp > (TEMP_MEASUREMENT_INTERVAL * US_PER_S)) + { + NRF_TEMP->TASKS_START = 1; + sLastReadTimestamp = now; + } #endif - return temperature; + if (prevTemperature != sTemperature) + { + nrf_802154_temperature_changed(); + } +} + +int32_t nrf5TempGet(void) +{ + // Provide temperature value in [0.25 C] unit. + return sTemperature; +} + +void nrf_802154_temperature_init(void) +{ + // Intentionally empty +} + +void nrf_802154_temperature_deinit(void) +{ + // Intentionally empty +} + +int8_t nrf_802154_temperature_get(void) +{ + // Provide temperature value in [C]. + return (int8_t)(sTemperature / 4); } diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154.c b/third_party/NordicSemiconductor/drivers/radio/nrf_802154.c index ca31d3fc7..e0e8305c4 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154.c +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154.c @@ -53,9 +53,11 @@ #include "nrf_802154_priority_drop.h" #include "nrf_802154_request.h" #include "nrf_802154_revision.h" +#include "nrf_802154_rssi.h" #include "nrf_802154_rx_buffer.h" #include "hal/nrf_radio.h" #include "platform/clock/nrf_802154_clock.h" +#include "platform/temperature/nrf_802154_temperature.h" #include "platform/timer/nrf_802154_timer.h" #include "raal/nrf_raal_api.h" #include "timer_scheduler/nrf_802154_timer_sched.h" @@ -123,6 +125,11 @@ int8_t nrf_802154_tx_power_get(void) return nrf_802154_pib_tx_power_get(); } +void nrf_802154_temperature_changed(void) +{ + nrf_802154_request_cca_cfg_update(); +} + void nrf_802154_pan_id_set(const uint8_t * p_pan_id) { nrf_802154_pib_pan_id_set(p_pan_id); @@ -164,6 +171,7 @@ void nrf_802154_init(void) nrf_802154_request_init(); nrf_802154_revision_init(); nrf_802154_rx_buffer_init(); + nrf_802154_temperature_init(); nrf_802154_timer_init(); nrf_802154_timer_sched_init(); nrf_raal_init(); @@ -173,6 +181,7 @@ void nrf_802154_deinit(void) { nrf_802154_timer_sched_deinit(); nrf_802154_timer_deinit(); + nrf_802154_temperature_deinit(); nrf_802154_clock_deinit(); nrf_802154_core_deinit(); } @@ -356,44 +365,12 @@ void nrf_802154_buffer_free(uint8_t * p_data) int8_t nrf_802154_rssi_last_get(void) { uint8_t minus_dbm = nrf_radio_rssi_sample_get(); + + minus_dbm = nrf_802154_rssi_sample_corrected_get(minus_dbm); + return - (int8_t)minus_dbm; } -int8_t nrf_802154_rssi_corrected_get(int8_t rssi, int8_t temp) -{ - if (temp <= -30) - { - return rssi + 3; - } - - if (temp <= -10) - { - return rssi + 2; - } - - if (temp <= 10) - { - return rssi + 1; - } - - if (temp <= 30) - { - return rssi; - } - - if (temp <= 50) - { - return rssi - 1; - } - - if (temp <= 70) - { - return rssi - 2; - } - - return rssi - 3; -} - bool nrf_802154_promiscuous_get(void) { return nrf_802154_pib_promiscuous_get(); diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154.h b/third_party/NordicSemiconductor/drivers/radio/nrf_802154.h index 1642c2caf..b9185cc32 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154.h +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154.h @@ -29,7 +29,8 @@ */ /** - * @brief This module contains generic 802.15.4 radio driver for nRF SoC devices. + * @defgroup nrf_802154 802.15.4 radio driver + * @{ * */ @@ -51,18 +52,18 @@ extern "C" { #endif /** - * @brief Initialize 802.15.4 driver. + * @brief Initialize the 802.15.4 driver. * - * @note This function shall be called once, before any other function from this module. + * Initialize the RADIO peripheral to Sleep state. * - * Initialize radio peripheral to Sleep state. + * @note This function shall be called once, before any other functions from this module. */ void nrf_802154_init(void); /** - * @brief Deinitialize 802.15.4 driver. + * @brief Deinitialize the 802.15.4 driver. * - * Deinitialize radio peripheral and reset it to the default state. + * Deinitialize the RADIO peripheral and reset it to the default state. */ void nrf_802154_deinit(void); @@ -70,34 +71,34 @@ void nrf_802154_deinit(void); /** * @brief Handle interrupt request from the RADIO peripheral. * - * @note When NRF_802154_INTERNAL_RADIO_IRQ_HANDLING is enabled the driver internally handles the - * RADIO IRQ and this function shall not be called. + * @note If NRF_802154_INTERNAL_RADIO_IRQ_HANDLING is enabled, the driver internally handles the + * RADIO IRQ, and this function shall not be called. * - * This function is intended to be used in Operating System environment when the OS handles IRQ - * and indirectly passes it to the driver or with RAAL implementation that indirectly passes radio - * IRQ handler to the driver (i.e. SoftDevice). + * This function should be used in an operating system environment where the OS handles IRQ + * and indirectly passes it to the driver, or with a RAAL implementation that indirectly passes radio + * IRQ to the driver (i.e. SoftDevice). */ void nrf_802154_radio_irq_handler(void); #endif // !NRF_802154_INTERNAL_RADIO_IRQ_HANDLING /** - * @brief Set channel on which the radio shall operate right now. + * @brief Set channel on which the radio shall operate. * * @param[in] channel Channel number (11-26). */ void nrf_802154_channel_set(uint8_t channel); /** - * @brief Get channel on which the radio operates right now. + * @brief Get channel on which the radio operates. * - * @returns Channel number (11-26). + * @return Channel number (11-26). */ uint8_t nrf_802154_channel_get(void); /** * @brief Set transmit power. * - * @note The driver recalculates requested value to the nearest value accepted by the hardware. + * @note The driver recalculates the requested value to the nearest value accepted by the hardware. * The calculation result is rounded up. * * @param[in] power Transmit power [dBm]. @@ -111,16 +112,17 @@ void nrf_802154_tx_power_set(int8_t power); */ int8_t nrf_802154_tx_power_get(void); -/*************************************************************************************************** - * @section Front-end module management. - **************************************************************************************************/ +/** + * @defgroup nrf_802154_frontend Front-end module management + * @{ + */ #if ENABLE_FEM -/** Structure containing run-time configuration of FEM module. */ +/** Structure containing run-time configuration of the FEM module. */ typedef nrf_fem_control_cfg_t nrf_802154_fem_control_cfg_t; -/** Macro with default configuration of FEM module. */ +/** Macro with default configuration of the FEM module. */ #define NRF_802154_FEM_DEFAULT_SETTINGS \ ((nrf_802154_fem_control_cfg_t) { \ .pa_cfg = { \ @@ -142,7 +144,7 @@ typedef nrf_fem_control_cfg_t nrf_802154_fem_control_cfg_t; /** * @brief Set PA & LNA GPIO toggle configuration. * - * @note This function shall not be called when radio is in use. + * @note This function shall not be called when the radio is in use. * * @param[in] p_cfg A pointer to the PA & LNA GPIO toggle configuration. * @@ -160,65 +162,71 @@ void nrf_802154_fem_control_cfg_get(nrf_802154_fem_control_cfg_t * p_cfg); #endif // ENABLE_FEM -/*************************************************************************************************** - * @section Setting addresses and Pan Id of this device. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_addresses Setting addresses and PAN ID of the device + * @{ + */ /** - * @brief Set PAN Id used by this device. + * @brief Set the PAN ID used by the device. * - * @param[in] p_pan_id Pointer to PAN Id (2 bytes, little-endian). + * @param[in] p_pan_id Pointer to the PAN ID (2 bytes, little-endian). * - * This function makes copy of the PAN Id. + * This function makes a copy of the PAN ID. */ void nrf_802154_pan_id_set(const uint8_t *p_pan_id); /** - * @brief Set Extended Address of this device. + * @brief Set the extended address of the device. * - * @param[in] p_extended_address Pointer to extended address (8 bytes, little-endian). + * @param[in] p_extended_address Pointer to the extended address (8 bytes, little-endian). * - * This function makes copy of the address. + * This function makes a copy of the address. */ void nrf_802154_extended_address_set(const uint8_t *p_extended_address); /** - * @brief Set Short Address of this device. + * @brief Set the short address of the device. * - * @param[in] p_short_address Pointer to short address (2 bytes, little-endian). + * @param[in] p_short_address Pointer to the short address (2 bytes, little-endian). * - * This function makes copy of the address. + * This function makes a copy of the address. */ void nrf_802154_short_address_set(const uint8_t *p_short_address); -/*************************************************************************************************** - * @section Functions to calculate data given by the driver. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_data Functions to calculate data given by the driver + * @{ + */ /** - * @brief Calculate dBm from energy level received during energy detection procedure. + * @brief Calculate dBm from the energy level received during the energy detection procedure. * - * @param[in] energy_level Energy level passed by @sa nrf_802154_energy_detected + * @param[in] energy_level Energy level passed by @ref nrf_802154_energy_detected. * - * @return Result of energy detection procedure in dBm. + * @return Result of the energy detection procedure in dBm. */ int8_t nrf_802154_dbm_from_energy_level_calculate(uint8_t energy_level); /** - * @brief Calculate timestamp of beginning of first symbol of preamble in a received frame. + * @brief Calculate the timestamp of the first symbol of the preamble in a received frame. * - * @param[in] end_timestamp Timestamp of end of last symbol in the frame (in us). + * @param[in] end_timestamp Timestamp of the end of the last symbol in the frame (in us). * @param[in] psdu_length Number of bytes in the frame PSDU. * - * @return Timestamp of first preamble symbol of given frame (in us). + * @return Timestamp of the beginning of the first preamble symbol of a given frame (in us). */ uint32_t nrf_802154_first_symbol_timestamp_get(uint32_t end_timestamp, uint8_t psdu_length); -/*************************************************************************************************** - * @section Functions to request FSM transitions and check current state. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_transitions Functions to request FSM transitions and check current state + * @{ + */ /** * @brief Get current state of the radio. @@ -226,165 +234,169 @@ uint32_t nrf_802154_first_symbol_timestamp_get(uint32_t end_timestamp, uint8_t p nrf_802154_state_t nrf_802154_state_get(void); /** - * @brief Change radio state to Sleep. + * @brief Change radio state to sleep. * - * Sleep state is the lowest power state. In this state radio cannot transmit or receive frames. - * It is the only state in which the driver releases high frequency clock and does not request + * Sleep state is the lowest power state. In this state, the radio cannot transmit or receive frames. + * It is the only state in which the driver releases the high-frequency clock and does not request * timeslots from a radio arbiter. * - * @note High frequency clock may be enabled even in radio Sleep state if other module requests it. + * @note If another module requests it, the high-frequency clock may be enabled even in radio sleep state. * - * @return true If the radio changes it's state to low power mode. - * @return false If the driver could not schedule changing state. + * @retval true If the radio changes its state to low power mode. + * @retval false If the driver could not schedule changing state. */ bool nrf_802154_sleep(void); /** - * @brief Change radio state to Receive. + * @brief Change radio state to receive. * - * In Receive state radio receives frames and may automatically send ACK frames when appropriate. - * Received frame is reported to higher layer by @sa nrf_radio802154_received() call. + * In receive state, the radio receives frames and may automatically send ACK frames when appropriate. + * The received frame is reported to higher layer by a call to @ref nrf_802154_received. * - * @return true If the radio enters Receive state. - * @return false If the driver could not enter Receive state. + * @retval true If the radio enters receive state. + * @retval false If the driver could not enter receive state. */ bool nrf_802154_receive(void); #if NRF_802154_USE_RAW_API /** - * @brief Change radio state to Transmit. + * @brief Change radio state to transmit. * - * @note If the CPU was halted or interrupted during performing this function - * @sa nrf_802154_transmitted() or @sa nrf_802154_transmit_failed() may be - * called before nrf_802154_transmit_raw() returns result. - * @note This function is implemented in zero-copy fashion. It passes given buffer pointer to + * @note If the CPU is halted or interrupted while this function is executed, + * @ref nrf_802154_transmitted or @ref nrf_802154_transmit_failed may be + * called before this function returns a result. + * @note This function is implemented in zero-copy fashion. It passes the given buffer pointer to * the RADIO peripheral. * - * In Transmit state radio transmits given frame. If requested it waits for ACK frame. - * Depending on @sa NRF_802154_ACK_TIMEOUT_ENABLED configuration option, Radio driver automatically - * stops waiting for an ACK frame or waits infinitely for an ACK frame. If it is configured to wait - * indefinitely, MAC layer is responsible to call @sa nrf_radio802154_receive() or - * @sa nrf_radio802154_sleep() after ACK timeout. - * Transmission result is reported to higher layer by @sa nrf_radio802154_transmitted() or - * @sa nrf_radio802154_transmit_failed() calls. + * In transmit state, the radio transmits a given frame. If requested, it waits for an ACK frame. + * Depending on @ref NRF_802154_ACK_TIMEOUT_ENABLED, the radio driver automatically + * stops waiting for an ACK frame or waits indefinitely for an ACK frame. If it is configured to wait, + * the MAC layer is responsible for calling @ref nrf_802154_receive or + * @ref nrf_802154_sleep after the ACK time-out. + * The transmission result is reported to the higher layer by calls to @ref nrf_802154_transmitted or + * @ref nrf_802154_transmit_failed. * + * @verbatim * p_data * v * +-----+-----------------------------------------------------------+------------+ - * | PHR | MAC Header and payload | FCS | + * | PHR | MAC header and payload | FCS | * +-----+-----------------------------------------------------------+------------+ * | | * | <---------------------------- PHR -----------------------------------> | + * @endverbatim * * @param[in] p_data Pointer to array containing data to transmit. First byte should contain * frame length (including PHR and FCS). Following bytes should contain data. - * CRC is computed automatically by radio hardware and because of that FCS + * CRC is computed automatically by radio hardware. Therefore, the FCS * field can contain any bytes. - * @param[in] cca If the driver should perform CCA procedure before transmission. + * @param[in] cca If the driver should perform a CCA procedure before transmission. * - * @return true If the transmission procedure was scheduled. - * @return false If the driver could not schedule the transmission procedure. + * @retval true If the transmission procedure was scheduled. + * @retval false If the driver could not schedule the transmission procedure. */ bool nrf_802154_transmit_raw(const uint8_t * p_data, bool cca); #else // NRF_802154_USE_RAW_API /** - * @brief Change radio state to Transmit. + * @brief Change radio state to transmit. * - * @note If the CPU was halted or interrupted during performing this function - * @sa nrf_802154_transmitted() or @sa nrf_802154_transmit_failed() may be - * called before nrf_802154_transmit() returns result. - * @note This function makes copy of given buffer. There is an internal buffer maintained by this - * function. It is used to make a frame copy. To prevent unnecessary memory consumption and - * to perform zero-copy transmission @sa nrf_802154_transmit_raw() function should - * be used instead of this. + * @note If the CPU is halted or interrupted while this function is executed, + * @ref nrf_802154_transmitted or @ref nrf_802154_transmit_failed must be + * called before this function returns a result. + * @note This function copies the given buffer. It maintains an internal buffer, which + * is used to make a frame copy. To prevent unnecessary memory consumption and + * to perform zero-copy transmission, use @ref nrf_802154_transmit_raw instead. * - * In Transmit state radio transmits given frame. If requested it waits for ACK frame. - * Depending on @sa NRF_802154_ACK_TIMEOUT_ENABLED configuration option, Radio driver automatically - * stops waiting for an ACK frame or waits infinitely for an ACK frame. If it is configured to wait - * indefinitely, MAC layer is responsible to call @sa nrf_radio802154_receive() or - * @sa nrf_radio802154_sleep() after ACK timeout. - * Transmission result is reported to higher layer by @sa nrf_radio802154_transmitted() or - * @sa nrf_radio802154_transmit_failed() calls. + * In transmit state, the radio transmits a given frame. If requested, it waits for an ACK frame. + * Depending on @ref NRF_802154_ACK_TIMEOUT_ENABLED, the radio driver automatically + * stops waiting for an ACK frame or waits indefinitely for an ACK frame. If it is configured to wait, + * the MAC layer is responsible for calling @ref nrf_802154_receive or + * @ref nrf_802154_sleep after the ACK time-out. + * The transmission result is reported to the higher layer by calls to @ref nrf_802154_transmitted or + * @ref nrf_802154_transmit_failed. * + * @verbatim * p_data * v * +-----+-----------------------------------------------------------+------------+ - * | PHR | MAC Header and payload | FCS | + * | PHR | MAC header and payload | FCS | * +-----+-----------------------------------------------------------+------------+ * | | * | <------------------ length -----------------------------> | + * @endverbatim * - * @param[in] p_data Pointer to array containing payload of a data to transmit. The array - * should exclude PHR or FCS fields of 802.15.4 frame. - * @param[in] length Length of given frame. This value shall exclude PHR and FCS fields from - * the given frame (exact size of buffer pointed by @p p_data). - * @param[in] cca If the driver should perform CCA procedure before transmission. + * @param[in] p_data Pointer to array containing payload of data to transmit. The array + * should exclude PHR or FCS fields of the 802.15.4 frame. + * @param[in] length Length of the given frame. This value shall exclude PHR and FCS fields from + * the given frame (exact size of buffer pointed to by @p p_data). + * @param[in] cca If the driver should perform a CCA procedure before transmission. * - * @return true If the transmission procedure was scheduled. - * @return false If the driver could not schedule the transmission procedure. + * @retval true If the transmission procedure was scheduled. + * @retval false If the driver could not schedule the transmission procedure. */ bool nrf_802154_transmit(const uint8_t * p_data, uint8_t length, bool cca); #endif // NRF_802154_USE_RAW_API /** - * @brief Change radio state to Energy Detection. + * @brief Change radio state to energy detection. * - * In Energy Detection state radio detects maximum energy for given time. Result of the detection - * is reported to the higher layer by @sa nrf_802154_energy_detected() call. + * In energy detection state, the radio detects the maximum energy for a given time. The result of the detection + * is reported to the higher layer by @ref nrf_802154_energy_detected. * - * @note @sa nrf_802154_energy_detected() may be called before nrf_802154_energy_detection() - * returns result. - * @note Performing Energy Detection procedure make take longer than time requested in @p time_us. - * Procedure is performed only during timeslots granted by a radio arbiter. It may be - * interrupted by other protocols using radio hardware. If procedure is interrupted, it is + * @note @ref nrf_802154_energy_detected may be called before this function returns a result. + * @note Performing the energy detection procedure make take longer time than requested in @p time_us. + * The procedure is performed only during timeslots granted by a radio arbiter. It may be + * interrupted by other protocols using the radio hardware. If the procedure is interrupted, it is * automatically continued and the sum of time periods during which the procedure is carried - * out is not less than requested @p time_us. + * out is not less than the requested @p time_us. * - * @param[in] time_us Duration of energy detection procedure. Given value is rounded up to + * @param[in] time_us Duration of energy detection procedure. The given value is rounded up to * multiplication of 8s (128 us). * - * @return true If the energy detection procedure was scheduled. - * @return false If the driver could not schedule the energy detection procedure. + * @retval true If the energy detection procedure was scheduled. + * @retval false If the driver could not schedule the energy detection procedure. */ bool nrf_802154_energy_detection(uint32_t time_us); /** * @brief Change radio state to CCA. * - * @note @sa nrf_802154_cca_done() may be called before nrf_802154_cca() returns result. + * @note @ref nrf_802154_cca_done may be called before this function returns a result. * - * In CCA state radio verifies if channel is clear. Result of verification is reported to the higher - * layer by @sa nrf_802154_cca_done() call. + * In CCA state, the radio verifies if the channel is clear. The result of the verification is reported to the higher + * layer by @ref nrf_802154_cca_done. * - * @return true If the CCA procedure was scheduled. - * @return false If the driver could not schedule the CCA procedure. + * @retval true If the CCA procedure was scheduled. + * @retval false If the driver could not schedule the CCA procedure. */ bool nrf_802154_cca(void); /** - * @brief Change radio state to Continuous Carrier. + * @brief Change radio state to continuous carrier. * - * @note When radio is emitting continuous carrier it blocks all transmissions on selected channel. + * @note When the radio is emitting continuous carrier signals, it blocks all transmissions on the selected channel. * This function should be called only during radio tests. It should not be used during * normal device operation. - * @note This function works correctly only with a single-phy arbiter. It should not be used with + * @note This function works correctly only with a single-PHY arbiter. It should not be used with * any other arbiter. * - * @return true If the continuous carrier procedure was scheduled. - * @return false If the driver could not schedule the continuous carrier procedure. + * @retval true If the continuous carrier procedure was scheduled. + * @retval false If the driver could not schedule the continuous carrier procedure. */ bool nrf_802154_continuous_carrier(void); -/*************************************************************************************************** - * @section Calls to higher layer. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_calls Calls to higher layer + * @{ + */ /** - * @brief Notify that transmitting ACK frame has started. + * @brief Notify that transmitting the ACK frame has started. * * @note This function should be very short to prevent dropping frames by the driver. */ @@ -393,13 +405,14 @@ extern void nrf_802154_tx_ack_started(void); #if NRF_802154_USE_RAW_API /** - * @brief Notify that frame was received. + * @brief Notify that a frame was received. * - * @note Buffer pointed by the p_data pointer is not modified by the radio driver (and can't - * be used to receive a frame) until @sa nrf_802154_buffer_free_raw() function is called. - * @note Buffer pointed by the p_data pointer may be modified by the function handler (and other - * modules) until @sa nrf_802154_buffer_free_raw() function is called. + * @note The buffer pointed to by @p p_data is not modified by the radio driver (and cannot + * be used to receive a frame) until @ref nrf_802154_buffer_free_raw is called. + * @note The buffer pointed to by @p p_data may be modified by the function handler (and other + * modules) until @ref nrf_802154_buffer_free_raw is called. * + * @verbatim * p_data * v * +-----+-----------------------------------------------------------+------------+ @@ -407,10 +420,11 @@ extern void nrf_802154_tx_ack_started(void); * +-----+-----------------------------------------------------------+------------+ * | | * | <---------------------------- PHR -----------------------------------> | + * @endverbatim * * @param[in] p_data Pointer to the buffer containing received data (PHR + PSDU). First byte in - * the buffer is length of the frame (PHR) and following bytes is the frame - * itself (PSDU). Length byte (PHR) includes FCS. FCS is already verified by + * the buffer is length of the frame (PHR). The following bytes contain the frame + * itself (PSDU). The length byte (PHR) includes FCS. FCS is already verified by * the hardware and may be modified by the hardware. * @param[in] power RSSI of received frame. * @param[in] lqi LQI of received frame. @@ -420,13 +434,14 @@ extern void nrf_802154_received_raw(uint8_t * p_data, int8_t power, uint8_t lqi) #else // NRF_802154_USE_RAW_API /** - * @brief Notify that frame was received. + * @brief Notify that a frame was received. * - * @note Buffer pointed by the p_data pointer is not modified by the radio driver (and can't - * be used to receive a frame) until nrf_802154_buffer_free() function is called. - * @note Buffer pointed by the p_data pointer may be modified by the function handler (and other - * modules) until @sa nrf_802154_buffer_free() function is called. + * @note The buffer pointed to by @p p_data is not modified by the radio driver (and cannot + * be used to receive a frame) until @ref nrf_802154_buffer_free is called. + * @note The buffer pointed to by @p p_data may be modified by the function handler (and other + * modules) until @ref nrf_802154_buffer_free is called. * + * @verbatim * p_data * v * +-----+-----------------------------------------------------------+------------+ @@ -434,8 +449,9 @@ extern void nrf_802154_received_raw(uint8_t * p_data, int8_t power, uint8_t lqi) * +-----+-----------------------------------------------------------+------------+ * | | * | <------------------ length -----------------------------> | + * @endverbatim * - * @param[in] p_data Pointer to the buffer containing payload of received frame (PSDU without FCS). + * @param[in] p_data Pointer to the buffer containing the payload of the received frame (PSDU without FCS). * @param[in] length Length of received payload. * @param[in] power RSSI of received frame. * @param[in] lqi LQI of received frame. @@ -447,24 +463,24 @@ extern void nrf_802154_received(uint8_t * p_data, uint8_t length, int8_t power, #if NRF_802154_FRAME_TIMESTAMP_ENABLED #if NRF_802154_USE_RAW_API /** - * @brief Notify that frame was received at given time + * @brief Notify that a frame was received at a given time. * - * This functions works like @sa nrf_802154_received_raw and adds timestamp to parameter + * This functions works like @ref nrf_802154_received_raw and adds a timestamp to the parameter * list. * - * @note @p timestamp may be inacurate due to software latency (IRQ handling). - * @note @p timestamp granularity depends on granularity of the timer driver in platform/timer + * @note @p timestamp may be inaccurate due to software latency (IRQ handling). + * @note @p timestamp granularity depends on the granularity of the timer driver in the platform/timer * directory. - * @note Including timestamp to received frame uses resources like CPU time and memory. If timestamp - * is not required use @sa nrf_802154_received_raw() instead. + * @note Including the timestamp for received frames uses resources like CPU time and memory. If the timestamp + * is not required, use @ref nrf_802154_received_raw instead. * * @param[in] p_data Pointer to the buffer containing received data (PHR + PSDU). First byte in - * the buffer is length of the frame (PHR) and following bytes is the frame - * itself (PSDU). Length byte (PHR) includes FCS. FCS is already verified by + * the buffer is length of the frame (PHR). The following bytes contain the frame + * itself (PSDU). The length byte (PHR) includes FCS. FCS is already verified by * the hardware and may be modified by the hardware. * @param[in] power RSSI of received frame. * @param[in] lqi LQI of received frame. - * @param[in] time Timestamp taken when last symbol of the frame was received (in us). + * @param[in] time Timestamp taken when the last symbol of the frame was received (in us). */ extern void nrf_802154_received_timestamp_raw(uint8_t * p_data, int8_t power, @@ -474,21 +490,21 @@ extern void nrf_802154_received_timestamp_raw(uint8_t * p_data, #else // NRF_802154_USE_RAW_API /** - * @brief Notify that frame was received at given time + * @brief Notify that a frame was received at a given time. * - * This functions works like @sa nrf_802154_received and adds timestamp to parameter list. + * This functions works like @ref nrf_802154_received and adds a timestamp to the parameter list. * - * @note @p timestamp may be inacurate due to software latency (IRQ handling). - * @note @p timestamp granularity depends on granularity of the timer driver in platform/timer + * @note @p timestamp may be inaccurate due to software latency (IRQ handling). + * @note @p timestamp granularity depends on the granularity of the timer driver in the platform/timer * directory. - * @note Including timestamp to received frame uses resources like CPU time and memory. If timestamp - * is not required use @sa nrf_802154_received instead(). + * @note Including the timestamp for received frames uses resources like CPU time and memory. If the timestamp + * is not required, use @ref nrf_802154_received instead. * - * @param[in] p_data Pointer to the buffer containing payload of received frame (PSDU without FCS). + * @param[in] p_data Pointer to the buffer containing the payload of the received frame (PSDU without FCS). * @param[in] length Length of received payload. * @param[in] power RSSI of received frame. * @param[in] lqi LQI of received frame. - * @param[in] time Timestamp taken when last symbol of the frame was received (in us). + * @param[in] time Timestamp taken when the last symbol of the frame was received (in us). */ extern void nrf_802154_received_timestamp(uint8_t * p_data, uint8_t length, @@ -502,41 +518,41 @@ extern void nrf_802154_received_timestamp(uint8_t * p_data, /** * @brief Notify that reception of a frame failed. * - * @param[in] error An error code that indicates reason of the failure. + * @param[in] error An error code that indicates the reason of the failure. */ extern void nrf_802154_receive_failed(nrf_802154_rx_error_t error); /** - * @brief Notify that transmitting frame has started. + * @brief Notify that transmitting a frame has started. * - * @note It is possible that transmit procedure is interrupted and - * @sa nrf_802154_transmitted won't be called. + * @note Usually, @ref nrf_802154_transmitted is called shortly after this function. + * However, if the transmit procedure is interrupted, it might happen that + * @ref nrf_802154_transmitted is not called. * @note This function should be very short to prevent dropping frames by the driver. * - * @param[in] p_frame Pointer to buffer containing PSDU of the frame being transmitted. + * @param[in] p_frame Pointer to the buffer containing PSDU of the frame being transmitted. */ extern void nrf_802154_tx_started(const uint8_t * p_frame); #if NRF_802154_USE_RAW_API /** - * @brief Notify that frame was transmitted. + * @brief Notify that a frame was transmitted. * - * @note If ACK was requested for transmitted frame this function is called after proper ACK is - * received. If ACK was not requested this function is called just after transmission is + * @note If ACK was requested for the transmitted frame, this function is called after a proper ACK is + * received. If ACK was not requested, this function is called just after transmission has * ended. - * @note Buffer pointed by the @p p_ack pointer is not modified by the radio driver (and can't - * be used to receive a frame) until @sa nrf_802154_buffer_free_raw() function is - * called. - * @note Buffer pointed by the @p p_ack pointer may be modified by the function handler (and other - * modules) until @sa nrf_802154_buffer_free_raw() function is called. + * @note The buffer pointed to by @p p_ack is not modified by the radio driver (and cannot + * be used to receive a frame) until @ref nrf_802154_buffer_free_raw is called. + * @note The buffer pointed to by @p p_ack may be modified by the function handler (and other + * modules) until @ref nrf_802154_buffer_free_raw is called. * - * @param[in] p_frame Pointer to buffer containing PHR and PSDU of transmitted frame. - * @param[in] p_ack Pointer to received ACK buffer. Fist byte in the buffer is length of the - * frame (PHR) and following bytes are the ACK frame itself (PSDU). Length byte + * @param[in] p_frame Pointer to the buffer containing PHR and PSDU of the transmitted frame. + * @param[in] p_ack Pointer to the received ACK buffer. First byte in the buffer is the length of the + * frame (PHR). The following bytes contain the ACK frame itself (PSDU). The length byte * (PHR) includes FCS. FCS is already verified by the hardware and may be * modified by the hardware. - * If ACK was not requested @p p_ack is set to NULL. + * If ACK was not requested, @p p_ack is set to NULL. * @param[in] power RSSI of received frame or 0 if ACK was not requested. * @param[in] lqi LQI of received frame or 0 if ACK was not requested. */ @@ -548,23 +564,23 @@ extern void nrf_802154_transmitted_raw(const uint8_t * p_frame, #else // NRF_802154_USE_RAW_API /** - * @brief Notify that frame was transmitted. + * @brief Notify that a frame was transmitted. * - * @note If ACK was requested for transmitted frame this function is called after proper ACK is - * received. If ACK was not requested this function is called just after transmission is + * @note If ACK was requested for the transmitted frame, this function is called after a proper ACK is + * received. If ACK was not requested, this function is called just after transmission has * ended. - * @note Buffer pointed by the @p p_ack pointer is not modified by the radio driver (and can't - * be used to receive a frame) until @sa nrf_802154_buffer_free() function is + * @note The buffer pointed to by @p p_ack is not modified by the radio driver (and cannot + * be used to receive a frame) until @ref nrf_802154_buffer_free is * called. - * @note Buffer pointed by the @p p_ack pointer may be modified by the function handler (and other - * modules) until @sa nrf_802154_buffer_free() function is called. - * @note The next higher layer should handle @sa nrf_802154_transmitted() or - * @sa nrf_802154_transmitted_raw() function. It should not handle both. + * @note The buffer pointed to by @p p_ack may be modified by the function handler (and other + * modules) until @ref nrf_802154_buffer_free is called. + * @note The next higher layer should handle either @ref nrf_802154_transmitted or + * @ref nrf_802154_transmitted_raw. It should not handle both functions. * - * @param[in] p_frame Pointer to buffer containing PSDU of transmitted frame. - * @param[in] p_ack Pointer to buffer containing received ACK payload (PHR excluding FCS). - * If ACK was not requested @p p_ack is set to NULL. - * @param[in] length Length of received ACK payload or 0 if ACK was not requested. + * @param[in] p_frame Pointer to the buffer containing PSDU of the transmitted frame. + * @param[in] p_ack Pointer to the buffer containing the received ACK payload (PHR excluding FCS). + * If ACK was not requested, @p p_ack is set to NULL. + * @param[in] length Length of the received ACK payload or 0 if ACK was not requested. * @param[in] power RSSI of received frame or 0 if ACK was not requested. * @param[in] lqi LQI of received frame or 0 if ACK was not requested. */ @@ -580,26 +596,26 @@ extern void nrf_802154_transmitted(const uint8_t * p_frame, #if NRF_802154_USE_RAW_API /** - * @brief Notify that frame was transmitted. + * @brief Notify that a frame was transmitted. * - * This functions works like @sa nrf_802154_transmitted_raw and adds timestamp to parameter + * This functions works like @ref nrf_802154_transmitted_raw and adds a timestamp to the parameter * list. * - * @note @p timestamp may be inacurate due to software latency (IRQ handling). - * @note @p timestamp granularity depends on granularity of the timer driver in platform/timer + * @note @p timestamp may be inaccurate due to software latency (IRQ handling). + * @note @p timestamp granularity depends on the granularity of the timer driver in the platform/timer * directory. - * @note Including timestamp to received frame uses resources like CPU time and memory. If timestamp - * is not required use @sa nrf_802154_received instead. + * @note Including a timestamp for received frames uses resources like CPU time and memory. If the timestamp + * is not required, use @ref nrf_802154_received instead. * - * @param[in] p_frame Pointer to buffer containing PSDU of transmitted frame. - * @param[in] p_ack Pointer to received ACK buffer. Fist byte in the buffer is length of the - * frame (PHR) and following bytes are the ACK frame itself (PSDU). Length byte + * @param[in] p_frame Pointer to the buffer containing PSDU of the transmitted frame. + * @param[in] p_ack Pointer to the received ACK buffer. First byte in the buffer is the length of the + * frame (PHR). The following bytes contain the ACK frame itself (PSDU). The length byte * (PHR) includes FCS. FCS is already verified by the hardware and may be * modified by the hardware. - * If ACK was not requested @p p_ack is set to NULL. + * If ACK was not requested, @p p_ack is set to NULL. * @param[in] power RSSI of received frame or 0 if ACK was not requested. * @param[in] lqi LQI of received frame or 0 if ACK was not requested. - * @param[in] time Timestamp taken when received last symbol of ACK or 0 if ACK was not + * @param[in] time Timestamp taken when the last symbol of ACK is received or 0 if ACK was not * requested. */ extern void nrf_802154_transmitted_timestamp_raw(const uint8_t * p_frame, @@ -611,24 +627,24 @@ extern void nrf_802154_transmitted_timestamp_raw(const uint8_t * p_frame, #else // NRF_802154_USE_RAW_API /** - * @brief Notify that frame was transmitted. + * @brief Notify that a frame was transmitted. * - * This functions works like @sa nrf_802154_transmitted and adds timestamp to parameter + * This functions works like @ref nrf_802154_transmitted and adds a timestamp to the parameter * list. * - * @note @p timestamp may be inacurate due to software latency (IRQ handling). - * @note @p timestamp granularity depends on granularity of the timer driver in platform/timer + * @note @p timestamp may be inaccurate due to software latency (IRQ handling). + * @note @p timestamp granularity depends on the granularity of the timer driver in the platform/timer * directory. - * @note Including timestamp to received frame uses resources like CPU time and memory. If timestamp - * is not required use @sa nrf_802154_received instead. + * @note Including a timestamp for received frames uses resources like CPU time and memory. If the timestamp + * is not required, use @ref nrf_802154_received instead. * - * @param[in] p_frame Pointer to buffer containing PSDU of transmitted frame. - * @param[in] p_ack Pointer to buffer containing received ACK payload (PHR excluding FCS). - * If ACK was not requested @p p_ack is set to NULL. - * @param[in] length Length of received ACK payload. + * @param[in] p_frame Pointer to the buffer containing PSDU of the transmitted frame. + * @param[in] p_ack Pointer to the buffer containing the received ACK payload (PHR excluding FCS). + * If ACK was not requested, @p p_ack is set to NULL. + * @param[in] length Length of the received ACK payload. * @param[in] power RSSI of received frame or 0 if ACK was not requested. * @param[in] lqi LQI of received frame or 0 if ACK was not requested. - * @param[in] time Timestamp taken when received last symbol of ACK or 0 if ACK was not + * @param[in] time Timestamp taken when the last symbol of ACK is received or 0 if ACK was not * requested. */ extern void nrf_802154_transmitted_timestamp(const uint8_t * p_frame, @@ -642,61 +658,63 @@ extern void nrf_802154_transmitted_timestamp(const uint8_t * p_frame, #endif // NRF_802154_FRAME_TIMESTAMP_ENABLED /** - * @brief Notify that frame was not transmitted due to busy channel. + * @brief Notify that a frame was not transmitted due to busy channel. * - * This function is called if transmission procedure fails. + * This function is called if the transmission procedure fails. * - * @param[in] p_frame Pointer to buffer containing PSDU of frame that was not transmitted. + * @param[in] p_frame Pointer to the buffer containing PSDU of the frame that was not transmitted. * @param[in] error Reason of the failure. */ extern void nrf_802154_transmit_failed(const uint8_t * p_frame, nrf_802154_tx_error_t error); /** - * @brief Notify that Energy Detection procedure finished. + * @brief Notify that the energy detection procedure finished. * - * @note This function passes EnergyLevel defined in 802.15.4-2006 specification: + * @note This function passes the EnergyLevel defined in the 802.15.4-2006 specification: * 0x00 - 0xff proportional to detected energy level (dBm above receiver sensitivity). To - * calculate result in dBm use @sa nrf_802154_dbm_from_energy_level_calculate(). + * calculate the result in dBm, use @ref nrf_802154_dbm_from_energy_level_calculate. * - * @param[in] result Maximum energy detected during Energy Detection procedure. + * @param[in] result Maximum energy detected during the energy detection procedure. */ extern void nrf_802154_energy_detected(uint8_t result); /** - * @brief Notify that Energy Detection procedure failed. + * @brief Notify that the energy detection procedure failed. * * @param[in] error Reason of the failure. */ extern void nrf_802154_energy_detection_failed(nrf_802154_ed_error_t error); /** - * @brief Notify that CCA procedure has finished. + * @brief Notify that the CCA procedure has finished. * * @param[in] channel_free Indication if channel is free. */ extern void nrf_802154_cca_done(bool channel_free); /** - * @brief Notify that CCA procedure failed. + * @brief Notify that the CCA procedure failed. * * @param[in] error Reason of the failure. */ extern void nrf_802154_cca_failed(nrf_802154_cca_error_t error); -/*************************************************************************************************** - * @section Driver memory management - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_memman Driver memory management + * @{ + */ #if NRF_802154_USE_RAW_API /** - * @brief Notify driver that buffer containing received frame is not used anymore. + * @brief Notify the driver that the buffer containing the received frame is not used anymore. * - * @note The buffer pointed by the @p p_data pointer may be modified by this function. + * @note The buffer pointed to by @p p_data may be modified by this function. * - * @param[in] p_data A pointer to the buffer containing received data that is no more needed by + * @param[in] p_data A pointer to the buffer containing the received data that is no longer needed by * the higher layer. */ void nrf_802154_buffer_free_raw(uint8_t * p_data); @@ -704,11 +722,11 @@ void nrf_802154_buffer_free_raw(uint8_t * p_data); #else // NRF_802154_USE_RAW_API /** - * @brief Notify driver that buffer containing received frame is not used anymore. + * @brief Notify the driver that the buffer containing the received frame is not used anymore. * - * @note The buffer pointed by the @p p_data pointer may be modified by this function. + * @note The buffer pointed to by @p p_data may be modified by this function. * - * @param[in] p_data A pointer to the buffer containing received data that is no more needed by + * @param[in] p_data A pointer to the buffer containing the received data that is no longer needed by * the higher layer. */ void nrf_802154_buffer_free(uint8_t * p_data); @@ -716,58 +734,52 @@ void nrf_802154_buffer_free(uint8_t * p_data); #endif // NRF_802154_USE_RAW_API -/*************************************************************************************************** - * @section RSSI measurement function. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_rssi RSSI measurement function + * @{ + */ /** * @brief Begin RSSI measurement. * - * @note This function should be called in Receive state. + * @note This function should be called in receive state. * - * Begin RSSI measurement. The result will be available in 8 uS. The result can be read by - * @sa nrf_radio802154_rssi_last_get() function. + * The result will be available after 8 us and can be read by + * @ref nrf_802154_rssi_last_get. */ void nrf_802154_rssi_measure(void); /** - * @brief Get result of last RSSI measurement. + * @brief Get the result of the last RSSI measurement. * * @returns RSSI measurement result [dBm]. */ int8_t nrf_802154_rssi_last_get(void); + /** - * @brief Adjust given RSSI measurement using a temperature correction factor. - * - * @param[in] rssi Measured RSSI value [dBm]. - * @param[in] temp Temperature value when RSSI sample took place [C]. - * - * @returns RSSI [dBm] corrected by a temperature factor (Errata 153). + * @} + * @defgroup nrf_802154_prom Promiscuous mode + * @{ */ -int8_t nrf_802154_rssi_corrected_get(int8_t rssi, int8_t temp); - - -/*************************************************************************************************** - * @section Promiscuous mode. - **************************************************************************************************/ /** * @brief Enable or disable promiscuous radio mode. * * @note Promiscuous mode is disabled by default. * - * In promiscuous mode driver notifies higher layer that it received any frame (regardless + * In promiscuous mode, the driver notifies the higher layer that it received any frame (regardless * frame type or destination address). - * In normal mode (not promiscuous) higher layer is not notified about ACK frames and frames with - * unknown type. Also frames with destination address not matching this device address are ignored. + * In normal mode (not promiscuous), the higher layer is not notified about ACK frames and frames with + * unknown type. Also frames with a destination address not matching the device address are ignored. * * @param[in] enabled If promiscuous mode should be enabled. */ void nrf_802154_promiscuous_set(bool enabled); /** - * @brief Check if radio is in promiscuous mode. + * @brief Check if the radio is in promiscuous mode. * * @retval True Radio is in promiscuous mode. * @retval False Radio is not in promiscuous mode. @@ -775,129 +787,134 @@ void nrf_802154_promiscuous_set(bool enabled); bool nrf_802154_promiscuous_get(void); -/*************************************************************************************************** - * @section Auto ACK management. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_autoack Auto ACK management + * @{ + */ /** - * @brief Enable or disable auto ACK procedure. + * @brief Enable or disable automatic acknowledgments. * - * @note Auto ACK procedure is enabled by default. + * @note Auto ACK is enabled by default. * - * If auto ACK procedure is enabled the driver prepares and sends ACK frames automatically - * aTurnaroundTime (192 us) after proper frame is received. The driver sets sequence number in - * the ACK frame and pending bit according to auto pending bit feature settings. When auto ACK - * procedure is enabled the driver notifies the next higher layer about received frame after ACK + * If auto ACK is enabled, the driver prepares and sends ACK frames automatically + * aTurnaroundTime (192 us) after the proper frame is received. The driver sets the sequence number in + * the ACK frame and a pending bit according to the auto pending bit feature settings. When auto ACK + * is enabled, the driver notifies the next higher layer about the received frame after the ACK * frame is transmitted. - * If auto ACK procedure is disabled the driver does not transmit ACK frames. It notifies the next - * higher layer about received frame when a frame is received. In this mode the next higher layer - * is responsible for sending ACK frame. ACK frames should be sent using @sa nrf_802154_transmit() - * function. + * If auto ACK is disabled, the driver does not transmit ACK frames. It notifies the next + * higher layer about received frames when a frame is received. In this mode, the next higher layer + * is responsible for sending the ACK frame. ACK frames should be sent using @ref nrf_802154_transmit. * - * @param[in] enabled If auto ACK procedure should be enabled. + * @param[in] enabled If auto ACK should be enabled. */ void nrf_802154_auto_ack_set(bool enabled); /** - * @brief Check if auto ACK procedure is enabled. + * @brief Check if auto ACK is enabled. * - * @retval True Auto ACK procedure is enabled. - * @retval False Auto ACK procedure is disabled. + * @retval True Auto ACK is enabled. + * @retval False Auto ACK is disabled. */ bool nrf_802154_auto_ack_get(void); /** * @brief Enable or disable setting pending bit in automatically transmitted ACK frames. * - * @note Setting pending bit in automatically transmitted ACK frames is enabled by default. + * @note Setting a pending bit in automatically transmitted ACK frames is enabled by default. * - * Radio driver automatically sends ACK frames in response frames destined to this node with Ack - * Request bit set. Pending bit in ACK frame can be set or cleared regarding data in indirect queue + * The radio driver automatically sends ACK frames in response frames destined to this node with the ACK + * Request bit set. The pending bit in the ACK frame can be set or cleared regarding data in the indirect queue * destined to ACK destination. * - * If setting pending bit in ACK frames is disabled, pending bit in every ACK frame is set. - * If setting pending bit in ACK frames is enabled, radio driver checks if there is data - * in indirect queue destined to ACK destination. If there is no such data, pending bit is cleared. + * If setting a pending bit in ACK frames is disabled, the pending bit in every ACK frame is set. + * If setting a pending bit in ACK frames is enabled, the radio driver checks if there is data + * in the indirect queue destined to ACK destination. If there is no such data, the pending bit is cleared. * - * @note It is possible that due to ISR latency, radio driver cannot verify if there is data in - * indirect queue before ACK is sent. In this case pending bit is set. + * @note Due to ISR latency, the radio driver might not be able to verify if there is data in + * the indirect queue before ACK is sent. In this case, the pending bit is set. * - * @param[in] enabled If setting pending bit in ACK frames is enabled. + * @param[in] enabled If setting a pending bit in ACK frames is enabled. */ void nrf_802154_auto_pending_bit_set(bool enabled); /** - * @brief Add address of peer node for which there is pending data in the buffer. + * @brief Add address of a peer node for which there is pending data in the buffer. * - * @note This function makes a copy of given address. + * @note This function makes a copy of the given address. * - * @param[in] p_addr Array of bytes containing address of the node (little-endian). - * @param[in] extended If given address is Extended MAC Address or Short MAC Address. + * @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 Address successfully added to the list. - * @retval False There is not enough memory to store this address in the list. + * @retval True If the address is successfully added to the list. + * @retval False If there is 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); /** - * @brief Remove address of peer node for which there is no more pending data in the buffer. + * @brief Remove address of a peer node for which there is no more pending data in the buffer. * - * @param[in] p_addr Array of bytes containing address of the node (little-endian). - * @param[in] extended If given address is Extended MAC Address or Short MAC Address. + * @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 Address successfully removed from the list. - * @retval False There is no such address in the list. + * @retval True If the address is successfully removed from the list. + * @retval False If there is no such address in the list. */ bool nrf_802154_pending_bit_for_addr_clear(const uint8_t *p_addr, bool extended); /** - * @brief Remove all addresses of given type from pending bit list. + * @brief Remove all addresses of a given type from the pending bit list. * - * @param[in] extended If function should remove all Exnteded MAC Adresses of all Short Addresses. + * @param[in] extended If the function should remove all extended MAC addresses or all short addresses. */ void nrf_802154_pending_bit_for_addr_reset(bool extended); -/*************************************************************************************************** - * @section CCA configuration management. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_cca CCA configuration management + * @{ + */ /** * @brief Configure radio CCA mode and threshold. * * @param[in] p_cca_cfg A pointer to the CCA configuration structure. Only fields relevant to - * selected mode are updated. + * the selected mode are updated. */ void nrf_802154_cca_cfg_set(const nrf_802154_cca_cfg_t * p_cca_cfg); /** - * @brief Get current radio CCA configuration + * @brief Get current radio CCA configuration. * - * @param[out] p_cca_cfg A pointer to the structure for current CCA configuration. + * @param[out] p_cca_cfg A pointer to the structure for the current CCA configuration. */ void nrf_802154_cca_cfg_get(nrf_802154_cca_cfg_t * p_cca_cfg); -/*************************************************************************************************** - * @section CSMA-CA procedure. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_csma CSMA-CA procedure + * @{ + */ #if NRF_802154_CSMA_CA_ENABLED #if NRF_802154_USE_RAW_API /** * @brief Perform CSMA-CA procedure and transmit frame in case of success. * - * End of CSMA-CA procedure is notified by @sa nrf_802154_transmitted_raw() or - * @sa nrf_802154_transmit_failed() function. + * The end of the CSMA-CA procedure is notified by @ref nrf_802154_transmitted_raw or + * @ref nrf_802154_transmit_failed. * - * @note The driver may be configured to automatically time out waiting for ACK frame depending on - * @sa NRF_802154_ACK_TIMEOUT_ENABLED configuration option. If automatic ACK timeout is - * disabled, CSMA-CA procedure does not time out waiting for ACK frame in case frame with ACK - * request bit set was transmitted. MAC layer should manage timer to time out waiting for ACK - * frame. This timer may be started by @sa nrf_802154_tx_started() function. When the timer - * expires MAC layer should call @sa nrf_802154_receive() or @sa nrf_802154_sleep() to stop - * waiting for ACK frame. - * @note Before CSMA-CA procedure is used, application should initialize random seed with srand(). + * @note The driver may be configured to automatically time out waiting for an ACK frame depending on + * @ref NRF_802154_ACK_TIMEOUT_ENABLED. If automatic ACK time-out is + * disabled, the CSMA-CA procedure does not time out waiting for an ACK frame if a frame with the ACK + * request bit set was transmitted. The MAC layer should manage the timer to time out waiting for the ACK + * frame. This timer can be started by @ref nrf_802154_tx_started. When the timer + * expires, the MAC layer should call @ref nrf_802154_receive or @ref nrf_802154_sleep to stop + * waiting for the ACK frame. + * @note Before the CSMA-CA procedure is used, the application should initialize a random seed with srand. * - * @param[in] p_data Pointer to frame to transmit. @sa nrf_802154_transmit_raw() + * @param[in] p_data Pointer to the frame to transmit. See also @ref nrf_802154_transmit_raw. */ void nrf_802154_transmit_csma_ca_raw(const uint8_t * p_data); @@ -906,46 +923,52 @@ void nrf_802154_transmit_csma_ca_raw(const uint8_t * p_data); /** * @brief Perform CSMA-CA procedure and transmit frame in case of success. * - * End of CSMA-CA procedure is notified by @sa nrf_802154_transmitted() or - * @sa nrf_802154_transmit_failed() function. + * The end of the CSMA-CA procedure is notified by @ref nrf_802154_transmitted or + * @ref nrf_802154_transmit_failed. * - * @note The driver may be configured to automatically time out waiting for ACK frame depending on - * @sa NRF_802154_ACK_TIMEOUT_ENABLED configuration option. If automatic ACK timeout is - * disabled, CSMA-CA procedure does not time out waiting for ACK frame in case frame with ACK - * request bit set was transmitted. MAC layer should manage timer to time out waiting for ACK - * frame. This timer may be started by @sa nrf_802154_tx_started() function. When the timer - * expires MAC layer should call @sa nrf_802154_receive() or @sa nrf_802154_sleep() to stop - * waiting for ACK frame. - * @note Before CSMA-CA procedure is used, application should initialize random seed with srand(). + * @note The driver may be configured to automatically time out waiting for an ACK frame depending on + * @ref NRF_802154_ACK_TIMEOUT_ENABLED. If automatic ACK time-out is + * disabled, the CSMA-CA procedure does not time out waiting for an ACK frame if a frame with the ACK + * request bit set was transmitted. The MAC layer should manage the timer to time out waiting for the ACK + * frame. This timer can be started by @ref nrf_802154_tx_started. When the timer + * expires, the MAC layer should call @ref nrf_802154_receive or @ref nrf_802154_sleep to stop + * waiting for the ACK frame. + * @note Before the CSMA-CA procedure is used, the application should initialize a random seed with srand. * - * @param[in] p_data Pointer to frame to transmit. @sa nrf_802154_transmit() - * @param[in] length Length of given frame. @sa nrf_802154_transmit() + * @param[in] p_data Pointer to the frame to transmit. See also @ref nrf_802154_transmit. + * @param[in] length Length of the given frame. See also @ref nrf_802154_transmit. */ void nrf_802154_transmit_csma_ca(const uint8_t * p_data, uint8_t length); #endif // NRF_802154_USE_RAW_API #endif // NRF_802154_CSMA_CA_ENABLED -/*************************************************************************************************** - * @section ACK timeout procedure. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_timeout ACK time-out procedure + * @{ + */ #if NRF_802154_ACK_TIMEOUT_ENABLED /** - * @brief Set timeout time for ACK timeout feature. + * @brief Set time-out for the ACK time-out feature. * - * Timeout is notified by @sa nrf_802154_transmit_failed() function. + * A time-out is notified by @ref nrf_802154_transmit_failed. * - * @param[in] time Timeout time in us. Timeout is started at the beginning of frame transmission - * (after transmission of PHR). Default value is defined in nrf_802154_config.h - * @sa NRF_802154_ACK_TIMEOUT_DEFAULT_TIMEOUT . + * @param[in] time Time-out in us. The time-out is started at the beginning of frame transmission + * (after transmission of PHR). A default value is defined in nrf_802154_config.h + * (@ref NRF_802154_ACK_TIMEOUT_DEFAULT_TIMEOUT). */ void nrf_802154_ack_timeout_set(uint32_t time); #endif // NRF_802154_ACK_TIMEOUT_ENABLED +/** @} */ + #ifdef __cplusplus } #endif #endif /* NRF_802154_H_ */ + +/** @} */ diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_config.h b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_config.h index b35fd7b53..bea42e28c 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_config.h +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_config.h @@ -45,17 +45,18 @@ extern "C" { * @defgroup nrf_802154_config 802.15.4 driver configuration * @{ * @ingroup nrf_802154 - * @brief Configuration of 802.15.4 radio driver for nRF SoC. + * @brief Configuration of the 802.15.4 radio driver for nRF SoCs. */ -/*************************************************************************************************** - * @section Radio Driver Configuration. - **************************************************************************************************/ +/** + * @defgroup nrf_802154_config_radio Radio driver configuration + * @{ + */ /** - * @def NRF_802154_CCA_MODE + * @def NRF_802154_CCA_MODE_DEFAULT * - * CCA Mode used by the driver. + * CCA mode used by the driver. * */ #ifndef NRF_802154_CCA_MODE_DEFAULT @@ -63,9 +64,9 @@ extern "C" { #endif /** - * @def NRF_802154_CCA_ED_THRESHOLD + * @def NRF_802154_CCA_ED_THRESHOLD_DEFAULT * - * Energy Detection Threshold used in CCA procedure. + * Energy detection threshold used in CCA procedure. * */ #ifndef NRF_802154_CCA_ED_THRESHOLD_DEFAULT @@ -73,9 +74,9 @@ extern "C" { #endif /** - * @def NRF_802154_CCA_CORR_THRESHOLD + * @def NRF_802154_CCA_CORR_THRESHOLD_DEFAULT * - * Correlator Threshold used in CCA procedure. + * Correlator threshold used in CCA procedure. * */ #ifndef NRF_802154_CCA_CORR_THRESHOLD_DEFAULT @@ -83,7 +84,7 @@ extern "C" { #endif /** - * @def NRF_802154_CCA_CORR_LIMIT + * @def NRF_802154_CCA_CORR_LIMIT_DEFAULT * * Correlator limit used in CCA procedure. * @@ -96,8 +97,8 @@ extern "C" { * @def NRF_802154_INTERNAL_RADIO_IRQ_HANDLING * * If the driver should internally handle the RADIO IRQ. - * In case the driver is used in an OS the RADIO IRQ may be handled by the OS and passed to - * the driver @sa nrf_802154_radio_irq_handler(). In this case internal handling should be disabled. + * If the driver is used in an OS, the RADIO IRQ may be handled by the OS and passed to + * the driver by @ref nrf_802154_radio_irq_handler. In this case, internal handling should be disabled. */ #ifndef NRF_802154_INTERNAL_RADIO_IRQ_HANDLING @@ -114,7 +115,7 @@ extern "C" { * @def NRF_802154_IRQ_PRIORITY * * Interrupt priority for RADIO peripheral. - * It is recommended to keep IRQ priority high (low number) to prevent losing frames due to + * Keep IRQ priority high (low number) to prevent losing frames due to * preemption. * */ @@ -125,7 +126,7 @@ extern "C" { /** * @def NRF_802154_TIMER_INSTANCE * - * TIMER instance used by the driver for Ack IFS and by FEM module. + * Timer instance used by the driver for ACK IFS and by the FEM module. * */ #ifndef NRF_802154_TIMER_INSTANCE @@ -137,8 +138,8 @@ extern "C" { * * Timer instance used by the driver for detecting when PSDU is being received. * - * @note This configuration is only used when NRF_RADIO_EVENT_BCMATCH event handling is disabled - * (@sa NRF_802154_DISABLE_BCC_MATCHING). + * @note This configuration is used only when NRF_RADIO_EVENT_BCMATCH event handling is disabled + * (see @ref NRF_802154_DISABLE_BCC_MATCHING). */ #ifndef NRF_802154_COUNTER_TIMER_INSTANCE #define NRF_802154_COUNTER_TIMER_INSTANCE NRF_TIMER2 @@ -150,7 +151,7 @@ extern "C" { * SWI EGU instance used by the driver to synchronize PPIs and for requests and notifications if * SWI is in use. * - * @note This option is used by core module regardless driver configuration. + * @note This option is used by the core module regardless of the driver configuration. * */ #ifndef NRF_802154_SWI_EGU_INSTANCE @@ -194,7 +195,7 @@ extern "C" { /** * @def NRF_802154_USE_RAW_API * - * When this flag is set RAW API is available for the MAC layer. It is recommended to use RAW API, + * When this flag is set, RAW API is available for the MAC layer. It is recommended to use RAW API * because it provides more optimized functions. * * @note If RAW API is not available for the MAC layer, only less optimized functions performing @@ -236,7 +237,7 @@ extern "C" { #endif /** - * @def NRF_802154_EXCLUDE_BCC_MATCHING + * @def NRF_802154_DISABLE_BCC_MATCHING * * Setting this flag disables NRF_RADIO_EVENT_BCMATCH handling, and therefore address filtering * during frame reception. With this flag set to 1, address filtering is done after receiving @@ -250,7 +251,7 @@ extern "C" { /** * @def NRF_802154_NOTIFY_CRCERROR * - * With this flag set to 1 CRC errors would be notified to upper layers. This requires interrupt + * With this flag set to 1, CRC errors are notified to upper layers. This requires an interrupt * handler to be used. * */ @@ -262,25 +263,27 @@ extern "C" { * @def NRF_802154_FRAME_TIMESTAMP_ENABLED * * If timestamps should be added to received frames. - * Enabling this feature enables @sa nrf_802154_received_timsestamp_raw, - * @sa nrf_802154_received_timestamp, @sa nrf_802154_transmitted_timestamp_raw and - * @sa nrf_802154_transmitted_timestamp functions that add timestamps to received frames. + * Enabling this feature enables the functions @ref nrf_802154_received_timsestamp_raw, + * @ref nrf_802154_received_timestamp, @ref nrf_802154_transmitted_timestamp_raw, and + * @ref nrf_802154_transmitted_timestamp, which add timestamps to received frames. * */ #ifndef NRF_802154_FRAME_TIMESTAMP_ENABLED #define NRF_802154_FRAME_TIMESTAMP_ENABLED 1 #endif -/*************************************************************************************************** - * @section Clock Driver Configuration. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_config_clock Clock driver configuration + * @{ + */ /** * @def NRF_802154_CLOCK_IRQ_PRIORITY * * Priority of clock interrupt used in standalone clock driver implementation. * - * @note This configuration is only applicable for Clock Abstraction Layer implementation + * @note This configuration is only applicable for the Clock Abstraction Layer implementation * in nrf_802154_clock_nodrv.c. * */ @@ -289,11 +292,11 @@ extern "C" { #endif /** - * @def NRF_802154_CLOCK_IRQ_PRIORITY + * @def NRF_802154_CLOCK_LFCLK_SOURCE * - * Low frequency clock source used in standalone clock driver implementation. + * Low-frequency clock source used in standalone clock driver implementation. * - * @note This configuration is only applicable for Clock Abstraction Layer implementation + * @note This configuration is only applicable for the Clock Abstraction Layer implementation * in nrf_802154_clock_nodrv.c. * */ @@ -301,16 +304,18 @@ extern "C" { #define NRF_802154_CLOCK_LFCLK_SOURCE NRF_CLOCK_LFCLK_Xtal #endif -/*************************************************************************************************** - * @section RTC Driver Configuration. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_config_rtc RTC driver configuration + * @{ + */ /** * @def NRF_802154_RTC_IRQ_PRIORITY * * Priority of RTC interrupt used in standalone timer driver implementation. * - * @note This configuration is only applicable for Timer Abstraction Layer implementation + * @note This configuration is only applicable for the Timer Abstraction Layer implementation * in nrf_802154_timer_nodrv.c. * */ @@ -323,7 +328,7 @@ extern "C" { * * RTC instance used in standalone timer driver implementation. * - * @note This configuration is only applicable for Timer Abstraction Layer implementation + * @note This configuration is only applicable for the Timer Abstraction Layer implementation * in nrf_802154_timer_nodrv.c. * */ @@ -350,7 +355,7 @@ extern "C" { * * RTC Interrupt number used in standalone timer driver implementation. * - * @note This configuration is only applicable for Timer Abstraction Layer implementation + * @note This configuration is only applicable for the Timer Abstraction Layer implementation * in nrf_802154_timer_nodrv.c. * */ @@ -359,14 +364,16 @@ extern "C" { #endif -/*************************************************************************************************** - * @section CSMA/CA procedure configuration. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_config_csma CSMA/CA procedure configuration + * @{ + */ /** * @def NRF_802154_CSMA_CA_ENABLED * - * If CSMA-CA procedure should be enabled by the driver. Disabling CSMA-CA procedure improves + * If CSMA-CA should be enabled by the driver. Disabling CSMA-CA improves * driver performance. * */ @@ -377,8 +384,8 @@ extern "C" { /** * @def NRF_802154_CSMA_CA_MIN_BE * - * The minimum value of the backoff exponent (BE) in the CSMA-CA algorithm. - * (IEEE 802.15.4-2015: 6.2.5.1) + * The minimum value of the backoff exponent (BE) in the CSMA-CA algorithm + * (IEEE 802.15.4-2015: 6.2.5.1). * */ #ifndef NRF_802154_CSMA_CA_MIN_BE @@ -388,8 +395,8 @@ extern "C" { /** * @def NRF_802154_CSMA_CA_MAX_BE * - * The maximum value of the backoff exponent, BE, in the CSMA-CA algorithm. - * (IEEE 802.15.4-2015: 6.2.5.1) + * The maximum value of the backoff exponent, BE, in the CSMA-CA algorithm + * (IEEE 802.15.4-2015: 6.2.5.1). * */ #ifndef NRF_802154_CSMA_CA_MAX_BE @@ -399,7 +406,7 @@ extern "C" { /** * @def NRF_802154_CSMA_CA_MAX_CSMA_BACKOFFS * - * The maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel + * The maximum number of backoffs that the CSMA-CA algorithm will attempt before declaring a channel * access failure. * */ @@ -407,14 +414,16 @@ extern "C" { #define NRF_802154_CSMA_CA_MAX_CSMA_BACKOFFS 4 #endif -/*************************************************************************************************** - * @section ACK timeout feature configuration. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_config_timeout ACK time-out feature configuration + * @{ + */ /** * @def NRF_802154_ACK_TIMEOUT_ENABLED * - * If ACK timeout feature should be enabled in the driver. + * If the ACK time-out feature should be enabled in the driver. * */ #ifndef NRF_802154_ACK_TIMEOUT_ENABLED @@ -424,24 +433,26 @@ extern "C" { /** * @def NRF_802154_ACK_TIMEOUT_DEFAULT_TIMEOUT * - * Default timeout time in us for ACK timeout feature. + * Default time-out in us for the ACK time-out feature. * */ #ifndef NRF_802154_ACK_TIMEOUT_DEFAULT_TIMEOUT #define NRF_802154_ACK_TIMEOUT_DEFAULT_TIMEOUT 7000 #endif -/*************************************************************************************************** - * @section Transmission start notification feature configuration. - **************************************************************************************************/ +/** + * @} + * @defgroup nrf_802154_config_transmission Transmission start notification feature configuration + * @{ + */ /** * @def NRF_802154_TX_STARTED_NOTIFY_ENABLED * - * If notification of started transmission should be enabled in the driver. + * If notifications of started transmissions should be enabled in the driver. * - * @note This feature is enabled by default if Ack Timeout feature or CSMA-CA feature is enabled. - * These features depend on notification of transmission start. + * @note This feature is enabled by default if the ACK time-out feature or CSMA-CA is enabled. + * These features depend on notifications of transmission start. */ #ifndef NRF_802154_TX_STARTED_NOTIFY_ENABLED #if NRF_802154_ACK_TIMEOUT_ENABLED || NRF_802154_CSMA_CA_ENABLED @@ -460,3 +471,7 @@ extern "C" { #endif #endif // NRF_802154_CONFIG_H__ + +/** + *@} + **/ diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c index 92d9465d3..482b162e1 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c @@ -52,6 +52,7 @@ #include "nrf_802154_priority_drop.h" #include "nrf_802154_procedures_duration.h" #include "nrf_802154_revision.h" +#include "nrf_802154_rssi.h" #include "nrf_802154_rx_buffer.h" #include "nrf_802154_types.h" #include "fem/nrf_fem_control_api.h" @@ -222,7 +223,11 @@ static void rx_flags_clear(void) */ static int8_t rssi_last_measurement_get(void) { - return -((int8_t)nrf_radio_rssi_sample_get()); + uint8_t rssi_sample = nrf_radio_rssi_sample_get(); + + rssi_sample = nrf_802154_rssi_sample_corrected_get(rssi_sample); + + return -((int8_t)rssi_sample); } /** Get LQI of a received frame. @@ -235,6 +240,7 @@ static uint8_t lqi_get(const uint8_t * p_data) { uint32_t lqi = RX_FRAME_LQI(p_data); + lqi = nrf_802154_rssi_lqi_corrected_get(lqi); lqi *= LQI_VALUE_FACTOR; if (lqi > LQI_MAX) @@ -328,7 +334,8 @@ static void cca_configuration_update(void) nrf_802154_pib_cca_cfg_get(&cca_cfg); nrf_radio_cca_mode_set(cca_cfg.mode); - nrf_radio_cca_ed_threshold_set(cca_cfg.ed_threshold); + nrf_radio_cca_ed_threshold_set( + nrf_802154_rssi_cca_ed_threshold_corrected_get(cca_cfg.ed_threshold)); nrf_radio_cca_corr_threshold_set(cca_cfg.corr_threshold); nrf_radio_cca_corr_counter_set(cca_cfg.corr_limit); } @@ -511,7 +518,6 @@ static void irq_init(void) { NVIC_SetPriority(RADIO_IRQn, NRF_802154_IRQ_PRIORITY); NVIC_ClearPendingIRQ(RADIO_IRQn); - NVIC_EnableIRQ(RADIO_IRQn); } /** Deinitialize interrupts for radio peripheral. */ @@ -556,6 +562,7 @@ static uint8_t ed_result_get(void) { uint32_t result = m_ed_result; + result = nrf_802154_rssi_ed_corrected_get(result); result *= ED_RESULT_FACTOR; if (result > ED_RESULT_MAX) @@ -796,7 +803,9 @@ static void fem_for_tx_set(bool cca) static void fem_for_tx_reset(bool disable_ppi_egu_timer_start) { nrf_fem_control_ppi_disable(NRF_FEM_CONTROL_ANY_PIN); - nrf_fem_control_timer_reset(NRF_FEM_CONTROL_ANY_PIN, NRF_TIMER_SHORT_COMPARE0_STOP_MASK | NRF_TIMER_SHORT_COMPARE1_STOP_MASK); + nrf_fem_control_timer_reset(NRF_FEM_CONTROL_ANY_PIN, + (nrf_timer_short_mask_t) (NRF_TIMER_SHORT_COMPARE0_STOP_MASK | + NRF_TIMER_SHORT_COMPARE1_STOP_MASK)); nrf_fem_control_ppi_fork_clear(NRF_FEM_CONTROL_ANY_PIN, PPI_CCAIDLE_FEM); nrf_ppi_channel_disable(PPI_CCAIDLE_FEM); @@ -2192,7 +2201,7 @@ static void irq_end_state_rx_ack(void) if (ack_match) { - p_ack_buffer = mp_current_rx_buffer; + p_ack_buffer = mp_current_rx_buffer; mp_current_rx_buffer->free = false; } diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_debug.h b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_debug.h index fcaca9ec6..ebeea04ce 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_debug.h +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_debug.h @@ -48,6 +48,8 @@ extern "C" { #define EVENT_TRACE_EXIT 0x0002UL #define EVENT_SET_STATE 0x0005UL #define EVENT_RADIO_RESET 0x0006UL +#define EVENT_TIMESLOT_REQUEST 0x0007UL +#define EVENT_TIMESLOT_REQUEST_RESULT 0x0008UL #define FUNCTION_SLEEP 0x0001UL #define FUNCTION_RECEIVE 0x0002UL @@ -88,8 +90,11 @@ extern "C" { #define FUNCTION_RAAL_SIG_EVENT_EXTEND 0x0403UL #define FUNCTION_RAAL_SIG_EVENT_ENDED 0x0404UL #define FUNCTION_RAAL_SIG_EVENT_RADIO 0x0405UL -#define FUNCTION_RAAL_SIG_EVENT_EXCEED_SUCCESS 0x0406UL -#define FUNCTION_RAAL_SIG_EVENT_EXCEED_FAIL 0x0407UL +#define FUNCTION_RAAL_SIG_EVENT_EXTEND_SUCCESS 0x0406UL +#define FUNCTION_RAAL_SIG_EVENT_EXTEND_FAIL 0x0407UL +#define FUNCTION_RAAL_EVT_BLOCKED 0x0408UL +#define FUNCTION_RAAL_EVT_SESSION_IDLE 0x0409UL +#define FUNCTION_RAAL_EVT_HFCLK_READY 0x040AUL #define PIN_DBG_RADIO_EVT_END 11 #define PIN_DBG_RADIO_EVT_DISABLED 12 @@ -123,7 +128,7 @@ extern volatile uint32_t nrf_802154_debug_log_ptr; #else // ENABLE_DEBUG_LOG -#define nrf_802154_log(EVENT_CODE, EVENT_ARG) +#define nrf_802154_log(EVENT_CODE, EVENT_ARG) (void)(EVENT_ARG) #endif // ENABLE_DEBUG_LOG diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.c b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.c new file mode 100644 index 000000000..b9ed46853 --- /dev/null +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.c @@ -0,0 +1,96 @@ +/* Copyright (c) 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** + * @file + * This file implements RSSI calculations for 802.15.4 driver. + * + */ + +#include + +#include "platform/temperature/nrf_802154_temperature.h" + +int8_t nrf_802154_rssi_sample_temp_corr_value_get(void) +{ + int8_t temp = nrf_802154_temperature_get(); + int8_t result; + + if (temp <= -30) + { + result = 3; + } + else if (temp <= -10) + { + result = 2; + } + else if (temp <= 10) + { + result = 1; + } + else if (temp <= 30) + { + result = 0; + } + else if (temp <= 50) + { + result = -1; + } + else if (temp <= 70) + { + result = -2; + } + else + { + result = -3; + } + + return result; +} + +uint8_t nrf_802154_rssi_sample_corrected_get(uint8_t rssi_sample) +{ + return rssi_sample + nrf_802154_rssi_sample_temp_corr_value_get(); +} + +uint8_t nrf_802154_rssi_lqi_corrected_get(uint8_t lqi) +{ + return lqi - nrf_802154_rssi_sample_temp_corr_value_get(); +} + +uint8_t nrf_802154_rssi_ed_corrected_get(uint8_t ed) +{ + return ed - nrf_802154_rssi_sample_temp_corr_value_get(); +} + +uint8_t nrf_802154_rssi_cca_ed_threshold_corrected_get(uint8_t cca_ed) +{ + return cca_ed - nrf_802154_rssi_sample_temp_corr_value_get(); +} diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.h b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.h new file mode 100644 index 000000000..50932f5b9 --- /dev/null +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.h @@ -0,0 +1,90 @@ +/* Copyright (c) 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef NRF_802154_RSSI_H__ +#define NRF_802154_RSSI_H__ + +#include + +/** + * @defgroup nrf_802154_rssi RSSI calculations used internally in the 802.15.4 driver. + * @{ + * @ingroup nrf_802154 + * @brief RSSI calculations used internally in the 802.15.4 driver. + */ + +/** + * @brief Get RSSISAMPLE temperature correction value for temperature provided by platform. + * + * @returns RSSISAMPLE temperature correction value (Errata 153). + */ +int8_t nrf_802154_rssi_sample_temp_corr_value_get(void); + +/** + * @brief Adjust the given RSSISAMPLE value using a temperature correction factor. + * + * @param[in] rssi_sample Value read from RSSISAMPLE register. + * + * @returns RSSISAMPLE corrected by a temperature factor (Errata 153). + */ +uint8_t nrf_802154_rssi_sample_corrected_get(uint8_t rssi_sample); + +/** + * @brief Adjust the reported LQI value using a temperature correction factor. + * + * @param[in] lqi Value read from LQI byte. + * + * @returns LQI byte value corrected by a temperature factor (Errata 153). + */ +uint8_t nrf_802154_rssi_lqi_corrected_get(uint8_t lqi); + +/** + * @brief Adjust the EDSAMPLE value using a temperature correction factor. + * + * @param[in] ed Value read from EDSAMPLE register. + * + * @returns EDSAMPLE value corrected by a temperature factor (Errata 153). + */ +uint8_t nrf_802154_rssi_ed_corrected_get(uint8_t ed); + +/** + * @brief Adjust the CCA ED threshold value using a temperature correction factor. + * + * @param[in] cca_ed Value representing CCA ED threshold that should be corrected. + * + * @returns CCA ED threshold value corrected by a temperature factor (Errata 153). + */ +uint8_t nrf_802154_rssi_cca_ed_threshold_corrected_get(uint8_t cca_ed); + +/** + *@} + **/ + +#endif // NRF_802154_RSSI_H__ diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_types.h b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_types.h index 0de181bd8..2f1799b7b 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_types.h +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_types.h @@ -36,7 +36,7 @@ #include "hal/nrf_radio.h" /** - * @defgroup nrf_802154_types Types definitions used in the 802.15.4 driver. + * @defgroup nrf_802154_types Type definitions used in the 802.15.4 driver. * @{ * @ingroup nrf_802154 * @brief Definitions of types used in the 802.15.4 driver. @@ -47,74 +47,74 @@ */ typedef uint8_t nrf_802154_state_t; -#define NRF_802154_STATE_INVALID 0x01 /**< Radio in an invalid state. */ -#define NRF_802154_STATE_SLEEP 0x02 /**< Radio in Sleep state. */ -#define NRF_802154_STATE_RECEIVE 0x03 /**< Radio in Receive state. */ -#define NRF_802154_STATE_TRANSMIT 0x04 /**< Radio in Transmit state. */ -#define NRF_802154_STATE_ENERGY_DETECTION 0x05 /**< Radio in Energy Detection state. */ -#define NRF_802154_STATE_CCA 0x06 /**< Radio in CCA state. */ -#define NRF_802154_STATE_CONTINUOUS_CARRIER 0x07 /**< Radio in Continuous Carrier state. */ +#define NRF_802154_STATE_INVALID 0x01 //!< Radio in an invalid state. +#define NRF_802154_STATE_SLEEP 0x02 //!< Radio in sleep state. +#define NRF_802154_STATE_RECEIVE 0x03 //!< Radio in receive state. +#define NRF_802154_STATE_TRANSMIT 0x04 //!< Radio in transmit state. +#define NRF_802154_STATE_ENERGY_DETECTION 0x05 //!< Radio in energy detection state. +#define NRF_802154_STATE_CCA 0x06 //!< Radio in CCA state. +#define NRF_802154_STATE_CONTINUOUS_CARRIER 0x07 //!< Radio in continuous carrier state. /** * @brief Errors reported during frame transmission. */ typedef uint8_t nrf_802154_tx_error_t; -#define NRF_802154_TX_ERROR_NONE 0x00 /**< There is no transmit error. */ -#define NRF_802154_TX_ERROR_BUSY_CHANNEL 0x01 /**< CCA reported busy channel prior to transmission. */ -#define NRF_802154_TX_ERROR_INVALID_ACK 0x02 /**< Received ACK frame is other than expected. */ -#define NRF_802154_TX_ERROR_NO_MEM 0x03 /**< No receive buffer are available to receive an ACK. */ -#define NRF_802154_TX_ERROR_TIMESLOT_ENDED 0x04 /**< Radio timeslot ended during transmission procedure. */ -#define NRF_802154_TX_ERROR_NO_ACK 0x05 /**< ACK frame was not received during timeout period. */ -#define NRF_802154_TX_ERROR_ABORTED 0x06 /**< Procedure was aborted by other driver operation with FORCE priority. */ +#define NRF_802154_TX_ERROR_NONE 0x00 //!< There is no transmit error. +#define NRF_802154_TX_ERROR_BUSY_CHANNEL 0x01 //!< CCA reported busy channel prior to transmission. +#define NRF_802154_TX_ERROR_INVALID_ACK 0x02 //!< Received ACK frame is other than expected. +#define NRF_802154_TX_ERROR_NO_MEM 0x03 //!< No receive buffer is available to receive an ACK. +#define NRF_802154_TX_ERROR_TIMESLOT_ENDED 0x04 //!< Radio timeslot ended during transmission procedure. +#define NRF_802154_TX_ERROR_NO_ACK 0x05 //!< ACK frame was not received during time-out period. +#define NRF_802154_TX_ERROR_ABORTED 0x06 //!< Procedure was aborted by another driver operation with FORCE priority. /** * @brief Possible errors during frame reception. */ typedef uint8_t nrf_802154_rx_error_t; -#define NRF_802154_RX_ERROR_NONE 0x00 /**< There is no receive error */ -#define NRF_802154_RX_ERROR_INVALID_FRAME 0x01 /**< Received a malformed frame */ -#define NRF_802154_RX_ERROR_INVALID_FCS 0x02 /**< Received a frame with invalid checksum. */ -#define NRF_802154_RX_ERROR_INVALID_DEST_ADDR 0x03 /**< Received a frame with mismatched destination address. */ -#define NRF_802154_RX_ERROR_RUNTIME 0x04 /**< A runtime error occured (e.g. CPU was hold for too long.) */ -#define NRF_802154_RX_ERROR_TIMESLOT_ENDED 0x05 /**< Radio timeslot ended during frame reception. */ -#define NRF_802154_RX_ERROR_ABORTED 0x06 /**< Procedure was aborted by other driver operation with FORCE priority. */ +#define NRF_802154_RX_ERROR_NONE 0x00 //!< There is no receive error. +#define NRF_802154_RX_ERROR_INVALID_FRAME 0x01 //!< Received a malformed frame. +#define NRF_802154_RX_ERROR_INVALID_FCS 0x02 //!< Received a frame with invalid checksum. +#define NRF_802154_RX_ERROR_INVALID_DEST_ADDR 0x03 //!< Received a frame with mismatched destination address. +#define NRF_802154_RX_ERROR_RUNTIME 0x04 //!< A runtime error occurred (for example, CPU was held for too long). +#define NRF_802154_RX_ERROR_TIMESLOT_ENDED 0x05 //!< Radio timeslot ended during frame reception. +#define NRF_802154_RX_ERROR_ABORTED 0x06 //!< Procedure was aborted by another driver operation with FORCE priority. /** * @brief Possible errors during energy detection. */ typedef uint8_t nrf_802154_ed_error_t; -#define NRF_802154_ED_ERROR_ABORTED 0x01 /**< Procedure was aborted by other driver operation with FORCE priority. */ +#define NRF_802154_ED_ERROR_ABORTED 0x01 //!< Procedure was aborted by another driver operation with FORCE priority. /** * @brief Possible errors during CCA procedure. */ typedef uint8_t nrf_802154_cca_error_t; -#define NRF_802154_CCA_ERROR_ABORTED 0x01 /**< Procedure was aborted by other driver operation with FORCE priority. */ +#define NRF_802154_CCA_ERROR_ABORTED 0x01 //!< Procedure was aborted by another driver operation with FORCE priority. /** - * @brief Termination level selected for particular request. + * @brief Termination level selected for a particular request. * - * Each request is able to terminate ongoing operation. This type selects which operation should be - * aborted by given request. + * Each request can terminate an ongoing operation. This type selects which operation should be + * aborted by a given request. */ typedef uint8_t nrf_802154_term_t; -#define NRF_802154_TERM_NONE 0x00 /**< Request is skipped if another operation is ongoing. */ -#define NRF_802154_TERM_802154 0x01 /**< Request terminates ongoing 802.15.4 operation. */ +#define NRF_802154_TERM_NONE 0x00 //!< Request is skipped if another operation is ongoing. +#define NRF_802154_TERM_802154 0x01 //!< Request terminates ongoing 802.15.4 operation. /** * @brief Structure for configuring CCA. */ typedef struct { - nrf_radio_cca_mode_t mode; /**< CCA mode. */ - uint8_t ed_threshold; /**< CCA Energy Busy Threshold. Not used in NRF_RADIO_CCA_MODE_CARRIER. */ - uint8_t corr_threshold; /**< CCA Correlator Busy Threshold. Not used in NRF_RADIO_CCA_MODE_ED. */ - uint8_t corr_limit; /**< Limit of occurrences above CCA Correlator Busy Threshold. Not used in NRF_RADIO_CCA_MODE_ED. */ + nrf_radio_cca_mode_t mode; //!< CCA mode. + uint8_t ed_threshold; //!< CCA energy busy threshold. Not used in NRF_RADIO_CCA_MODE_CARRIER. + uint8_t corr_threshold; //!< CCA correlator busy threshold. Not used in NRF_RADIO_CCA_MODE_ED. + uint8_t corr_limit; //!< Limit of occurrences above CCA correlator busy threshold. Not used in NRF_RADIO_CCA_MODE_ED. } nrf_802154_cca_cfg_t; /** diff --git a/third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature.h b/third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature.h new file mode 100644 index 000000000..095cfec21 --- /dev/null +++ b/third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature.h @@ -0,0 +1,87 @@ +/* Copyright (c) 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** + * @brief This module defines Thermometer Abstraction Layer for the 802.15.4 driver. + * + */ + +#ifndef NRF_802154_TEMPERATURE_H_ +#define NRF_802154_TEMPERATURE_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_802154_temperature Thermometer Abstraction Layer for the 802.15.4 driver + * @{ + * @ingroup nrf_802154 + * @brief Thermometer Abstraction Layer interface for the 802.15.4 driver. + * + * Thermometer Abstraction Layer is an abstraction layer of thermometer that is used to correct + * RSSI, LQI, ED result and CCA threshold measurements. + * + */ + +/** + * @brief Initialize thermometer. + */ +void nrf_802154_temperature_init(void); + +/** + * @brief Uninitialize thermometer. + */ +void nrf_802154_temperature_deinit(void); + +/** + * @brief Get current temperature. + * + * @return Current temperature [C]. + */ +int8_t nrf_802154_temperature_get(void); + +/** + * @brief Callback executed when temperature changes. + */ +extern void nrf_802154_temperature_changed(void); + +/** + *@} + **/ + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_802154_TEMPERATURE_H_ */ diff --git a/third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature_none.c b/third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature_none.c new file mode 100644 index 000000000..dc56c27be --- /dev/null +++ b/third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature_none.c @@ -0,0 +1,60 @@ +/* Copyright (c) 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** + * @file + * This file implements the thermometer abstraction stub that does not use thermometer. + * + * This thermometer abstraction will cause RSSI, LQI, ED, CCA threshold errors up to 3 dBm when + * temperature of device differs more than 5 C from 20 C. + * + */ + +#include "nrf_802154_temperature.h" + +#include + +#define DEFAULT_TEMPERATURE 20 ///< Default temperature reported by this driver stub [C]. + +void nrf_802154_temperature_init(void) +{ + // Intentionally empty +} + +void nrf_802154_temperature_deinit(void) +{ + // Intentionally empty +} + +int8_t nrf_802154_temperature_get(void) +{ + return DEFAULT_TEMPERATURE; +} + diff --git a/third_party/NordicSemiconductor/drivers/radio/raal/softdevice/nrf_raal_softdevice.c b/third_party/NordicSemiconductor/drivers/radio/raal/softdevice/nrf_raal_softdevice.c index 23b20b274..2780ff817 100644 --- a/third_party/NordicSemiconductor/drivers/radio/raal/softdevice/nrf_raal_softdevice.c +++ b/third_party/NordicSemiconductor/drivers/radio/raal/softdevice/nrf_raal_softdevice.c @@ -61,6 +61,10 @@ _Pragma("GCC diagnostic pop") #endif +/*************************************************************************************************** + * @section Defines and typedefs. + **************************************************************************************************/ + /**@brief Enable Request and End on timeslot safety interrupt. */ #define ENABLE_REQUEST_AND_END_ON_TIMESLOT_END 0 @@ -83,6 +87,7 @@ #define TIMER_CC_MARGIN_INT NRF_TIMER_INT_COMPARE1_MASK #define TIMER_CC_CAPTURE NRF_TIMER_CC_CHANNEL2 +#define TIMER_CC_CAPTURE_TASK NRF_TIMER_TASK_CAPTURE2 /**@brief Defines number of microseconds in one second. */ #define US_PER_S 1000000 @@ -98,6 +103,21 @@ typedef enum PENDING_EVENT_ENDED } pending_events_t; +/**@brief Defines states of timeslot. */ +typedef enum +{ + TIMESLOT_STATE_IDLE = 0, + TIMESLOT_STATE_REQUESTED, + TIMESLOT_STATE_GRANTED +} timeslot_state_t; + +/*************************************************************************************************** + * @section Static variables. + **************************************************************************************************/ + +/**@brief Defines if module has been initialized. */ +static bool m_initialized = false; + /**@brief Request parameters. */ static nrf_radio_request_t m_request; @@ -107,20 +127,17 @@ static nrf_radio_signal_callback_return_param_t m_ret_param; /**@brief Current configuration of the RAAL. */ static nrf_raal_softdevice_cfg_t m_config; -/**@brief Current timeslot length. */ -static uint16_t m_timeslot_length; - -/**@brief Defines if RAAL is in continous mode. */ +/**@brief Defines if RAAL is in continuous mode. */ static volatile bool m_continuous = false; /**@brief Defines if RAAL is currently in a timeslot. */ -static volatile bool m_in_timeslot = false; +static volatile timeslot_state_t m_timeslot_state; -/**@brief Current iteration process number. */ -static volatile uint16_t m_alloc_iters; +/**@brief Current timeslot length. */ +static uint16_t m_timeslot_length; -/**@brief Defines if module has been initialized. */ -static bool m_initialize = false; +/**@brief Number of already performed extentions tries on failed event. */ +static volatile uint16_t m_timeslot_extend_tries; /**@breif Defines if Radio Driver entered critical section. */ static volatile bool m_in_critical_section = false; @@ -131,79 +148,9 @@ static volatile pending_events_t m_pending_event = PENDING_EVENT_NONE; /**@brief Defines RTC0 counter value on timeslot begin. */ static uint32_t m_start_rtc_ticks = 0; -/**@brief Initialize timeslot internal variables. */ -static inline void timeslot_data_init(void) -{ - m_alloc_iters = 0; - m_timeslot_length = m_config.timeslot_length; -} - -/**@brief Get actual time. */ -static inline uint32_t timer_time_get(void) -{ - RAAL_TIMER->TASKS_CAPTURE[TIMER_CC_CAPTURE] = 1; - return RAAL_TIMER->CC[TIMER_CC_CAPTURE]; -} - -/**@brief Check if margin is already reached. */ -static inline bool timer_is_margin_reached(void) -{ - return RAAL_TIMER->EVENTS_COMPARE[TIMER_CC_MARGIN]; -} - -/**@brief Enter timeslot critical section. */ -static inline void timeslot_critical_section_enter(void) -{ - NVIC_DisableIRQ(RAAL_TIMER_IRQn); - __DSB(); - __ISB(); -} - -/**@brief Exit timeslot critical section. */ -static inline void timeslot_critical_section_exit(void) -{ - NVIC_EnableIRQ(RAAL_TIMER_IRQn); -} - -static inline void timeslot_started_notify(void) -{ - if (m_in_timeslot && m_continuous) - { - nrf_raal_timeslot_started(); - } -} - -static inline void timeslot_ended_notify(void) -{ - if (!m_in_timeslot && m_continuous) - { - nrf_raal_timeslot_ended(); - } -} - -/**@brief Calculate maximal crystal drift. */ -static inline uint32_t rtc_drift_calculate(uint32_t timeslot_length) -{ - return DIVIDE_AND_CEIL(((uint64_t)timeslot_length * m_config.lf_clk_accuracy_ppm), US_PER_S); -} - -/**@brief Prepare earliest timeslot request. */ -static void timeslot_request_prepare(void) -{ - memset(&m_request, 0, sizeof(m_request)); - m_request.request_type = NRF_RADIO_REQ_TYPE_EARLIEST; - m_request.params.earliest.hfclk = NRF_RADIO_HFCLK_CFG_NO_GUARANTEE; - m_request.params.earliest.priority = NRF_RADIO_PRIORITY_NORMAL; - m_request.params.earliest.length_us = m_timeslot_length; - m_request.params.earliest.timeout_us = m_config.timeslot_timeout; -} - -/**@brief Request earliest timeslot. */ -static void timeslot_request(void) -{ - timeslot_request_prepare(); - sd_radio_request(&m_request); -} +/*************************************************************************************************** + * @section Operations on RAAL TIMER. + **************************************************************************************************/ /**@brief Set timer on timeslot started. */ static void timer_start(void) @@ -214,8 +161,8 @@ static void timer_start(void) nrf_timer_int_enable(RAAL_TIMER, TIMER_CC_MARGIN_INT); nrf_timer_cc_write(RAAL_TIMER, TIMER_CC_EXTEND, 0); nrf_timer_cc_write(RAAL_TIMER, TIMER_CC_MARGIN, m_timeslot_length - m_config.timeslot_safe_margin); - nrf_timer_task_trigger(RAAL_TIMER, NRF_TIMER_TASK_START); + nrf_timer_task_trigger(RAAL_TIMER, NRF_TIMER_TASK_START); NVIC_EnableIRQ(RAAL_TIMER_IRQn); } @@ -228,22 +175,38 @@ static void timer_reset(void) NVIC_ClearPendingIRQ(RAAL_TIMER_IRQn); } +/**@brief Get current time on RAAL Timer. */ +static inline uint32_t timer_time_get(void) +{ + nrf_timer_task_trigger(RAAL_TIMER, TIMER_CC_CAPTURE_TASK); + return nrf_timer_cc_read(RAAL_TIMER, TIMER_CC_CAPTURE); +} + +/**@brief Check if margin is already reached. */ +static inline bool timer_is_margin_reached(void) +{ + return nrf_timer_event_check(RAAL_TIMER, TIMER_CC_MARGIN_EVENT); +} + +/**@brief Calculate maximal crystal drift. */ +static inline uint32_t timer_rtc_drift_calculate(uint32_t timeslot_length) +{ + return DIVIDE_AND_CEIL(((uint64_t)timeslot_length * m_config.lf_clk_accuracy_ppm), US_PER_S); +} + /**@brief Set timer on extend event. */ -static void timer_extend(void) +static void timer_on_extend_update(void) { NVIC_ClearPendingIRQ(RAAL_TIMER_IRQn); - nrf_timer_int_enable(RAAL_TIMER, TIMER_CC_MARGIN_INT); - nrf_timer_cc_write(RAAL_TIMER, - TIMER_CC_MARGIN, + nrf_timer_cc_write(RAAL_TIMER, TIMER_CC_MARGIN, nrf_timer_cc_read(RAAL_TIMER, TIMER_CC_MARGIN) + m_timeslot_length); - if (!m_alloc_iters) + if (m_timeslot_extend_tries == 0) { - nrf_timer_int_enable(RAAL_TIMER, TIMER_CC_EXTEND_INT); - nrf_timer_cc_write(RAAL_TIMER, - TIMER_CC_EXTEND, + nrf_timer_cc_write(RAAL_TIMER, TIMER_CC_EXTEND, nrf_timer_cc_read(RAAL_TIMER, TIMER_CC_EXTEND) + m_timeslot_length); + nrf_timer_int_enable(RAAL_TIMER, TIMER_CC_EXTEND_INT); } } @@ -270,7 +233,7 @@ static void timer_jitter_adjust(void) // Check if we are still in time. uint32_t cc_margin = nrf_timer_cc_read(RAAL_TIMER, TIMER_CC_MARGIN); - assert(cc_margin > rtc_ticks + rtc_drift_calculate(cc_margin)); + assert(cc_margin > rtc_ticks + timer_rtc_drift_calculate(cc_margin)); if (rtc_ticks > timer_ticks) { @@ -286,48 +249,146 @@ static void timer_jitter_adjust(void) } // Add safety drift time. - uint32_t safety_drift_time = rtc_drift_calculate(2 * m_config.timeslot_length) + + uint32_t safety_drift_time = timer_rtc_drift_calculate(2 * m_config.timeslot_length) + TIMER_TO_SIGNAL_JITTER_US; nrf_timer_cc_write(RAAL_TIMER, TIMER_CC_MARGIN, nrf_timer_cc_read(RAAL_TIMER, TIMER_CC_MARGIN) - safety_drift_time); } -/**@brief Decrease timeslot length. */ -static void timeslot_decrease_length(void) +/*************************************************************************************************** + * @section Timeslot related functions. + **************************************************************************************************/ + +/**@brief Initialize timeslot internal variables. */ +static inline void timeslot_data_init(void) { - m_alloc_iters++; + m_timeslot_extend_tries = 0; + m_timeslot_length = m_config.timeslot_length; +} + +/**@brief Indicate if timeslot is in idle state. */ +static inline bool timeslot_is_idle(void) +{ + return (m_timeslot_state == TIMESLOT_STATE_IDLE); +} + +/**@brief Indicate if timeslot has been granted. */ +static inline bool timeslot_is_granted(void) +{ + return (m_timeslot_state == TIMESLOT_STATE_GRANTED); +} + +/**@brief Enter timeslot critical section. */ +static inline void timeslot_critical_section_enter(void) +{ + NVIC_DisableIRQ(RAAL_TIMER_IRQn); + __DSB(); + __ISB(); +} + +/**@brief Exit timeslot critical section. */ +static inline void timeslot_critical_section_exit(void) +{ + NVIC_EnableIRQ(RAAL_TIMER_IRQn); +} + +/**@brief Notify driver that timeslot has been started. */ +static inline void timeslot_started_notify(void) +{ + if (timeslot_is_granted() && m_continuous) + { + nrf_raal_timeslot_started(); + } +} + +/**@brief Notify driver that timeslot has been ended. */ +static inline void timeslot_ended_notify(void) +{ + if (!timeslot_is_granted() && m_continuous) + { + nrf_raal_timeslot_ended(); + } +} + +/**@brief Prepare earliest timeslot request. */ +static void timeslot_request_prepare(void) +{ + memset(&m_request, 0, sizeof(m_request)); + m_request.request_type = NRF_RADIO_REQ_TYPE_EARLIEST; + m_request.params.earliest.hfclk = NRF_RADIO_HFCLK_CFG_NO_GUARANTEE; + m_request.params.earliest.priority = NRF_RADIO_PRIORITY_NORMAL; + m_request.params.earliest.length_us = m_timeslot_length; + m_request.params.earliest.timeout_us = m_config.timeslot_timeout; +} + +/**@brief Request earliest timeslot. */ +static void timeslot_request(void) +{ + timeslot_request_prepare(); + + // Request timeslot from SoftDevice. + uint32_t err_code = sd_radio_request(&m_request); + + if (err_code == NRF_SUCCESS) + { + m_timeslot_state = TIMESLOT_STATE_REQUESTED; + } + + nrf_802154_log(EVENT_TIMESLOT_REQUEST, m_request.params.earliest.length_us); + nrf_802154_log(EVENT_TIMESLOT_REQUEST_RESULT, err_code); +} + +/**@brief Decrease timeslot length. */ +static void timeslot_length_decrease(void) +{ + m_timeslot_extend_tries++; m_timeslot_length = m_timeslot_length >> 1; } -/**@brief Extend timeslot. */ -static void timeslot_extend(void) +/**@brief Fill timeslot parameters with extend action. */ +static void timeslot_extend(uint32_t timeslot_length) { - if (m_alloc_iters < m_config.timeslot_alloc_iters) + m_ret_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND; + m_ret_param.params.extend.length_us = timeslot_length; + + nrf_802154_pin_set(PIN_DBG_TIMESLOT_EXTEND_REQ); + nrf_802154_log(EVENT_TIMESLOT_REQUEST, m_ret_param.params.extend.length_us); +} + +/**@brief Extend timeslot further. */ +static void timeslot_next_extend(void) +{ + // Check if we can make another extend query. + if (m_timeslot_extend_tries < m_config.timeslot_alloc_iters) { - timeslot_decrease_length(); + // Decrease timeslot length. + timeslot_length_decrease(); // Try to extend right after start. - m_ret_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND; - m_ret_param.params.extend.length_us = m_timeslot_length; - - nrf_802154_pin_set(PIN_DBG_TIMESLOT_EXTEND_REQ); + timeslot_extend(m_timeslot_length); } else { + // Adjust possible clock jitters and wait for safety margin. timer_jitter_adjust(); } } +/*************************************************************************************************** + * @section RAAL TIMER interrupt handler. + **************************************************************************************************/ + +/**@brief Handle timer interrupts. */ static void timer_irq_handle(void) { // Safe margin exceeded. - if (RAAL_TIMER->EVENTS_COMPARE[TIMER_CC_MARGIN]) + if (nrf_timer_event_check(RAAL_TIMER, TIMER_CC_MARGIN_EVENT)) { nrf_802154_pin_clr(PIN_DBG_TIMESLOT_ACTIVE); nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_SIG_EVENT_MARGIN); - m_in_timeslot = false; + m_timeslot_state = TIMESLOT_STATE_IDLE; if (m_in_critical_section) { @@ -364,7 +425,7 @@ static void timer_irq_handle(void) } // Extension margin exceeded. - else if (RAAL_TIMER->EVENTS_COMPARE[TIMER_CC_EXTEND]) + else if (nrf_timer_event_check(RAAL_TIMER, TIMER_CC_EXTEND_EVENT)) { nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_SIG_EVENT_EXTEND); @@ -375,13 +436,12 @@ static void timer_irq_handle(void) (nrf_timer_cc_read(RAAL_TIMER, TIMER_CC_EXTEND) + m_config.timeslot_length < m_config.timeslot_max_length)) { - nrf_802154_pin_set(PIN_DBG_TIMESLOT_EXTEND_REQ); - - m_ret_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND; - m_ret_param.params.extend.length_us = m_config.timeslot_length; + // Try to extend timeslot. + timeslot_extend(m_config.timeslot_length); } else { + // We have reached maximum timeslot length. timer_jitter_adjust(); m_ret_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE; @@ -396,6 +456,10 @@ static void timer_irq_handle(void) } } +/*************************************************************************************************** + * @section SoftDevice signal and SoC handlers. + **************************************************************************************************/ + /**@brief Signal handler. */ static nrf_radio_signal_callback_return_param_t *signal_handler(uint8_t signal_type) { @@ -409,8 +473,8 @@ static nrf_radio_signal_callback_return_param_t *signal_handler(uint8_t signal_t nrf_802154_pin_clr(PIN_DBG_TIMESLOT_ACTIVE); nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_SIG_EVENT_ENDED); - m_pending_event = PENDING_EVENT_NONE; - m_in_timeslot = false; + m_pending_event = PENDING_EVENT_NONE; + m_timeslot_state = TIMESLOT_STATE_IDLE; // TODO: Change to NRF_RADIO_SIGNAL_CALLBACK_ACTION_END (KRKNWK-937) m_ret_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE; @@ -430,12 +494,15 @@ static nrf_radio_signal_callback_return_param_t *signal_handler(uint8_t signal_t // Ensure HFCLK is running before start is issued. assert(NRF_CLOCK->HFCLKSTAT == (CLOCK_HFCLKSTAT_SRC_Msk | CLOCK_HFCLKSTAT_STATE_Msk)); - - timer_start(); + assert(m_timeslot_state == TIMESLOT_STATE_REQUESTED); m_start_rtc_ticks = NRF_RTC0->COUNTER; - m_in_timeslot = true; + m_timeslot_state = TIMESLOT_STATE_GRANTED; + // Set up timer first with requested timeslot length. + timer_start(); + + // Re-initialize timeslot data for future extensions. timeslot_data_init(); if (m_in_critical_section) @@ -457,11 +524,9 @@ static nrf_radio_signal_callback_return_param_t *signal_handler(uint8_t signal_t } // Try to extend right after start. - m_ret_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND; - m_ret_param.params.extend.length_us = m_timeslot_length; + timeslot_extend(m_timeslot_length); nrf_802154_log(EVENT_TRACE_EXIT, FUNCTION_RAAL_SIG_EVENT_START); - nrf_802154_pin_set(PIN_DBG_TIMESLOT_EXTEND_REQ); break; } @@ -473,7 +538,7 @@ static nrf_radio_signal_callback_return_param_t *signal_handler(uint8_t signal_t nrf_802154_pin_set(PIN_DBG_TIMESLOT_RADIO_IRQ); nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_SIG_EVENT_RADIO); - if (m_in_timeslot) + if (timeslot_is_granted()) { if (!timer_is_margin_reached()) { @@ -491,27 +556,26 @@ static nrf_radio_signal_callback_return_param_t *signal_handler(uint8_t signal_t break; case NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED: /**< This signal indicates extend action failed. */ - nrf_802154_pin_clr(PIN_DBG_TIMESLOT_EXTEND_REQ); nrf_802154_pin_tgl(PIN_DBG_TIMESLOT_FAILED); - nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_SIG_EVENT_EXCEED_FAIL); + nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_SIG_EVENT_EXTEND_FAIL); - timeslot_extend(); + timeslot_next_extend(); - nrf_802154_log(EVENT_TRACE_EXIT, FUNCTION_RAAL_SIG_EVENT_EXCEED_FAIL); + nrf_802154_log(EVENT_TRACE_EXIT, FUNCTION_RAAL_SIG_EVENT_EXTEND_FAIL); break; case NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED: /**< This signal indicates extend action succeeded. */ - nrf_802154_pin_clr(PIN_DBG_TIMESLOT_EXTEND_REQ); - nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_SIG_EVENT_EXCEED_SUCCESS); + nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_SIG_EVENT_EXTEND_SUCCESS); - timer_extend(); + timer_on_extend_update(); - if (m_alloc_iters != 0) + // Request futher extension only if any of previous one failed. + if (m_timeslot_extend_tries != 0) { - timeslot_extend(); + timeslot_next_extend(); } - nrf_802154_log(EVENT_TRACE_EXIT, FUNCTION_RAAL_SIG_EVENT_EXCEED_SUCCESS); + nrf_802154_log(EVENT_TRACE_EXIT, FUNCTION_RAAL_SIG_EVENT_EXTEND_SUCCESS); break; default: @@ -531,19 +595,24 @@ void nrf_raal_softdevice_soc_evt_handler(uint32_t evt_id) case NRF_EVT_RADIO_CANCELED: { nrf_802154_pin_tgl(PIN_DBG_TIMESLOT_BLOCKED); + nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_EVT_BLOCKED); - assert(!m_in_timeslot); + assert(!timeslot_is_granted()); + + m_timeslot_state = TIMESLOT_STATE_IDLE; if (m_continuous) { - if (m_alloc_iters < m_config.timeslot_alloc_iters) + if (m_timeslot_extend_tries < m_config.timeslot_alloc_iters) { - timeslot_decrease_length(); + timeslot_length_decrease(); } timeslot_request(); } + nrf_802154_log(EVENT_TRACE_EXIT, FUNCTION_RAAL_EVT_BLOCKED); + break; } @@ -552,14 +621,18 @@ void nrf_raal_softdevice_soc_evt_handler(uint32_t evt_id) break; case NRF_EVT_RADIO_SESSION_IDLE: - if (m_continuous) - { - nrf_802154_pin_tgl(PIN_DBG_TIMESLOT_SESSION_IDLE); + nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_EVT_SESSION_IDLE); + nrf_802154_pin_tgl(PIN_DBG_TIMESLOT_SESSION_IDLE); + + if (m_continuous && timeslot_is_idle()) + { timeslot_data_init(); timeslot_request(); } + nrf_802154_log(EVENT_TRACE_EXIT, FUNCTION_RAAL_EVT_SESSION_IDLE); + break; case NRF_EVT_RADIO_SESSION_CLOSED: @@ -570,9 +643,30 @@ void nrf_raal_softdevice_soc_evt_handler(uint32_t evt_id) } } +/*************************************************************************************************** + * @section HFCLK management. + **************************************************************************************************/ + +void nrf_802154_clock_hfclk_ready(void) +{ + nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_EVT_HFCLK_READY); + + if (m_continuous && timeslot_is_idle()) + { + timeslot_data_init(); + timeslot_request(); + } + + nrf_802154_log(EVENT_TRACE_EXIT, FUNCTION_RAAL_EVT_HFCLK_READY); +} + +/*************************************************************************************************** + * @section RAAL API. + **************************************************************************************************/ + void nrf_raal_softdevice_config(const nrf_raal_softdevice_cfg_t * p_cfg) { - assert(m_initialize); + assert(m_initialized); assert(!m_continuous); assert(p_cfg); @@ -581,10 +675,10 @@ void nrf_raal_softdevice_config(const nrf_raal_softdevice_cfg_t * p_cfg) void nrf_raal_init(void) { - assert(!m_initialize); + assert(!m_initialized); - m_continuous = false; - m_in_timeslot = false; + m_continuous = false; + m_timeslot_state = TIMESLOT_STATE_IDLE; m_config.lf_clk_accuracy_ppm = NRF_RAAL_DEFAULT_LF_CLK_ACCURACY_PPM; m_config.timeslot_length = NRF_RAAL_TIMESLOT_DEFAULT_LENGTH; @@ -596,18 +690,18 @@ void nrf_raal_init(void) uint32_t err_code = sd_radio_session_open(signal_handler); assert(err_code == NRF_SUCCESS); - m_initialize = true; + m_initialized = true; } void nrf_raal_uninit(void) { - assert(m_initialize); + assert(m_initialized); uint32_t err_code = sd_radio_session_close(); assert(err_code == NRF_SUCCESS); - m_continuous = false; - m_in_timeslot = false; + m_continuous = false; + m_timeslot_state = TIMESLOT_STATE_IDLE; nrf_802154_pin_clr(PIN_DBG_TIMESLOT_ACTIVE); } @@ -616,12 +710,10 @@ void nrf_raal_continuous_mode_enter(void) { nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_CONTINUOUS_ENTER); - assert(m_initialize); + assert(m_initialized); assert(!m_continuous); - m_alloc_iters = 0; - m_timeslot_length = m_config.timeslot_length; - m_continuous = true; + m_continuous = true; nrf_802154_clock_hfclk_start(); @@ -632,13 +724,13 @@ void nrf_raal_continuous_mode_exit(void) { nrf_802154_log(EVENT_TRACE_ENTER, FUNCTION_RAAL_CONTINUOUS_EXIT); - assert(m_initialize); + assert(m_initialized); assert(m_continuous); m_continuous = false; - // Emulate signal interrupt to inform SD about end of m_continuous mode. - if (m_in_timeslot) + // Emulate signal interrupt to inform SD about end of continuous mode. + if (timeslot_is_granted()) { NVIC_SetPendingIRQ(RAAL_TIMER_IRQn); } @@ -650,7 +742,7 @@ void nrf_raal_continuous_mode_exit(void) bool nrf_raal_timeslot_request(uint32_t length_us) { - if (!m_continuous || !m_in_timeslot) + if (!m_continuous || !timeslot_is_granted()) { return false; } @@ -660,12 +752,12 @@ bool nrf_raal_timeslot_request(uint32_t length_us) bool nrf_raal_timeslot_is_granted(void) { - return (m_continuous && m_in_timeslot); + return (m_continuous && timeslot_is_granted()); } uint32_t nrf_raal_timeslot_us_left_get(void) { - if (!m_continuous || !m_in_timeslot) + if (!m_continuous || !timeslot_is_granted()) { return 0; } @@ -710,11 +802,3 @@ void nrf_raal_critical_section_exit(void) nrf_802154_log(EVENT_TRACE_EXIT, FUNCTION_RAAL_CRIT_SECT_EXIT); } - -void nrf_802154_clock_hfclk_ready(void) -{ - if (m_continuous && !m_in_timeslot) - { - timeslot_request(); - } -} diff --git a/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.c b/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.c index 46969c1a4..67f353b6d 100644 --- a/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.c +++ b/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.c @@ -49,6 +49,10 @@ #include #include "platform/timer/nrf_802154_timer.h" +#if defined(__ICCARM__) + _Pragma("diag_suppress=Pe167") +#endif + static volatile uint8_t m_mutex; ///< Mutex for starting the timer. static volatile uint8_t m_queue_changed_cntr; ///< Information that scheduler queue was modified. static volatile nrf_802154_timer_t * mp_head; ///< Head of the running timers list.