1choice BTDM_CTRL_MODE
2    prompt "Bluetooth controller mode (BR/EDR/BLE/DUALMODE)"
3    help
4        Specify the bluetooth controller mode (BR/EDR, BLE or dual mode).
5
6    config BTDM_CTRL_MODE_BLE_ONLY
7        bool "BLE Only"
8
9    config BTDM_CTRL_MODE_BR_EDR_ONLY
10        bool "BR/EDR Only"
11
12    config BTDM_CTRL_MODE_BTDM
13        bool "Bluetooth Dual Mode"
14
15endchoice
16
17config BTDM_CTRL_BLE_MAX_CONN
18    int "BLE Max Connections"
19    depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
20    default 3
21    range 1 9
22    help
23        BLE maximum connections of bluetooth controller.
24        Each connection uses 1KB static DRAM whenever the BT controller is enabled.
25
26config BTDM_CTRL_BR_EDR_MAX_ACL_CONN
27    int "BR/EDR ACL Max Connections"
28    depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
29    default 2
30    range 1 7
31    help
32        BR/EDR ACL maximum connections of bluetooth controller.
33        Each connection uses 1.2 KB DRAM whenever the BT controller is enabled.
34
35config BTDM_CTRL_BR_EDR_MAX_SYNC_CONN
36    int "BR/EDR Sync(SCO/eSCO) Max Connections"
37    depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
38    default 0
39    range 0 3
40    help
41        BR/EDR Synchronize maximum connections of bluetooth controller.
42        Each connection uses 2 KB DRAM whenever the BT controller is enabled.
43
44
45
46choice BTDM_CTRL_BR_EDR_SCO_DATA_PATH
47    prompt "BR/EDR Sync(SCO/eSCO) default data path"
48    depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
49    default BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
50    help
51        SCO data path, i.e. HCI or PCM.
52        SCO data can be sent/received through HCI synchronous packets, or the data
53        can be routed to on-chip PCM module on ESP32. PCM input/output signals can
54        be "matrixed" to GPIOs. The default data path can also be set using API
55        "esp_bredr_sco_datapath_set"
56
57    config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI
58        bool "HCI"
59    config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
60        bool "PCM"
61endchoice
62
63config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF
64    int
65    default 0 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI
66    default 1 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
67    default 0
68
69menuconfig BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
70    bool "PCM Signal Config (Role and Polar)"
71    depends on BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
72    default y
73
74choice BTDM_CTRL_PCM_ROLE
75    prompt "PCM Role"
76    depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
77    help
78        PCM role can be configured as PCM master or PCM slave
79
80    config BTDM_CTRL_PCM_ROLE_MASTER
81        bool "PCM Master"
82    config BTDM_CTRL_PCM_ROLE_SLAVE
83        bool "PCM Slave"
84endchoice
85
86choice BTDM_CTRL_PCM_POLAR
87    prompt "PCM Polar"
88    depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
89    help
90        PCM polarity can be configured as Falling Edge or Rising Edge
91
92    config BTDM_CTRL_PCM_POLAR_FALLING_EDGE
93        bool "Falling Edge"
94    config BTDM_CTRL_PCM_POLAR_RISING_EDGE
95        bool "Rising Edge"
96endchoice
97
98config BTDM_CTRL_PCM_ROLE_EFF
99    int
100    default 0 if BTDM_CTRL_PCM_ROLE_MASTER
101    default 1 if BTDM_CTRL_PCM_ROLE_SLAVE
102    default 0
103
104config BTDM_CTRL_PCM_POLAR_EFF
105    int
106    default 0 if BTDM_CTRL_PCM_POLAR_FALLING_EDGE
107    default 1 if BTDM_CTRL_PCM_POLAR_RISING_EDGE
108    default 0
109
110config BTDM_CTRL_AUTO_LATENCY
111    bool "Auto latency"
112    depends on BTDM_CTRL_MODE_BTDM
113    default n
114    help
115        BLE auto latency, used to enhance classic BT performance
116        while classic BT and BLE are enabled at the same time.
117
118config BTDM_CTRL_AUTO_LATENCY_EFF
119    bool
120    default BTDM_CTRL_AUTO_LATENCY if BTDM_CTRL_MODE_BTDM
121    default n
122
123config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT
124    bool "Legacy Authentication Vendor Specific Event Enable"
125    depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
126    default y
127    help
128        To protect from BIAS attack during Legacy authentication,
129        Legacy authentication Vendor specific event should be enabled
130
131config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF
132    bool
133    default BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
134    default 0
135
136
137config BTDM_CTRL_BLE_MAX_CONN_EFF
138    int
139    default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
140    default 0
141
142config BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF
143    int
144    default BTDM_CTRL_BR_EDR_MAX_ACL_CONN if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
145    default 0
146
147config BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF
148    int
149    default BTDM_CTRL_BR_EDR_MAX_SYNC_CONN if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
150    default 0
151
152choice BTDM_CTRL_PINNED_TO_CORE_CHOICE
153    prompt "The cpu core which bluetooth controller run"
154    depends on !FREERTOS_UNICORE
155    help
156        Specify the cpu core to run bluetooth controller.
157        Can not specify no-affinity.
158
159    config BTDM_CTRL_PINNED_TO_CORE_0
160        bool "Core 0 (PRO CPU)"
161    config BTDM_CTRL_PINNED_TO_CORE_1
162        bool "Core 1 (APP CPU)"
163        depends on !FREERTOS_UNICORE
164endchoice
165
166config BTDM_CTRL_PINNED_TO_CORE
167    int
168    default 0 if BTDM_CTRL_PINNED_TO_CORE_0
169    default 1 if BTDM_CTRL_PINNED_TO_CORE_1
170    default 0
171
172choice BTDM_CTRL_HCI_MODE_CHOICE
173    prompt "HCI mode"
174    help
175        Speicify HCI mode as VHCI or UART(H4)
176
177    config BTDM_CTRL_HCI_MODE_VHCI
178        bool "VHCI"
179        help
180            Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32, too.
181
182    config BTDM_CTRL_HCI_MODE_UART_H4
183        bool "UART(H4)"
184        help
185            If use external bluetooth host which run on other hardware and use UART as the HCI interface,
186            choose this option.
187endchoice
188
189menu "HCI UART(H4) Options"
190    visible if BTDM_CTRL_HCI_MODE_UART_H4
191
192    config BTDM_CTRL_HCI_UART_NO
193        int "UART Number for HCI"
194        depends on BTDM_CTRL_HCI_MODE_UART_H4
195        range 1 2
196        default 1
197        help
198            Uart number for HCI. The available uart is UART1 and UART2.
199
200    config BTDM_CTRL_HCI_UART_BAUDRATE
201        int "UART Baudrate for HCI"
202        depends on BTDM_CTRL_HCI_MODE_UART_H4
203        range 115200 921600
204        default 921600
205        help
206            UART Baudrate for HCI. Please use standard baudrate.
207
208endmenu
209
210menu "MODEM SLEEP Options"
211    config BTDM_CTRL_MODEM_SLEEP
212        bool "Bluetooth modem sleep"
213        default y
214        help
215            Enable/disable bluetooth controller low power mode.
216
217    choice BTDM_CTRL_MODEM_SLEEP_MODE
218        prompt "Bluetooth Modem sleep mode"
219        depends on BTDM_CTRL_MODEM_SLEEP
220        help
221            To select which strategy to use for modem sleep
222
223        config BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
224            bool "ORIG Mode(sleep with low power clock)"
225            help
226                ORIG mode is a bluetooth sleep mode that can be used for dual mode controller. In this mode,
227                bluetooth controller sleeps between BR/EDR frames and BLE events. A low power clock is used to
228                maintain bluetooth reference clock.
229
230        config BTDM_CTRL_MODEM_SLEEP_MODE_EVED
231            bool "EVED Mode(For internal test only)"
232            help
233                EVED mode is for BLE only and is only for internal test. Do not use it for production. this
234                mode is not compatible with DFS nor light sleep
235    endchoice
236
237    choice BTDM_CTRL_LOW_POWER_CLOCK
238        prompt "Bluetooth low power clock"
239        depends on BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
240        help
241            Select the low power clock source for bluetooth controller. Bluetooth low power clock is
242            the clock source to maintain time in sleep mode.
243
244            - "Main crystal" option provides good accuracy and can support Dynamic Frequency Scaling
245              to be used with Bluetooth modem sleep. Light sleep is not supported.
246            - "External 32kHz crystal" option allows user to use a 32.768kHz crystal as Bluetooth low
247              power clock. This option is allowed as long as External 32kHz crystal is configured as
248              the system RTC clock source. This option provides good accuracy and supports Bluetooth
249              modem sleep to be used alongside Dynamic Frequency Scaling or light sleep.
250
251        config BTDM_CTRL_LPCLK_SEL_MAIN_XTAL
252            bool "Main crystal"
253            help
254                Main crystal can be used as low power clock for bluetooth modem sleep. If this option is
255                selected, bluetooth modem sleep can work under Dynamic Frequency Scaling(DFS) enabled, but
256                cannot work when light sleep is enabled. Main crystal has a good performance in accuracy as
257                the bluetooth low power clock source.
258
259        config BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL
260            bool "External 32kHz crystal"
261            depends on RTC_CLK_SRC_EXT_CRYS
262            help
263                External 32kHz crystal has a nominal frequency of 32.768kHz and provides good frequency
264                stability. If used as Bluetooth low power clock, External 32kHz can support Bluetooth
265                modem sleep to be used with both DFS and light sleep.
266    endchoice
267
268endmenu
269
270choice BTDM_BLE_SLEEP_CLOCK_ACCURACY
271    prompt "BLE Sleep Clock Accuracy"
272    depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
273    default BTDM_BLE_DEFAULT_SCA_250PPM
274    help
275        BLE Sleep Clock Accuracy(SCA) for the local device is used to estimate window widening in BLE
276        connection events. With a lower level of clock accuracy(e.g. 500ppm over 250ppm), the slave
277        needs a larger RX window to synchronize with master in each anchor point, thus resulting in an
278        increase of power consumption but a higher level of robustness in keeping connected. According
279        to the requirements of Bluetooth Core specification 4.2, the worst-case accuracy of Classic
280        Bluetooth low power oscialltor(LPO) is +/-250ppm in STANDBY and in low power modes such as
281        sniff. For BLE the worst-case SCA is +/-500ppm.
282
283        - "151ppm to 250ppm" option is the default value for Bluetooth Dual mode
284        - "251ppm to 500ppm" option can be used in BLE only mode when using external 32kHz crystal as
285           low power clock. This option is provided in case that BLE sleep clock has a lower level of
286           accuracy, or other error sources contribute to the inaccurate timing during sleep.
287
288    config BTDM_BLE_DEFAULT_SCA_500PPM
289        bool "251ppm to 500ppm"
290        depends on BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL && BTDM_CTRL_MODE_BLE_ONLY
291    config BTDM_BLE_DEFAULT_SCA_250PPM
292        bool "151ppm to 250ppm"
293endchoice
294config BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF
295    int
296    default 0 if BTDM_BLE_DEFAULT_SCA_500PPM
297    default 1 if BTDM_BLE_DEFAULT_SCA_250PPM
298    default 1
299
300config BTDM_BLE_SCAN_DUPL
301    bool "BLE Scan Duplicate Options"
302    depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
303    default y
304    help
305        This select enables parameters setting of BLE scan duplicate.
306
307choice BTDM_SCAN_DUPL_TYPE
308    prompt "Scan Duplicate Type"
309    default BTDM_SCAN_DUPL_TYPE_DEVICE
310    depends on BTDM_BLE_SCAN_DUPL
311    help
312        Scan duplicate have three ways. one is "Scan Duplicate By Device Address", This way is to use
313        advertiser address filtering. The adv packet of the same address is only allowed to be reported once.
314        Another way is "Scan Duplicate By Device Address And Advertising Data". This way is to use advertising
315        data and device address filtering. All different adv packets with the same address are allowed to be
316        reported. The last way is "Scan Duplicate By Advertising Data". This way is to use advertising data
317        filtering. All same advertising data only allow to be reported once even though they are from
318        different devices.
319
320    config BTDM_SCAN_DUPL_TYPE_DEVICE
321        bool "Scan Duplicate By Device Address"
322        help
323            This way is to use advertiser address filtering. The adv packet of the same address is only
324            allowed to be reported once
325
326    config BTDM_SCAN_DUPL_TYPE_DATA
327        bool "Scan Duplicate By Advertising Data"
328        help
329            This way is to use advertising data filtering. All same advertising data only allow to be reported
330            once even though they are from different devices.
331
332    config BTDM_SCAN_DUPL_TYPE_DATA_DEVICE
333        bool "Scan Duplicate By Device Address And Advertising Data"
334        help
335            This way is to use advertising data and device address filtering. All different adv packets with
336            the same address are allowed to be reported.
337endchoice
338
339config BTDM_SCAN_DUPL_TYPE
340    int
341    depends on BTDM_BLE_SCAN_DUPL
342    default 0 if BTDM_SCAN_DUPL_TYPE_DEVICE
343    default 1 if BTDM_SCAN_DUPL_TYPE_DATA
344    default 2 if BTDM_SCAN_DUPL_TYPE_DATA_DEVICE
345    default 0
346
347config BTDM_SCAN_DUPL_CACHE_SIZE
348    int "Maximum number of devices in scan duplicate filter"
349    depends on BTDM_BLE_SCAN_DUPL
350    range 10 1000
351    default 100
352    help
353        Maximum number of devices which can be recorded in scan duplicate filter.
354        When the maximum amount of device in the filter is reached, the cache will be refreshed.
355
356config BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD
357    int "Duplicate scan list refresh period (seconds)"
358    depends on BTDM_BLE_SCAN_DUPL
359    range 0 1000
360    default 0
361    help
362        If the period value is non-zero, the controller will periodically clear the device information
363        stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared
364        until the scanning is disabled. Duplicate advertisements for this period should not be sent to the
365        Host in advertising report events.
366        There are two scenarios where the ADV packet will be repeatedly reported:
367        1. The duplicate scan cache is full, the controller will delete the oldest device information and
368        add new device information.
369        2. When the refresh period is up, the controller will clear all device information and start filtering
370        again.
371
372config BTDM_BLE_MESH_SCAN_DUPL_EN
373    bool "Special duplicate scan mechanism for BLE Mesh scan"
374    depends on BTDM_BLE_SCAN_DUPL
375    default n
376    help
377        This enables the BLE scan duplicate for special BLE Mesh scan.
378
379config BTDM_MESH_DUPL_SCAN_CACHE_SIZE
380    int "Maximum number of Mesh adv packets in scan duplicate filter"
381    depends on BTDM_BLE_MESH_SCAN_DUPL_EN
382    range 10 1000
383    default 100
384    help
385        Maximum number of adv packets which can be recorded in duplicate scan cache for BLE Mesh.
386        When the maximum amount of device in the filter is reached, the cache will be refreshed.
387
388config BTDM_CTRL_FULL_SCAN_SUPPORTED
389    bool "BLE full scan feature supported"
390    depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
391    default y
392    help
393        The full scan function is mainly used to provide BLE scan performance.
394        This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
395
396config BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
397    bool "BLE adv report flow control supported"
398    depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
399    default y
400    help
401        The function is mainly used to enable flow control for advertising reports. When it is enabled,
402        advertising reports will be discarded by the controller if the number of unprocessed advertising
403        reports exceeds the size of BLE adv report flow control.
404
405config BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM
406    int "BLE adv report flow control number"
407    depends on BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
408    range 50 1000
409    default 100
410    help
411        The number of unprocessed advertising report that Bluedroid can save.If you set
412        `BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a small value, this may cause adv packets lost.
413        If you set `BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a large value, Bluedroid may cache a
414        lot of adv packets and this may cause system memory run out. For example, if you set
415        it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
416        `BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM` according to your system free memory and handle adv
417        packets as fast as possible, otherwise it will cause adv packets lost.
418
419config BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD
420    int "BLE adv lost event threshold value"
421    depends on BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
422    range 1 1000
423    default 20
424    help
425        When adv report flow control is enabled, The ADV lost event will be generated when the number
426        of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
427        If you set `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
428        may cause adv packets lost more.
429
430
431config BTDM_RESERVE_DRAM
432    hex
433    default 0xdb5c if BT_ENABLED
434    default 0
435
436config BTDM_CTRL_HLI
437    bool "High level interrupt"
438    depends on BT_ENABLED
439    default y
440    help
441        Using Level 4 interrupt for Bluetooth.
442