1 /* USER CODE BEGIN Header */
2 /**
3   ******************************************************************************
4   * @file    app_conf.h
5   * @author  MCD Application Team
6   * @brief   Application configuration file for STM32WPAN Middleware.
7   ******************************************************************************
8   * @attention
9   *
10   * Copyright (c) 2024 STMicroelectronics.
11   * All rights reserved.
12   *
13   * This software is licensed under terms that can be found in the LICENSE file
14   * in the root directory of this software component.
15   * If no LICENSE file comes with this software, it is provided AS-IS.
16   *
17   ******************************************************************************
18   */
19 /* USER CODE END Header */
20 
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef APP_CONF_H
23 #define APP_CONF_H
24 
25 /* Includes ------------------------------------------------------------------*/
26 #include "stm32wb0x.h"
27 /* USER CODE BEGIN Includes */
28 
29 /* USER CODE END Includes */
30 
31 /**
32  * Define to 1 if LSE is used, otherwise set it to 0.
33  */
34 #define CFG_LSCLK_LSE                       (1)
35 
36 /******************************************************************************
37  * Application Config
38  ******************************************************************************/
39 /**< generic parameters ******************************************************/
40 
41 /* USER CODE BEGIN Generic_Parameters */
42 
43 /* USER CODE END Generic_Parameters */
44 
45 /**< specific parameters */
46 /*****************************************************/
47 
48 /* USER CODE BEGIN Specific_Parameters */
49 
50 /* USER CODE END Specific_Parameters */
51 
52 /******************************************************************************
53  * BLE Stack initialization parameters
54  ******************************************************************************/
55 
56 /**
57  * Maximum number of simultaneous radio tasks. Radio controller supports up to
58  * 128 simultaneous radio tasks, but actual usable max value depends on the
59  * available RAM.
60  */
61 #ifndef __ZEPHYR__
62 /* It is handled by CMakeLists.txt */
63 #define CFG_BLE_NUM_RADIO_TASKS                         (CFG_NUM_RADIO_TASKS)
64 #endif
65 
66 /**
67  * Maximum number of Attributes that can be stored in the GATT database.
68  */
69 #define CFG_BLE_NUM_GATT_ATTRIBUTES                     (60)
70 
71 /**
72  * Maximum number of concurrent Client's Procedures. This value must be less
73  * than or equal to the maximum number of supported links (CFG_BLE_NUM_RADIO_TASKS).
74  */
75 #define CFG_BLE_NUM_OF_CONCURRENT_GATT_CLIENT_PROC      (8)
76 
77 /**
78  * Maximum supported ATT MTU size [23-1020].
79  */
80 #define CFG_BLE_ATT_MTU_MAX                             (247)
81 
82 /**
83  * Maximum duration of the connection event in system time units (625/256 us =~
84  * 2.44 us) when the device is in Peripheral role [0-0xFFFFFFFF].
85  */
86 #define CFG_BLE_CONN_EVENT_LENGTH_MAX                   (0xFFFFFFFF)
87 
88 /**
89  * Sleep clock accuracy (ppm).
90  */
91 #if CFG_LSCLK_LSE
92 /* Change this value according to accuracy of low speed crystal (ppm). */
93 #define CFG_BLE_SLEEP_CLOCK_ACCURACY                    (100)
94 #else
95 /* This value should be kept to 500 ppm when using LSI. */
96 #define CFG_BLE_SLEEP_CLOCK_ACCURACY                    (500)
97 #endif
98 
99 /**
100  * Number of extra memory blocks, in addition to the minimum required for the
101  * supported links.
102  */
103 #define CFG_BLE_MBLOCK_COUNT_MARGIN                     (0)
104 
105 /**
106  * Maximum number of simultaneous EATT active channels. It must be less than or
107  * equal to CFG_BLE_COC_NBR_MAX.
108  */
109 #ifndef __ZEPHYR__
110 #define CFG_BLE_NUM_EATT_CHANNELS                       (6)
111 #endif
112 
113 /**
114  * Maximum number of channels in LE Credit Based Flow Control mode [0-255].
115  * This number must be greater than or equal to CFG_BLE_NUM_EATT_CHANNELS.
116  */
117 #define CFG_BLE_COC_NBR_MAX                             (8)
118 
119 /**
120  * The maximum size of payload data in octets that the L2CAP layer entity is
121  * capable of accepting [0-1024].
122  */
123 #define CFG_BLE_COC_MPS_MAX                             (247)
124 
125 /**
126  * Maximum number of Advertising Data Sets, if Advertising Extension Feature is
127  * enabled.
128  */
129 #ifndef __ZEPHYR__
130 /* It is handled by CMakeLists.txt */
131 #define CFG_BLE_NUM_ADV_SETS                            (2)
132 #endif
133 
134 /**
135  * Maximum number of Periodic Advertising with Responses subevents.
136  */
137 #define CFG_BLE_NUM_PAWR_SUBEVENTS                      (16)
138 
139 /**
140  * Maximum number of subevent data that can be queued in the controller.
141  */
142 #define CFG_BLE_PAWR_SUBEVENT_DATA_COUNT_MAX            (8U)
143 
144 /**
145  * Maximum number of slots for scanning on the secondary advertising channel,
146  * if Advertising Extension Feature is enabled.
147  */
148 #ifndef __ZEPHYR__
149 #define CFG_BLE_NUM_AUX_SCAN_SLOTS                      (4)
150 #endif
151 /**
152  * Maximum number of slots for synchronizing to a periodic advertising train,
153  * if Periodic Advertising and Synchronizing Feature is enabled.
154  */
155 #ifndef __ZEPHYR__
156 /* It is handled by CMakeLists.txt */
157 #define CFG_BLE_NUM_SYNC_SLOTS                          (2)
158 #endif
159 
160 /**
161  * Two's logarithm of Filter Accept, Resolving and Advertiser list size.
162  */
163 #define CFG_BLE_FILTER_ACCEPT_LIST_SIZE_LOG2            (4)
164 
165 /**
166  * Maximum number of Antenna IDs in the antenna pattern used in CTE connection
167  * oriented mode.
168  */
169 #define CFG_BLE_NUM_CTE_ANTENNA_IDS_MAX                 (11)
170 
171 /**
172  * Maximum number of IQ samples in the buffer used in CTE connection oriented mode.
173  */
174 #define CFG_BLE_NUM_CTE_IQ_SAMPLES_MAX                  (82)
175 
176 /**
177  * Maximum number of slots for synchronizing to a Broadcast Isochronous Group.
178  */
179 #ifndef __ZEPHYR__
180 #define CFG_BLE_NUM_SYNC_BIG_MAX                        (1U)
181 
182 /**
183  * Maximum number of slots for synchronizing to a Broadcast Isochronous Stream.
184  */
185 #define CFG_BLE_NUM_SYNC_BIS_MAX                        (2U)
186 
187 /**
188  * Maximum number of slots for broadcasting a Broadcast Isochronous Group.
189  */
190 #define CFG_BLE_NUM_BRC_BIG_MAX                         (1U)
191 
192 /**
193  * Maximum number of slots for broadcasting a Broadcast Isochronous Stream.
194  */
195 #define CFG_BLE_NUM_BRC_BIS_MAX                         (2U)
196 
197 /**
198  * Maximum number of Connected Isochronous Groups.
199  */
200 #define CFG_BLE_NUM_CIG_MAX                             (2U)
201 
202 /**
203  * Maximum number of Connected Isochronous Streams.
204  */
205 #define CFG_BLE_NUM_CIS_MAX                             (2U)
206 #endif /* __ZEPHYR__ */
207 
208 /**
209  * Size of the internal FIFO used for critical controller events produced by the
210  * ISR (e.g. rx data packets).
211  */
212 #define CFG_BLE_ISR0_FIFO_SIZE                          (256)
213 
214 /**
215  * Size of the internal FIFO used for non-critical controller events produced by
216  * the ISR (e.g. advertising or IQ sampling reports).
217  */
218 #define CFG_BLE_ISR1_FIFO_SIZE                          (768)
219 
220 /**
221  * Size of the internal FIFO used for controller and host events produced
222  * outside the ISR.
223  */
224 #define CFG_BLE_USER_FIFO_SIZE                          (1024)
225 
226 /**
227  * Number of allocated memory blocks used for packet allocation.
228  * The use of BLE_STACK_MBLOCKS_CALC macro is suggested to calculate the minimum
229  * number of memory blocks for a given number of supported links and ATT MTU.
230  */
231 #define CFG_BLE_MBLOCKS_COUNT           (BLE_STACK_MBLOCKS_CALC(CFG_BLE_ATT_MTU_MAX, CFG_BLE_NUM_RADIO_TASKS, CFG_BLE_NUM_EATT_CHANNELS) + CFG_BLE_MBLOCK_COUNT_MARGIN)
232 
233 /**
234  * Macro to calculate the RAM needed by the stack according the number of links,
235  * memory blocks, advertising data sets and all the other initialization
236  * parameters.
237  */
238 #define BLE_DYN_ALLOC_SIZE (BLE_STACK_TOTAL_BUFFER_SIZE(CFG_BLE_NUM_RADIO_TASKS,\
239                                                         CFG_BLE_NUM_EATT_CHANNELS,\
240                                                         CFG_BLE_NUM_GATT_ATTRIBUTES,\
241                                                         CFG_BLE_NUM_OF_CONCURRENT_GATT_CLIENT_PROC,\
242                                                         CFG_BLE_MBLOCKS_COUNT,\
243                                                         CFG_BLE_NUM_ADV_SETS,\
244                                                         CFG_BLE_NUM_PAWR_SUBEVENTS,\
245                                                         CFG_BLE_PAWR_SUBEVENT_DATA_COUNT_MAX,\
246                                                         CFG_BLE_NUM_AUX_SCAN_SLOTS,\
247                                                         CFG_BLE_FILTER_ACCEPT_LIST_SIZE_LOG2,\
248                                                         CFG_BLE_COC_NBR_MAX,\
249                                                         CFG_BLE_NUM_SYNC_SLOTS,\
250                                                         CFG_BLE_NUM_CTE_ANTENNA_IDS_MAX,\
251                                                         CFG_BLE_NUM_CTE_IQ_SAMPLES_MAX,\
252                                                         CFG_BLE_NUM_SYNC_BIG_MAX,\
253                                                         CFG_BLE_NUM_BRC_BIG_MAX,\
254                                                         CFG_BLE_NUM_SYNC_BIS_MAX,\
255                                                         CFG_BLE_NUM_BRC_BIS_MAX,\
256                                                         CFG_BLE_NUM_CIG_MAX,\
257                                                         CFG_BLE_NUM_CIS_MAX,\
258                                                         CFG_BLE_ISR0_FIFO_SIZE,\
259                                                         CFG_BLE_ISR1_FIFO_SIZE,\
260                                                         CFG_BLE_USER_FIFO_SIZE))
261 
262 /* USER CODE BEGIN BLE_Stack */
263 
264 /* USER CODE END BLE_Stack */
265 
266 /******************************************************************************
267  * Initialization parameters used in Network Processor mode
268  ******************************************************************************/
269 /**
270  * Size of buffer used for ATT queued writes
271  */
272 #define CFG_BLE_ATT_QUEUED_WRITE_SIZE                   (512)
273 
274 /**
275  * Amount of RAM used to store GATT services (bytes)
276  */
277  #define CFG_BLE_GATT_NWK_BUFFER_SIZE                   (3072)
278 
279 /**
280  * Amount of RAM used to store advertising data (bytes)
281  */
282  #define CFG_BLE_ADV_NWK_BUFFER_SIZE                    (1660)
283 
284 /**
285  * Size of buffer shared between GATT_NWK library (used for GATT database and client
286  * write procedures) and ADV_NWK library (used for advertising buffers).
287  */
288 #define CFG_BLE_GATT_ADV_NWK_BUFFER_SIZE           (CFG_BLE_GATT_NWK_BUFFER_SIZE + CFG_BLE_ADV_NWK_BUFFER_SIZE + CFG_BLE_ATT_QUEUED_WRITE_SIZE)
289 
290 /******************************************************************************
291  * BLE Stack modularity options
292  ******************************************************************************/
293 #ifndef __ZEPHYR__
294 /* It is handled by CMakeLists.txt */
295 #define CFG_BLE_CONTROLLER_SCAN_ENABLED                   (1U)
296 #define CFG_BLE_CONTROLLER_PRIVACY_ENABLED                (1U)
297 #define CFG_BLE_SECURE_CONNECTIONS_ENABLED                (1U)
298 #define CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED  (1U)
299 #define CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED           (1U)
300 #define CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED           (1U)
301 #define CFG_BLE_L2CAP_COS_ENABLED                         (1U)
302 #define CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED           (1U)
303 #define CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED        (1U)
304 #define CFG_BLE_CONTROLLER_CTE_ENABLED                    (1U)
305 #define CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED          (1U)
306 #define CFG_BLE_CONNECTION_ENABLED                        (1U)
307 #define CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED             (1U)
308 #define CFG_BLE_CONTROLLER_BIS_ENABLED                    (1U)
309 #define CFG_BLE_CONNECTION_SUBRATING_ENABLED              (1U)
310 #define CFG_BLE_CONTROLLER_CIS_ENABLED                    (1U)
311 #endif
312 
313 /******************************************************************************
314  * Low Power
315  *
316  *  When CFG_FULL_LOW_POWER is set to 1, the system is configured in full
317  *  low power mode. It means that all what can have an impact on the consumptions
318  *  are powered down.(For instance LED, Access to Debugger, Etc.)
319  *
320  ******************************************************************************/
321 
322 #define CFG_FULL_LOW_POWER       (0)
323 
324 #define CFG_LPM_SUPPORTED        (1)
325 
326 /**
327  * Low Power configuration
328  */
329 #if (CFG_FULL_LOW_POWER == 1)
330   #undef CFG_LPM_SUPPORTED
331   #define CFG_LPM_SUPPORTED      (1)
332 #endif /* CFG_FULL_LOW_POWER */
333 
334 /* USER CODE BEGIN Low_Power 0 */
335 
336 /* USER CODE END Low_Power 0 */
337 
338 /**
339  * Supported requester to the MCU Low Power Manager - can be increased up  to 32
340  * It list a bit mapping of all user of the Low Power Manager
341  */
342 typedef enum
343 {
344   CFG_LPM_APP,
345   /* USER CODE BEGIN CFG_LPM_Id_t */
346 
347   /* USER CODE END CFG_LPM_Id_t */
348 } CFG_LPM_Id_t;
349 
350 /* USER CODE BEGIN Low_Power 1 */
351 
352 /* USER CODE END Low_Power 1 */
353 
354 /*****************************************************************************
355  * Traces
356  * Enable or Disable traces in application
357  * When CFG_DEBUG_TRACE is set, traces are activated
358  *
359  * Note : Refer to utilities_conf.h file in order to details
360  *        the level of traces : CFG_DEBUG_TRACE_FULL or CFG_DEBUG_TRACE_LIGHT
361  *****************************************************************************/
362 /**
363  * Enable or disable debug prints.
364  */
365 #define CFG_DEBUG_APP_TRACE             (0)
366 
367 /**
368  * Use or not advanced trace module. UART interrupts to be enabled.
369  */
370 #define CFG_DEBUG_APP_ADV_TRACE         (0)
371 
372 #define ADV_TRACE_TIMESTAMP_ENABLE      (0)
373 
374 #if (CFG_DEBUG_APP_TRACE == 0)
375 #undef CFG_DEBUG_APP_ADV_TRACE
376 #define CFG_DEBUG_APP_ADV_TRACE         (0)
377 #endif
378 
379 #if (CFG_DEBUG_APP_ADV_TRACE != 0)
380 
381 #include "stm32_adv_trace.h"
382 
383 #define APP_DBG(...)                                      \
384 {                                                                 \
385   UTIL_ADV_TRACE_COND_FSend(VLEVEL_L, ~0x0, ADV_TRACE_TIMESTAMP_ENABLE, __VA_ARGS__); \
386 }
387 #else
388 #define APP_DBG(...) printf(__VA_ARGS__)
389 #endif
390 
391 #if (CFG_DEBUG_APP_TRACE != 0)
392 #include <stdio.h>
393 #define APP_DBG_MSG             APP_DBG
394 #else
395 #define APP_DBG_MSG(...)
396 #endif
397 
398 /* USER CODE BEGIN Traces */
399 
400 /* USER CODE END Traces */
401 
402 /******************************************************************************
403  * Sequencer
404  ******************************************************************************/
405 
406 /**
407  * These are the lists of task id registered to the sequencer
408  * Each task id shall be in the range [0:31]
409  */
410 typedef enum
411 {
412   CFG_TASK_BLE_STACK,
413   CFG_TASK_VTIMER,
414   CFG_TASK_NVM,
415   CFG_TASK_TM,
416   CFG_TASK_BURST,
417   /* USER CODE BEGIN CFG_Task_Id_t */
418 
419   /* USER CODE END CFG_Task_Id_t */
420   CFG_TASK_NBR,  /**< Shall be LAST in the list */
421 } CFG_Task_Id_t;
422 
423 /* USER CODE BEGIN DEFINE_TASK */
424 
425 /* USER CODE END DEFINE_TASK */
426 
427 /**
428  * This is the list of priority required by the application
429  * Each Id shall be in the range 0..31
430  */
431 typedef enum
432 {
433   CFG_SEQ_PRIO_0,
434   CFG_SEQ_PRIO_1,
435   /* USER CODE BEGIN CFG_SEQ_Prio_Id_t */
436 
437   /* USER CODE END CFG_SEQ_Prio_Id_t */
438   CFG_SEQ_PRIO_NBR
439 } CFG_SEQ_Prio_Id_t;
440 
441 /******************************************************************************
442  * RT GPIO debug module configuration
443  ******************************************************************************/
444 
445 #define RT_DEBUG_GPIO_MODULE         (0)
446 
447 /* USER CODE BEGIN Defines */
448 /**
449  * User interaction
450  * When CFG_LED_SUPPORTED is set, LEDS are activated if requested
451  * When CFG_BUTTON_SUPPORTED is set, the push button are activated if requested
452  */
453 
454 #define CFG_LED_SUPPORTED                       (1)
455 #define CFG_BUTTON_SUPPORTED                    (0)
456 
457 /**
458  * If CFG_FULL_LOW_POWER is requested, make sure LED and debugger are disabled
459  */
460 #if (CFG_FULL_LOW_POWER == 1)
461   #undef  CFG_LED_SUPPORTED
462   #define CFG_LED_SUPPORTED      (0)
463 #endif /* CFG_FULL_LOW_POWER */
464 
465 /* USER CODE END Defines */
466 
467 #endif /*APP_CONF_H */
468