1 /* 2 * Copyright (c) 2018-2022 Nordic Semiconductor ASA 3 * Copyright (c) 2018 Ioannis Glaropoulos 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 /* HAL header files for nRF5x SoCs. 9 * These has to come before the radio_*.h include below. 10 */ 11 #include <hal/nrf_radio.h> 12 13 /* Common radio resources */ 14 #include "radio_nrf5_resources.h" 15 16 /* Helpers for radio timing conversions. 17 * These has to come before the radio_*.h include below. 18 */ 19 #define HAL_RADIO_NS2US_CEIL(ns) ((ns + 999)/1000) 20 #define HAL_RADIO_NS2US_ROUND(ns) ((ns + 500)/1000) 21 22 /* SoC specific defines */ 23 #if defined(CONFIG_BOARD_NRF52_BSIM) 24 #include "radio_sim_nrf52.h" 25 #elif defined(CONFIG_BOARD_NRF5340BSIM_NRF5340_CPUNET) 26 #include "radio_sim_nrf5340.h" 27 #elif defined(CONFIG_SOC_SERIES_NRF51X) 28 #include "radio_nrf51.h" 29 #elif defined(CONFIG_SOC_NRF52805) 30 #include "radio_nrf52805.h" 31 #elif defined(CONFIG_SOC_NRF52810) 32 #include "radio_nrf52810.h" 33 #elif defined(CONFIG_SOC_NRF52811) 34 #include "radio_nrf52811.h" 35 #elif defined(CONFIG_SOC_NRF52820) 36 #include "radio_nrf52820.h" 37 #elif defined(CONFIG_SOC_NRF52832) 38 #include "radio_nrf52832.h" 39 #elif defined(CONFIG_SOC_NRF52833) 40 #include "radio_nrf52833.h" 41 #elif defined(CONFIG_SOC_NRF52840) 42 #include "radio_nrf52840.h" 43 #elif defined(CONFIG_SOC_NRF5340_CPUNET) 44 #include <hal/nrf_vreqctrl.h> 45 #include "radio_nrf5340.h" 46 #elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) 47 #include "radio_nrf54lx.h" 48 #else /* !CONFIG_SOC_COMPATIBLE_NRF54LX */ 49 #error "Unsupported SoC." 50 #endif 51 52 #if defined(CONFIG_BT_CTLR_NRF_GRTC) 53 #include <hal/nrf_grtc.h> 54 #include <hal/nrf_ppib.h> 55 #else /* !CONFIG_BT_CTLR_NRF_GRTC */ 56 #include <hal/nrf_rtc.h> 57 #endif /* !CONFIG_BT_CTLR_NRF_GRTC */ 58 59 #include <hal/nrf_timer.h> 60 61 #if defined(CONFIG_BT_CTLR_LE_ENC) || defined(CONFIG_BT_CTLR_BROADCAST_ISO_ENC) 62 #include <hal/nrf_ccm.h> 63 #include <hal/nrf_aar.h> 64 #endif /* CONFIG_BT_CTLR_LE_ENC || CONFIG_BT_CTLR_BROADCAST_ISO_ENC */ 65 66 /* Define to reset PPI registration. 67 * This has to come before the ppi/dppi includes below. 68 */ 69 #define NRF_PPI_NONE 0 70 71 /* This has to come before the ppi/dppi includes below. */ 72 #include "radio_nrf5_fem.h" 73 74 /* Include RTC/GRTC Compare Index used to Trigger Radio TXEN/RXEN */ 75 #include "hal/cntr.h" 76 77 #if defined(PPI_PRESENT) 78 #include <hal/nrf_ppi.h> 79 #include "radio_nrf5_ppi_resources.h" 80 #include "radio_nrf5_ppi.h" 81 #elif defined(DPPI_PRESENT) 82 #include <hal/nrf_dppi.h> 83 #include "radio_nrf5_dppi_resources.h" 84 #include "radio_nrf5_dppi.h" 85 #else 86 #error "PPI or DPPI abstractions missing." 87 #endif 88 89 #include "radio_nrf5_txp.h" 90 91 /* Common NRF_RADIO power-on reset value. Refer to Product Specification, 92 * RADIO Registers section for the documented reset values. 93 * 94 * NOTE: Only implementation used values defined here. 95 * In the future if MDK or nRFx header include these, use them instead. 96 */ 97 #define HAL_RADIO_RESET_VALUE_PCNF1 0x00000000UL 98 99 /* SoC specific Radio PDU length field maximum value */ 100 #if defined(CONFIG_SOC_SERIES_NRF51X) 101 #define HAL_RADIO_PDU_LEN_MAX (BIT(5) - 1) 102 #else 103 #define HAL_RADIO_PDU_LEN_MAX (BIT(8) - 1) 104 #endif 105 106 /* This is delay between PPI task START and timer actual start counting. */ 107 #if !defined(CONFIG_SOC_SERIES_BSIM_NRFXX) 108 #define HAL_RADIO_TMR_START_DELAY_US 1U 109 #else /* For simulated targets there is no delay for the PPI task -> TIMER start */ 110 #define HAL_RADIO_TMR_START_DELAY_US 0U 111 #endif 112 113 /* This is the minimum prepare duration required to setup radio for deferred transmission */ 114 #define HAL_RADIO_TMR_DEFERRED_TX_DELAY_US 50U 115