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) 2022 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 "hw_if.h"
27 #include "utilities_conf.h"
28 
29 /* USER CODE BEGIN Includes */
30 
31 /* USER CODE END Includes */
32 
33 /******************************************************************************
34  * Application Config
35  ******************************************************************************/
36 /**< generic parameters ******************************************************/
37 
38 /**
39 *   Identity root key used to derive IRK and DHK(Legacy)
40 */
41 #define CFG_BLE_IR      {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0}
42 
43 /**
44 * Encryption root key used to derive LTK(Legacy) and CSRK
45 */
46 #define CFG_BLE_ER      {0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21, 0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21}
47 
48 /* USER CODE BEGIN Generic_Parameters */
49 
50 /* USER CODE END Generic_Parameters */
51 
52 /**< specific parameters */
53 /*****************************************************/
54 
55 /* USER CODE BEGIN Specific_Parameters */
56 
57 /* USER CODE END Specific_Parameters */
58 
59 /******************************************************************************
60  * BLE Stack
61  ******************************************************************************/
62 /**
63  * BLE stack options, bitmap to active or not some features at BleStack_Init() function call.
64  */
65 #define CFG_BLE_OPTIONS             (0 | \
66                                      0 | \
67                                      0 | \
68                                      BLE_OPTIONS_EXTENDED_ADV | \
69                                      0 | \
70                                      BLE_OPTIONS_GATT_CACHING | \
71                                      0 | \
72                                      0 | \
73                                      BLE_OPTIONS_ENHANCED_ATT)
74 
75 /**
76  * Maximum number of simultaneous connections and advertising that the device will support.
77  * This setting should not exceed the number of BLE connection supported by BLE host stack.
78  */
79 #define CFG_BLE_NUM_LINK            (2)
80 
81 /**
82  * Maximum number of Services that can be stored in the GATT database.
83  * Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services
84  */
85 #define CFG_BLE_NUM_GATT_SERVICES   (8)
86 
87 /**
88  * Maximum number of Attributes
89  * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services)
90  * that can be stored in the GATT database.
91  * Note that certain characteristics and relative descriptors are added automatically during device initialization
92  * so this parameters should be 9 plus the number of user Attributes
93  */
94 #define CFG_BLE_NUM_GATT_ATTRIBUTES (68)
95 
96 /**
97  * Maximum supported ATT_MTU size
98  * This setting should be aligned with ATT_MTU value configured in the ble host
99  */
100 #define CFG_BLE_ATT_MTU_MAX         (251)
101 
102 /**
103  * Size of the storage area for Attribute values
104  *  This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute:
105  *  - attribute value length
106  *  - 5, if UUID is 16 bit; 19, if UUID is 128 bit
107  *  - 2, if server configuration descriptor is used
108  *  - 2*DTM_NUM_LINK, if client configuration descriptor is used
109  *  - 2, if extended properties is used
110  *  The total amount of memory needed is the sum of the above quantities for each attribute.
111  */
112 #define CFG_BLE_ATT_VALUE_ARRAY_SIZE    (1344)
113 
114 /**
115  * depth of the PREPARE WRITE queue when PREPARE WRITE REQUEST
116  */
117 #define CFG_BLE_ATTR_PREPARE_WRITE_VALUE_SIZE       (30)
118 
119 #define CFG_BLE_MBLOCK_COUNT_MARGIN                 (0x15)
120 
121 #define PREP_WRITE_LIST_SIZE                        (BLE_DEFAULT_PREP_WRITE_LIST_SIZE)
122 
123 /**
124  * Number of allocated memory blocks used to transmit and receive data packets
125  */
126 #define CFG_BLE_MBLOCK_COUNT          (BLE_MBLOCKS_CALC(PREP_WRITE_LIST_SIZE, \
127                                        CFG_BLE_ATT_MTU_MAX, CFG_BLE_NUM_LINK) \
128                                        + CFG_BLE_MBLOCK_COUNT_MARGIN)
129 
130 /**
131  * Appearance of device set into BLE GAP
132  */
133 #define CFG_GAP_APPEARANCE            (GAP_APPEARANCE_UNKNOWN)
134 
135 /**
136  * Connection Oriented Channel parameters
137  */
138 #define CFG_BLE_COC_NBR_MAX           (64)
139 #define CFG_BLE_COC_MPS_MAX           (248)
140 #define CFG_BLE_COC_INITIATOR_NBR_MAX (32)
141 
142 /**
143  * PHY preferences
144  */
145 #define CFG_PHY_PREF                  (0)
146 #define CFG_PHY_PREF_TX               (HCI_TX_PHYS_LE_2M_PREF)
147 #define CFG_PHY_PREF_RX               (HCI_RX_PHYS_LE_2M_PREF)
148 
149 /* USER CODE BEGIN BLE_Stack */
150 
151 /* USER CODE END BLE_Stack */
152 
153 /******************************************************************************
154  * Low Power
155  *
156  *  When CFG_LPM_LEVEL is set to:
157  *   - 0 : Low Power Mode is not activated, RUN mode will be used.
158  *   - 1 : Low power active, the one selected with CFG_LPM_STDBY_SUPPORTED
159  *   - 2 : In addition, force to disable modules to reach lowest power figures.
160  *
161  * When CFG_LPM_STDBY_SUPPORTED is set to:
162  *   - 1 : Standby is used as low power mode.
163  *   - 0 : Standby is not used, so stop mode 1 is used as low power mode.
164  *
165  ******************************************************************************/
166 #define CFG_LPM_LEVEL            (1)
167 #define CFG_LPM_STDBY_SUPPORTED  (1)
168 
169 /* Defines time to wake up from standby before radio event to meet timings */
170 #define CFG_LPM_STDBY_WAKEUP_TIME (1500)
171 
172 /* USER CODE BEGIN Low_Power 0 */
173 
174 /* USER CODE END Low_Power 0 */
175 
176 /**
177  * Supported requester to the MCU Low Power Manager - can be increased up  to 32
178  * It list a bit mapping of all user of the Low Power Manager
179  */
180 typedef enum
181 {
182   CFG_LPM_APP,
183   CFG_LPM_LOG,
184   CFG_LPM_LL_DEEPSLEEP,
185   CFG_LPM_LL_HW_RCO_CLBR,
186   CFG_LPM_APP_BLE,
187   /* USER CODE BEGIN CFG_LPM_Id_t */
188 
189   /* USER CODE END CFG_LPM_Id_t */
190 } CFG_LPM_Id_t;
191 
192 /* USER CODE BEGIN Low_Power 1 */
193 
194 /* USER CODE END Low_Power 1 */
195 
196 /******************************************************************************
197  * RTC
198  ******************************************************************************/
199 
200 /* USER CODE BEGIN RTC */
201 
202 /* USER CODE END RTC */
203 
204 /*****************************************************************************
205  * Logs
206  *
207  * Applications must call LOG_INFO_APP for logs.
208  * By default, CFG_LOG_INSERT_TIME_STAMP_INSIDE_THE_TRACE is set to 0.
209  * As a result, there is no time stamp insertion inside the logs.
210  *
211  * For advanced log use cases, see the log_module.h file.
212  * This file is customizable, you can create new verbose levels and log regions.
213  *****************************************************************************/
214 /**
215  * Enable or disable LOG over UART in the application.
216  * Low power level(CFG_LPM_LEVEL) above 1 will disable LOG.
217  * Standby low power mode(CFG_LPM_STDBY_SUPPORTED) will disable LOG.
218  */
219 #define CFG_LOG_SUPPORTED           (0U)
220 
221 /* Usart used by LOG */
222 
223 /* Configure Log display settings */
224 #define CFG_LOG_INSERT_COLOR_INSIDE_THE_TRACE       (0U)
225 #define CFG_LOG_INSERT_TIME_STAMP_INSIDE_THE_TRACE  (0U)
226 #define CFG_LOG_INSERT_EOL_INSIDE_THE_TRACE         (0U)
227 
228 #define CFG_LOG_TRACE_FIFO_SIZE     (4096U)
229 #define CFG_LOG_TRACE_BUF_SIZE      (256U)
230 
231 /* macro ensuring retrocompatibility with old applications */
232 #define APP_DBG                     LOG_INFO_APP
233 #define APP_DBG_MSG                 LOG_INFO_APP
234 
235 /* USER CODE BEGIN Logs */
236 
237 /* USER CODE END Logs */
238 
239 /******************************************************************************
240  * Configure Log level for Application
241  ******************************************************************************/
242 #define APPLI_CONFIG_LOG_LEVEL      LOG_VERBOSE_INFO
243 #define APPLI_CONFIG_LOG_REGION     (LOG_REGION_ALL_REGIONS)
244 /* USER CODE BEGIN Log_level */
245 
246 /* USER CODE END Log_level */
247 
248 /******************************************************************************
249  * Sequencer
250  ******************************************************************************/
251 
252 /**
253  * These are the lists of task id registered to the sequencer
254  * Each task id shall be in the range [0:31]
255  */
256 typedef enum
257 {
258   CFG_TASK_HW_RNG,
259   CFG_TASK_LINK_LAYER,
260   CFG_TASK_BLE_HCI_CMD_ID,
261   CFG_TASK_SYS_HCI_CMD_ID,
262   CFG_TASK_HCI_ACL_DATA_ID,
263   CFG_TASK_SYS_LOCAL_CMD_ID,
264   CFG_TASK_TX_TO_HOST_ID,
265   CFG_TASK_NOTIFY_EVENT_ID,
266   CFG_TASK_TEMP_MEAS,
267   CFG_TASK_BLE_HOST,
268   CFG_TASK_AMM,
269   CFG_TASK_BPKA,
270   CFG_TASK_FLASH_MANAGER,
271   CFG_TASK_BLE_TIMER_BCKGND,
272   /* USER CODE BEGIN CFG_Task_Id_t */
273   TASK_BUTTON_1,
274   TASK_BUTTON_2,
275   TASK_BUTTON_3,
276   /* USER CODE END CFG_Task_Id_t */
277   CFG_TASK_NBR /* Shall be LAST in the list */
278 } CFG_Task_Id_t;
279 
280 /* USER CODE BEGIN DEFINE_TASK */
281 
282 /* USER CODE END DEFINE_TASK */
283 
284 /**
285  * This is the list of priority required by the application
286  * Shall be in the range 0..31
287  */
288 typedef enum
289 {
290   CFG_SEQ_PRIO_0 = 0,
291   CFG_SEQ_PRIO_1,
292   /* USER CODE BEGIN CFG_SEQ_Prio_Id_t */
293 
294   /* USER CODE END CFG_SEQ_Prio_Id_t */
295   CFG_SEQ_PRIO_NBR /* Shall be LAST in the list */
296 } CFG_SEQ_Prio_Id_t;
297 
298 /* Sequencer configuration */
299 #define UTIL_SEQ_CONF_PRIO_NBR              CFG_SEQ_PRIO_NBR
300 
301 /**
302  * These are the lists of events id registered to the sequencer
303  * Each event id shall be in the range [0:31]
304  */
305 typedef enum
306 {
307   /* USER CODE BEGIN CFG_Event_Id_t */
308 
309   /* USER CODE END CFG_Event_Id_t */
310   CFG_EVENT_NBR                   /* Shall be LAST in the list */
311 } CFG_Event_Id_t;
312 
313 /**< Events defines */
314 /* USER CODE BEGIN EVENT_ID_Define */
315 
316 /* USER CODE END EVENT_ID_Define */
317 
318 /******************************************************************************
319  * NVM configuration
320  ******************************************************************************/
321 
322 #define CFG_SNVMA_START_SECTOR_ID     ((FLASH_SIZE / FLASH_PAGE_SIZE) - 2u)
323 
324 #define CFG_SNVMA_START_ADDRESS       (FLASH_BASE + (FLASH_PAGE_SIZE * (CFG_SNVMA_START_SECTOR_ID)))
325 
326 /* USER CODE BEGIN NVM_Configuration */
327 
328 /* USER CODE END NVM_Configuration */
329 
330 /******************************************************************************
331  * BLEPLAT configuration
332  ******************************************************************************/
333 /* Number of 64-bit words in NVM flash area */
334 #define CFG_BLEPLAT_NVM_MAX_SIZE            ((2048/8)-4)
335 
336 /* USER CODE BEGIN BLEPLAT_Configuration */
337 
338 /* USER CODE END BLEPLAT_Configuration */
339 
340 /******************************************************************************
341  * Debugger
342  *
343  *  When CFG_DEBUGGER_LEVEL is set to:
344  *   - 0 : No Debugger available, SWD/JTAG pins are disabled.
345  *   - 1 : Debugger available in RUN mode only.
346  *   - 2 : Debugger available in low power mode.
347  *
348  ******************************************************************************/
349 #define CFG_DEBUGGER_LEVEL                  (2)
350 
351 /******************************************************************************
352  * RealTime GPIO debug module configuration
353  ******************************************************************************/
354 
355 #define CFG_RT_DEBUG_GPIO_MODULE            (0)
356 #define CFG_RT_DEBUG_DTB                    (0)
357 
358 /******************************************************************************
359  * System Clock Manager module configuration
360  ******************************************************************************/
361 
362 #define CFG_SCM_SUPPORTED                   (1)
363 
364 /******************************************************************************
365  * HW RADIO configuration
366  ******************************************************************************/
367 /* Do not modify - must be 1 */
368 #define USE_RADIO_LOW_ISR                   (1)
369 
370 /* Do not modify - must be 1 */
371 #define NEXT_EVENT_SCHEDULING_FROM_ISR      (1)
372 
373 /* Link Layer uses temperature based calibration (0 --> NO ; 1 --> YES) */
374 #define USE_TEMPERATURE_BASED_RADIO_CALIBRATION  (0)
375 
376 #define RADIO_INTR_NUM                      RADIO_IRQn     /* 2.4GHz RADIO global interrupt */
377 #define RADIO_INTR_PRIO_HIGH                (0)            /* 2.4GHz RADIO interrupt priority when radio is Active */
378 #define RADIO_INTR_PRIO_LOW                 (5)            /* 2.4GHz RADIO interrupt priority when radio is Not Active - Sleep Timer Only */
379 
380 #if (USE_RADIO_LOW_ISR == 1)
381 #define RADIO_SW_LOW_INTR_NUM               HASH_IRQn      /* Selected interrupt vector for 2.4GHz RADIO low ISR */
382 #define RADIO_SW_LOW_INTR_PRIO              (14)           /* 2.4GHz RADIO low ISR priority */
383 #endif /* USE_RADIO_LOW_ISR */
384 
385 /* Link Layer supported number of antennas */
386 #define RADIO_NUM_OF_ANTENNAS               (4)
387 
388 #define RCC_INTR_PRIO                       (1)           /* HSERDY and PLL1RDY */
389 
390 /* RF TX power table ID selection:
391  *   0 -> RF TX output level from -20 dBm to +10 dBm
392  *   1 -> RF TX output level from -20 dBm to +3 dBm
393  *   2 -> RF TX output level at +20 dBm with an external PA
394  */
395 #define CFG_RF_TX_POWER_TABLE_ID            (0)
396 
397 #define CFG_EXTERNAL_PA_ENABLE              (0)
398 
399 #define CFG_BLE_AOA_AOD_ENABLE              (0)
400 
401 /* Custom LSE sleep clock accuracy to use if both conditions are met:
402  * - LSE is selected as Link Layer sleep clock source
403  * - the LSE used is different from the default one.
404  */
405 #define CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE (0)
406 
407 /* USER CODE BEGIN Radio_Configuration */
408 
409 /* USER CODE END Radio_Configuration */
410 
411 /******************************************************************************
412  * HW_RNG configuration
413  ******************************************************************************/
414 
415 /* Number of 32-bit random values stored in internal pool */
416 #define CFG_HW_RNG_POOL_SIZE                (32)
417 
418 /* USER CODE BEGIN HW_RNG_Configuration */
419 
420 /* USER CODE END HW_RNG_Configuration */
421 
422 /******************************************************************************
423  * MEMORY MANAGER
424  ******************************************************************************/
425 
426 #define CFG_MM_POOL_SIZE                                  (4000U)  /* bytes */
427 #define CFG_AMM_VIRTUAL_MEMORY_NUMBER                     (2U)
428 #define CFG_AMM_VIRTUAL_STACK_BLE                         (1U)
429 #define CFG_AMM_VIRTUAL_STACK_BLE_BUFFER_SIZE     (400U)  /* words (32 bits) */
430 #define CFG_AMM_VIRTUAL_APP_BLE                           (2U)
431 #define CFG_AMM_VIRTUAL_APP_BLE_BUFFER_SIZE     (200U)  /* words (32 bits) */
432 #define CFG_AMM_POOL_SIZE                                 ( DIVC(CFG_MM_POOL_SIZE, sizeof (uint32_t)) \
433                                                           + (AMM_VIRTUAL_INFO_ELEMENT_SIZE * CFG_AMM_VIRTUAL_MEMORY_NUMBER) )
434 
435 /* USER CODE BEGIN MEMORY_MANAGER_Configuration */
436 
437 /* USER CODE END MEMORY_MANAGER_Configuration */
438 
439 /* USER CODE BEGIN Defines */
440 /**
441  * User interaction
442  * When CFG_LED_SUPPORTED is set, LEDS are activated if requested
443  * When CFG_BUTTON_SUPPORTED is set, the push button are activated if requested
444  */
445 
446 #define CFG_LED_SUPPORTED                       (1)
447 #define CFG_BUTTON_SUPPORTED                    (1)
448 
449 /**
450  * Overwrite some configuration imposed by Low Power level selected.
451  */
452 #if (CFG_LPM_LEVEL > 1)
453   #if CFG_LED_SUPPORTED
454     #undef  CFG_LED_SUPPORTED
455     #define CFG_LED_SUPPORTED      (0)
456   #endif /* CFG_LED_SUPPORTED */
457 #endif /* CFG_LPM_LEVEL */
458 
459 /* USER CODE END Defines */
460 
461 /**
462  * Overwrite some configuration imposed by Low Power level selected.
463  */
464 #if (CFG_LPM_LEVEL > 1)
465   #if CFG_LOG_SUPPORTED
466     #undef  CFG_LOG_SUPPORTED
467     #define CFG_LOG_SUPPORTED       (0)
468   #endif /* CFG_LOG_SUPPORTED */
469   #if CFG_DEBUGGER_LEVEL
470     #undef  CFG_DEBUGGER_LEVEL
471     #define CFG_DEBUGGER_LEVEL      (0)
472   #endif /* CFG_DEBUGGER_LEVEL */
473 #endif /* CFG_LPM_LEVEL */
474 
475 #if (CFG_LPM_STDBY_SUPPORTED == 1)
476   #if CFG_LOG_SUPPORTED
477     #undef  CFG_LOG_SUPPORTED
478     #define CFG_LOG_SUPPORTED       (0)
479   #endif /* CFG_LOG_SUPPORTED */
480 #endif /* CFG_LPM_STDBY_SUPPORTED */
481 
482 /* USER CODE BEGIN Defines_2 */
483 
484 /* USER CODE END Defines_2 */
485 
486 #endif /*APP_CONF_H */
487