1.. _bluetooth-ctlr-arch: 2 3Bluetooth Low Energy Controller 4############################### 5 6Overview 7******** 8 9.. image:: img/ctlr_overview.png 10 11#. HCI 12 13 * Host Controller Interface, Bluetooth standard 14 * Provides Zephyr Bluetooth HCI Driver 15 16#. HAL 17 18 * Hardware Abstraction Layer 19 * Vendor Specific, and Zephyr Driver usage 20 21#. Ticker 22 23 * Soft real time radio/resource scheduling 24 25#. LL_SW 26 27 * Software-based Link Layer implementation 28 * States and roles, control procedures, packet controller 29 30#. Util 31 32 * Bare metal memory pool management 33 * Queues of variable count, lockless usage 34 * FIFO of fixed count, lockless usage 35 * Mayfly concept based deferred ISR executions 36 37 38Architecture 39************ 40 41Execution Overview 42================== 43 44.. image:: img/ctlr_exec_overview.png 45 46 47Architecture Overview 48===================== 49 50.. image:: img/ctlr_arch_overview.png 51 52 53Scheduling 54********** 55 56.. image:: img/ctlr_sched.png 57 58 59Ticker 60====== 61 62.. image:: img/ctlr_sched_ticker.png 63 64 65Upper Link Layer and Lower Link Layer 66===================================== 67 68.. image:: img/ctlr_sched_ull_lll.png 69 70 71Scheduling Variants 72=================== 73 74.. image:: img/ctlr_sched_variant.png 75 76 77ULL and LLL Timing 78================== 79 80.. image:: img/ctlr_sched_ull_lll_timing.png 81 82 83Event Handling 84************** 85 86.. image:: img/ctlr_sched_event_handling.png 87 88 89Scheduling Closely Spaced Events 90================================ 91 92.. image:: img/ctlr_sched_msc_close_events.png 93 94 95Aborting Active Event 96===================== 97 98.. image:: img/ctlr_sched_msc_event_abort.png 99 100 101Cancelling Pending Event 102======================== 103 104.. image:: img/ctlr_sched_msc_event_cancel.png 105 106 107Pre-emption of Active Event 108=========================== 109 110.. image:: img/ctlr_sched_msc_event_preempt.png 111 112 113Data Flow 114********* 115 116Transmit Data Flow 117================== 118 119.. image:: img/ctlr_dataflow_tx.png 120 121 122Receive Data Flow 123================= 124 125.. image:: img/ctlr_dataflow_rx.png 126 127 128Execution Priorities 129******************** 130 131.. image:: img/ctlr_exec_prio.png 132 133- Event handle (0, 1) < Event preparation (2, 3) < Event/Rx done (4) < Tx 134 request (5) < Role management (6) < Host (7). 135 136- LLL is vendor ISR, ULL is Mayfly ISR concept, Host is kernel thread. 137 138 139Lower Link Layer 140**************** 141 142LLL Execution 143============= 144 145.. image:: img/ctlr_exec_lll.png 146 147 148LLL Resume 149---------- 150 151.. image:: img/ctlr_exec_lll_resume_top.png 152 153.. image:: img/ctlr_exec_lll_resume_bottom.png 154 155 156Bare metal utilities 157******************** 158 159Memory FIFO and Memory Queue 160============================ 161 162.. image:: img/ctlr_mfifo_memq.png 163 164Mayfly 165====== 166 167.. image:: img/ctlr_mayfly.png 168 169 170* Mayfly are multi-instance scalable ISR execution contexts 171* What a Work is to a Thread, Mayfly is to an ISR 172* List of functions executing in ISRs 173* Execution priorities map to IRQ priorities 174* Facilitate cross execution context scheduling 175* Race-to-idle execution 176* Lock-less, bare metal 177 178Legacy Controller 179***************** 180 181.. image:: img/ctlr_legacy.png 182 183Bluetooth Low Energy Controller - Vendor Specific Details 184********************************************************* 185 186Hardware Requirements 187===================== 188 189Nordic Semiconductor 190-------------------- 191 192The Nordic Semiconductor Bluetooth Low Energy Controller implementation 193requires the following hardware peripherals. 194 195.. list-table:: SoC Peripheral Use 196 :header-rows: 1 197 :widths: 15 15 15 10 50 198 199 * - Resource 200 - nRF Peripheral 201 - # instances 202 - Zephyr Driver Accessible 203 - Description 204 * - Clock 205 - NRF_CLOCK 206 - 1 207 - Yes 208 - * A Low Frequency Clock (LFCLOCK) or sleep clock, for low power 209 consumption between Bluetooth radio events 210 * A High Frequency Clock (HFCLOCK) or active clock, for high precision 211 packet timing and software based transceiver state switching with 212 inter-frame space (tIFS) timing inside Bluetooth radio events 213 * - RTC [a]_ 214 - NRF_RTC0 215 - 1 216 - **No** 217 - * Uses 2 capture/compare registers 218 * - Timer 219 - NRF_TIMER0 or NRF_TIMER4 [1]_, and NRF_TIMER1 [0]_ 220 - 2 or 1 [1]_ 221 - **No** 222 - * 2 instances, one each for packet timing and tIFS software switching, 223 respectively 224 * 7 capture/compare registers (3 mandatory, 1 optional for ISR profiling, 225 4 for single timer tIFS switching) on first instance 226 * 4 capture/compare registers for second instance, if single tIFS timer 227 is not used. 228 * - PPI [b]_ 229 - NRF_PPI 230 - 21 channels (20 [2]_), and 2 channel groups [3]_ 231 - Yes [4]_ 232 - * Used for radio mode switching to achieve tIFS timings, for PA/LNA 233 control 234 * - DPPI [c]_ 235 - NRF_DPPI 236 - 20 channels, and 2 channel groups [3]_ 237 - Yes [4]_ 238 - * Used for radio mode switching to achieve tIFS timings, for PA/LNA 239 control 240 * - SWI [d]_ 241 - NRF_SWI4 and NRF_SWI5, or NRF_SWI2 and NRF_SWI3 [5]_ 242 - 2 243 - **No** 244 - * 2 instances, for Lower Link Layer and Upper Link Layer Low priority 245 execution context 246 * - Radio 247 - NRF_RADIO 248 - 1 249 - **No** 250 - * 2.4 GHz radio transceiver with multiple radio standards such as 1 Mbps, 251 2 Mbps and Coded PHY S2/S8 Long Range Bluetooth Low Energy technology 252 * - RNG [e]_ 253 - NRF_RNG 254 - 1 255 - Yes 256 - 257 * - ECB [f]_ 258 - NRF_ECB 259 - 1 260 - **No** 261 - 262 * - CBC-CCM [g]_ 263 - NRF_CCM 264 - 1 265 - **No** 266 - 267 * - AAR [h]_ 268 - NRF_AAR 269 - 1 270 - **No** 271 - 272 * - GPIO [i]_ 273 - NRF_GPIO 274 - 2 GPIO pins for PA and LNA, 1 each 275 - Yes 276 - * Additionally, 10 Debug GPIO pins (optional) 277 * - GPIOTE [j]_ 278 - NRF_GPIOTE 279 - 1 280 - Yes 281 - * Used for PA/LNA 282 * - TEMP [k]_ 283 - NRF_TEMP 284 - 1 285 - Yes 286 - * For RC sourced LFCLOCK calibration 287 * - UART [l]_ 288 - NRF_UART0 289 - 1 290 - Yes 291 - * For HCI interface in Controller only builds 292 * - IPC [m]_ 293 - NRF_IPC [5]_ 294 - 1 295 - Yes 296 - * For HCI interface in Controller only builds 297 298 299.. [a] Real Time Counter (RTC) 300.. [b] Programmable Peripheral Interconnect (PPI) 301.. [c] Distributed Programmable Peripheral Interconnect (DPPI) 302.. [d] Software Interrupt (SWI) 303.. [e] Random Number Generator (RNG) 304.. [f] AES Electronic Codebook Mode Encryption (ECB) 305.. [g] Cipher Block Chaining (CBC) - Message Authentication Code with Counter 306 Mode encryption (CCM) 307.. [h] Accelerated Address Resolver (AAR) 308.. [i] General Purpose Input Output (GPIO) 309.. [j] GPIO tasks and events (GPIOTE) 310.. [k] Temperature sensor (TEMP) 311.. [l] Universal Asynchronous Receiver Transmitter (UART) 312.. [m] Interprocess Communication peripheral (IPC) 313 314 315.. [0] :kconfig:option:`CONFIG_BT_CTLR_TIFS_HW` ``=n`` 316.. [1] :kconfig:option:`CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER` ``=y`` 317.. [2] When not using pre-defined PPI channels 318.. [3] For software-based tIFS switching 319.. [4] Drivers that use nRFx interfaces 320.. [5] For nRF53x Series 321