1 /**
2  ******************************************************************************
3  * @file    shci.h
4  * @author  MCD Application Team
5  * @brief   HCI command for the system channel
6  ******************************************************************************
7  * @attention
8  *
9  * Copyright (c) 2018-2021 STMicroelectronics.
10  * All rights reserved.
11  *
12  * This software is licensed under terms that can be found in the LICENSE file
13  * in the root directory of this software component.
14  * If no LICENSE file comes with this software, it is provided AS-IS.
15  *
16  ******************************************************************************
17  */
18 
19 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __SHCI_H
22 #define __SHCI_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28   /* Includes ------------------------------------------------------------------*/
29 #include "mbox_def.h" /* Requested to expose the MB_WirelessFwInfoTable_t structure */
30 
31   /* Exported types ------------------------------------------------------------*/
32 
33   /* SYSTEM EVENT */
34   typedef enum
35   {
36     WIRELESS_FW_RUNNING = 0x00,
37     FUS_FW_RUNNING = 0x01,
38   } SHCI_SysEvt_Ready_Rsp_t;
39 
40   /* ERROR CODES
41    *
42    * These error codes are detected on CPU2 side and are send back to the CPU1 via a system
43    * notification message. It is up to the application running on CPU1 to manage these errors
44    *
45    * These errors can be generated by all layers (low level driver, stack, framework infrastructure, etc..)
46    */
47    typedef enum
48    {
49      ERR_BLE_INIT = 0,                 /* This event is currently not reported by the CPU2                    */
50      ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error              */
51      ERR_THREAD_UNKNOWN_CMD = 126,     /* The command send by the CPU1 to control the Thread stack is unknown */
52      ERR_ZIGBEE_UNKNOWN_CMD = 200,     /* The command send by the CPU1 to control the Zigbee stack is unknown */
53    } SCHI_SystemErrCode_t;
54 
55 #define SHCI_EVTCODE                    ( 0xFF )
56 #define SHCI_SUB_EVT_CODE_BASE          ( 0x9200 )
57 
58   /**
59    * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU1 DEFINITION
60    */
61   typedef enum
62   {
63     SHCI_SUB_EVT_CODE_READY =  SHCI_SUB_EVT_CODE_BASE,
64     SHCI_SUB_EVT_ERROR_NOTIF,
65     SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE,
66     SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE,
67     SHCI_SUB_EVT_NVM_START_WRITE,
68     SHCI_SUB_EVT_NVM_END_WRITE,
69     SHCI_SUB_EVT_NVM_START_ERASE,
70     SHCI_SUB_EVT_NVM_END_ERASE,
71     SHCI_SUB_EVT_CODE_CONCURRENT_802154_EVT,
72   } SHCI_SUB_EVT_CODE_t;
73 
74   /**
75    * SHCI_SUB_EVT_CODE_READY
76    * This notifies the CPU1 that the CPU2 is now ready to receive commands
77    * It reports as well which firmware is running on CPU2 : The wireless stack of the FUS (previously named RSS)
78    */
79   typedef PACKED_STRUCT{
80     SHCI_SysEvt_Ready_Rsp_t sysevt_ready_rsp;
81   } SHCI_C2_Ready_Evt_t;
82 
83   /**
84    * SHCI_SUB_EVT_ERROR_NOTIF
85    * This reports to the CPU1 some error form the CPU2
86    */
87   typedef PACKED_STRUCT{
88     SCHI_SystemErrCode_t errorCode;
89   } SHCI_C2_ErrorNotif_Evt_t;
90 
91   /**
92    * SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE
93    * This notifies the CPU1 which part of the BLE NVM RAM has been updated so that only the modified
94    * section could be written in Flash/NVM
95    * StartAddress : Start address of the section that has been modified
96    * Size : Size (in bytes) of the section that has been modified
97    */
98   typedef PACKED_STRUCT{
99     uint32_t StartAddress;
100     uint32_t Size;
101   } SHCI_C2_BleNvmRamUpdate_Evt_t;
102 
103   /**
104    * SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE
105    * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified
106    * section could be written in Flash/NVM
107    * StartAddress : Start address of the section that has been modified
108    * Size : Size (in bytes) of the section that has been modified
109    */
110   typedef PACKED_STRUCT{
111     uint32_t StartAddress;
112     uint32_t Size;
113   } SHCI_C2_ThreadNvmRamUpdate_Evt_t;
114 
115   /**
116    * SHCI_SUB_EVT_NVM_START_WRITE
117    * This notifies the CPU1 that the CPU2 has started a write procedure in Flash
118    * NumberOfWords : The number of 64bits data the CPU2 needs to write in Flash.
119    *                 For each 64bits data, the algorithm as described in AN5289 is executed.
120    *                 When this number is reported to 0, it means the Number of 64bits to be written
121    *                 was unknown when the procedure has started.
122    * When all data are written, the SHCI_SUB_EVT_NVM_END_WRITE event is reported
123    */
124   typedef PACKED_STRUCT{
125     uint32_t NumberOfWords;
126   } SHCI_C2_NvmStartWrite_Evt_t;
127 
128   /**
129    * SHCI_SUB_EVT_NVM_END_WRITE
130    * This notifies the CPU1 that the CPU2 has written all expected data in Flash
131    */
132 
133   /**
134    * SHCI_SUB_EVT_NVM_START_ERASE
135    * This notifies the CPU1 that the CPU2 has started a erase procedure in Flash
136    * NumberOfSectors : The number of sectors the CPU2 needs to erase in Flash.
137    *                   For each sector, the algorithm as described in AN5289 is executed.
138    *                   When this number is reported to 0, it means the Number of sectors to be erased
139    *                   was unknown when the procedure has started.
140    * When all sectors are erased, the SHCI_SUB_EVT_NVM_END_ERASE event is reported
141    */
142   typedef PACKED_STRUCT{
143     uint32_t NumberOfSectors;
144   } SHCI_C2_NvmStartErase_Evt_t;
145 
146   /**
147    * SHCI_SUB_EVT_NVM_END_ERASE
148    * This notifies the CPU1 that the CPU2 has erased all expected flash sectors
149    */
150 
151   /* SYSTEM COMMAND */
152   typedef PACKED_STRUCT
153   {
154     /**
155      * MetaData holds :
156      * 2*32bits for chaining list
157      * 1*32bits with BLE header (type + Opcode + Length)
158      */
159     uint32_t MetaData[3];
160   } SHCI_Header_t;
161 
162   typedef enum
163   {
164     SHCI_Success = 0x00,
165     SHCI_UNKNOWN_CMD = 0x01,
166     SHCI_MEMORY_CAPACITY_EXCEEDED_ERR_CODE=  0x07,
167     SHCI_ERR_UNSUPPORTED_FEATURE = 0x11,
168     SHCI_ERR_INVALID_HCI_CMD_PARAMS = 0x12,
169     SHCI_ERR_INVALID_PARAMS = 0x42,    /* only used for release < v1.13.0 */
170     SHCI_ERR_INVALID_PARAMS_V2 = 0x92, /* available for release >= v1.13.0 */
171     SHCI_FUS_CMD_NOT_SUPPORTED = 0xFF,
172   } SHCI_CmdStatus_t;
173 
174   typedef enum
175   {
176     SHCI_8BITS =  0x01,
177     SHCI_16BITS = 0x02,
178     SHCI_32BITS = 0x04,
179   } SHCI_Busw_t;
180 
181 #define SHCI_OGF                        ( 0x3F )
182 #define SHCI_OCF_BASE                   ( 0x50 )
183 
184   /**
185    * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU2 DEFINITION
186    */
187   typedef enum
188   {
189     SHCI_OCF_C2_RESERVED1 =  SHCI_OCF_BASE,
190     SHCI_OCF_C2_RESERVED2,
191     SHCI_OCF_C2_FUS_GET_STATE,
192     SHCI_OCF_C2_FUS_RESERVED1,
193     SHCI_OCF_C2_FUS_FW_UPGRADE,
194     SHCI_OCF_C2_FUS_FW_DELETE,
195     SHCI_OCF_C2_FUS_UPDATE_AUTH_KEY,
196     SHCI_OCF_C2_FUS_LOCK_AUTH_KEY,
197     SHCI_OCF_C2_FUS_STORE_USR_KEY,
198     SHCI_OCF_C2_FUS_LOAD_USR_KEY,
199     SHCI_OCF_C2_FUS_START_WS,
200     SHCI_OCF_C2_FUS_RESERVED2,
201     SHCI_OCF_C2_FUS_RESERVED3,
202     SHCI_OCF_C2_FUS_LOCK_USR_KEY,
203     SHCI_OCF_C2_FUS_UNLOAD_USR_KEY,
204     SHCI_OCF_C2_FUS_ACTIVATE_ANTIROLLBACK,
205     SHCI_OCF_C2_FUS_RESERVED7,
206     SHCI_OCF_C2_FUS_RESERVED8,
207     SHCI_OCF_C2_FUS_RESERVED9,
208     SHCI_OCF_C2_FUS_RESERVED10,
209     SHCI_OCF_C2_FUS_RESERVED11,
210     SHCI_OCF_C2_FUS_RESERVED12,
211     SHCI_OCF_C2_BLE_INIT,
212     SHCI_OCF_C2_THREAD_INIT,
213     SHCI_OCF_C2_DEBUG_INIT,
214     SHCI_OCF_C2_FLASH_ERASE_ACTIVITY,
215     SHCI_OCF_C2_CONCURRENT_SET_MODE,
216     SHCI_OCF_C2_FLASH_STORE_DATA,
217     SHCI_OCF_C2_FLASH_ERASE_DATA,
218     SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER,
219     SHCI_OCF_C2_MAC_802_15_4_INIT,
220     SHCI_OCF_C2_REINIT,
221     SHCI_OCF_C2_ZIGBEE_INIT,
222     SHCI_OCF_C2_LLD_TESTS_INIT,
223     SHCI_OCF_C2_EXTPA_CONFIG,
224     SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL,
225     SHCI_OCF_C2_BLE_LLD_INIT,
226     SHCI_OCF_C2_CONFIG,
227     SHCI_OCF_C2_CONCURRENT_GET_NEXT_BLE_EVT_TIME,
228     SHCI_OCF_C2_CONCURRENT_ENABLE_NEXT_802154_EVT_NOTIFICATION,
229     SHCI_OCF_C2_802_15_4_DEINIT,
230     SHCI_OCF_C2_SET_SYSTEM_CLOCK,
231   } SHCI_OCF_t;
232 
233 #define SHCI_OPCODE_C2_FUS_GET_STATE         (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_GET_STATE)
234 /** No command parameters */
235 /** Response parameters*/
236 /** It responds a 1 byte value holding FUS State error code when the FUS State value is 0xFF (FUS_STATE_VALUE_ERROR) */
237   typedef enum
238   {
239     FUS_STATE_ERROR_NO_ERROR =  0x00,
240     FUS_STATE_ERROR_IMG_NOT_FOUND = 0x01,
241     FUS_STATE_ERROR_IMG_CORRUPT = 0x02,
242     FUS_STATE_ERROR_IMG_NOT_AUTHENTIC = 0x03,
243     FUS_STATE_ERROR_IMG_NOT_ENOUGH_SPACE = 0x04,
244     FUS_STATE_ERROR_IMAGE_USRABORT = 0x05,
245     FUS_STATE_ERROR_IMAGE_ERSERROR = 0x06,
246     FUS_STATE_ERROR_IMAGE_WRTERROR = 0x07,
247     FUS_STATE_ERROR_AUTH_TAG_ST_NOTFOUND = 0x08,
248     FUS_STATE_ERROR_AUTH_TAG_CUST_NOTFOUND = 0x09,
249     FUS_STATE_ERROR_AUTH_KEY_LOCKED = 0x0A,
250     FUS_STATE_ERROR_FW_ROLLBACK_ERROR = 0x11,
251     FUS_STATE_ERROR_STATE_NOT_RUNNING = 0xFE,
252     FUS_STATE_ERROR_ERR_UNKNOWN = 0xFF,
253   } SHCI_FUS_GetState_ErrorCode_t;
254 
255   enum
256   {
257     FUS_STATE_VALUE_IDLE =  0x00,
258     FUS_STATE_VALUE_FW_UPGRD_ONGOING =  0x10,
259     FUS_STATE_VALUE_FW_UPGRD_ONGOING_END = 0x1F,    /* All values between 0x10 and 0x1F has the same meaning */
260     FUS_STATE_VALUE_FUS_UPGRD_ONGOING =  0x20,
261     FUS_STATE_VALUE_FUS_UPGRD_ONGOING_END =  0x2F,  /* All values between 0x20 and 0x2F has the same meaning */
262     FUS_STATE_VALUE_SERVICE_ONGOING =  0x30,
263     FUS_STATE_VALUE_SERVICE_ONGOING_END =  0x3F,    /* All values between 0x30 and 0x3F has the same meaning */
264     FUS_STATE_VALUE_ERROR =  0xFF,
265   };
266 
267 #define SHCI_OPCODE_C2_FUS_RESERVED1         (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED1)
268 /** No command parameters */
269 /** No response parameters*/
270 
271 #define SHCI_OPCODE_C2_FUS_FW_UPGRADE   (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_FW_UPGRADE)
272   /** No structure for command parameters */
273   /** No response parameters*/
274 
275 #define SHCI_OPCODE_C2_FUS_FW_DELETE   (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_FW_DELETE)
276 /** No command parameters */
277 /** No response parameters*/
278 
279 #define SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY    (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_UPDATE_AUTH_KEY)
280   typedef PACKED_STRUCT{
281   uint8_t KeySize;
282   uint8_t KeyData[64];
283   } SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t;
284 
285   /** No response parameters*/
286 
287 #define SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY    (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOCK_AUTH_KEY)
288 /** No command parameters */
289 /** No response parameters*/
290 
291 #define SHCI_OPCODE_C2_FUS_STORE_USR_KEY    (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_STORE_USR_KEY)
292   /** Command parameters */
293   /* List of supported key type */
294   enum
295   {
296     KEYTYPE_NONE =  0x00,
297     KEYTYPE_SIMPLE = 0x01,
298     KEYTYPE_MASTER = 0x02,
299     KEYTYPE_ENCRYPTED = 0x03,
300   };
301 
302   /* List of supported key size */
303   enum
304   {
305     KEYSIZE_16 =  16,
306     KEYSIZE_32 = 32,
307   };
308 
309   typedef PACKED_STRUCT{
310   uint8_t KeyType;
311   uint8_t KeySize;
312   uint8_t KeyData[32 + 12];
313   } SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t;
314 
315   /** Response parameters*/
316   /** It responds a 1 byte value holding the index given for the stored key */
317 
318 #define SHCI_OPCODE_C2_FUS_LOAD_USR_KEY         (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOAD_USR_KEY)
319   /** Command parameters */
320   /** 1 byte holding the key index value */
321 
322   /** No response parameters*/
323 
324 #define SHCI_OPCODE_C2_FUS_START_WS             (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_START_WS)
325 /** No command parameters */
326 /** No response parameters*/
327 
328 #define SHCI_OPCODE_C2_FUS_RESERVED2            (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED2)
329 /** No command parameters */
330 /** No response parameters*/
331 
332 #define SHCI_OPCODE_C2_FUS_RESERVED3            (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED3)
333 /** No command parameters */
334 /** No response parameters*/
335 
336 #define SHCI_OPCODE_C2_FUS_LOCK_USR_KEY         (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOCK_USR_KEY)
337   /** Command parameters */
338   /** 1 byte holding the key index value */
339 
340   /** No response parameters*/
341 
342 #define SHCI_OPCODE_C2_FUS_UNLOAD_USR_KEY       (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_UNLOAD_USR_KEY)
343 /** No command parameters */
344 /** 1 byte holding the key index value */
345 
346 #define SHCI_OPCODE_C2_FUS_ACTIVATE_ANTIROLLBACK  (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_ACTIVATE_ANTIROLLBACK)
347 /** No command parameters */
348 /** No response parameters*/
349 
350 #define SHCI_OPCODE_C2_FUS_RESERVED7            (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED7)
351 /** No command parameters */
352 /** No response parameters*/
353 
354 #define SHCI_OPCODE_C2_FUS_RESERVED8            (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED8)
355 /** No command parameters */
356 /** No response parameters*/
357 
358 #define SHCI_OPCODE_C2_FUS_RESERVED9            (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED9)
359 /** No command parameters */
360 /** No response parameters*/
361 
362 #define SHCI_OPCODE_C2_FUS_RESERVED10           (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED10)
363 /** No command parameters */
364 /** No response parameters*/
365 
366 #define SHCI_OPCODE_C2_FUS_RESERVED11           (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED11)
367 /** No command parameters */
368 /** No response parameters*/
369 
370 #define SHCI_OPCODE_C2_FUS_RESERVED12           (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED12)
371 /** No command parameters */
372 /** No response parameters*/
373 
374 #define SHCI_OPCODE_C2_BLE_INIT                 (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_INIT)
375   /** THE ORDER SHALL NOT BE CHANGED    */
376   typedef PACKED_STRUCT{
377   uint8_t* pBleBufferAddress;   /**< NOT USED - shall be set to 0 */
378   uint32_t BleBufferSize;       /**< NOT USED - shall be set to 0 */
379 
380   /**
381    * NumAttrRecord
382    * Maximum number of attribute records related to all the required characteristics (excluding the services)
383    * that can be stored in the GATT database, for the specific BLE user application.
384    * For each characteristic, the number of attribute records goes from two to five depending on the characteristic properties:
385    *    - minimum of two (one for declaration and one for the value)
386    *    - add one more record for each additional property: notify or indicate, broadcast, extended property.
387    * The total calculated value must be increased by 9, due to the records related to the standard attribute profile and
388    * GAP service characteristics, and automatically added when initializing GATT and GAP layers
389    *  - Min value: <number of user attributes> + 9
390    *  - Max value: depending on the GATT database defined by user application
391    */
392   uint16_t NumAttrRecord;
393 
394   /**
395    * NumAttrServ
396    * Defines the maximum number of services that can be stored in the GATT database. Note that the GAP and GATT services
397    * are automatically added at initialization so this parameter must be the number of user services increased by two.
398    *    - Min value: <number of user service> + 2
399    *    - Max value: depending GATT database defined by user application
400    */
401   uint16_t NumAttrServ;
402 
403   /**
404    * AttrValueArrSize
405    * NOTE: This parameter is ignored by the CPU2 when the parameter "Options" is set to "LL_only" ( see Options description in that structure )
406    *
407    * Size of the storage area for the attribute values.
408    * Each characteristic contributes to the attrValueArrSize value as follows:
409    *    - Characteristic value length plus:
410    *        + 5 bytes if characteristic UUID is 16 bits
411    *        + 19 bytes if characteristic UUID is 128 bits
412    *        + 2 bytes if characteristic has a server configuration descriptor
413    *        + 2 bytes * NumOfLinks if the characteristic has a client configuration descriptor
414    *        + 2 bytes if the characteristic has extended properties
415    * Each descriptor contributes to the attrValueArrSize value as follows:
416    *    - Descriptor length
417    */
418   uint16_t AttrValueArrSize;
419 
420   /**
421    * NumOfLinks
422    * Maximum number of BLE links supported
423    *    - Min value: 1
424    *    - Max value: 8
425    */
426   uint8_t NumOfLinks;
427 
428   /**
429    * ExtendedPacketLengthEnable
430    * Disable/enable the extended packet length BLE 5.0 feature
431    *    - Disable: 0
432    *    - Enable: 1
433    */
434   uint8_t ExtendedPacketLengthEnable;
435 
436   /**
437    * PrWriteListSize
438    * NOTE: This parameter is ignored by the CPU2 when the parameter "Options" is set to "LL_only" ( see Options description in that structure )
439    *
440    * Maximum number of supported "prepare write request"
441    *    - Min value: given by the macro DEFAULT_PREP_WRITE_LIST_SIZE
442    *    - Max value: a value higher than the minimum required can be specified, but it is not recommended
443    */
444   uint8_t PrWriteListSize;
445 
446   /**
447    * MblockCount
448    * NOTE: This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter "Options" is set to "LL_only"
449    * ( see Options description in that structure )
450    *
451    * Number of allocated memory blocks for the BLE stack
452    *     - Min value: given by the macro MBLOCKS_CALC
453    *     - Max value: a higher value can improve data throughput performance, but uses more memory
454    */
455   uint8_t MblockCount;
456 
457   /**
458    * AttMtu
459    * NOTE: This parameter is ignored by the CPU2 when the parameter "Options" is set to "LL_only" ( see Options description in that structure )
460    *
461    * Maximum ATT MTU size supported
462    *     - Min value: 23
463    *     - Max value: 512
464    */
465   uint16_t AttMtu;
466 
467   /**
468    * PeripheralSca
469    * The sleep clock accuracy (ppm value) that used in BLE connected Peripheral mode to calculate the window widening
470    * (in combination with the sleep clock accuracy sent by master in CONNECT_REQ PDU),
471    * refer to BLE 5.0 specifications - Vol 6 - Part B - chap 4.5.7 and 4.2.2
472    *     - Min value: 0
473    *     - Max value: 500 (worst possible admitted by specification)
474    */
475   uint16_t PeripheralSca;
476 
477   /**
478    * CentralSca
479    * The sleep clock accuracy handled in Central mode. It is used to determine the connection and advertising events timing.
480    * It is transmitted to the slave in CONNEC_REQ PDU used by the slave to calculate the window widening,
481    * see PeripheralSca and Bluetooth Core Specification v5.0 Vol 6 - Part B - chap 4.5.7 and 4.2.2
482    * Possible values:
483    *    - 251 ppm to 500 ppm: 0
484    *    - 151 ppm to 250 ppm: 1
485    *    - 101 ppm to 150 ppm: 2
486    *    - 76 ppm to 100 ppm: 3
487    *    - 51 ppm to 75 ppm: 4
488    *    - 31 ppm to 50 ppm: 5
489    *    - 21 ppm to 30 ppm: 6
490    *    - 0 ppm to 20 ppm: 7
491    */
492   uint8_t CentralSca;
493 
494   /**
495    * LsSource
496    * Some information for Low speed clock mapped in bits field
497    * - bit 0:   1: Calibration for the RF system wakeup clock source   0: No calibration for the RF system wakeup clock source
498    * - bit 1:   1: STM32W5M Module device                              0: Other devices as STM32WBxx SOC, STM32WB1M module
499    * - bit 2:   1: HSE/1024 Clock config                               0: LSE Clock config
500    */
501   uint8_t LsSource;
502 
503   /**
504    * MaxConnEventLength
505    * This parameter determines the maximum duration of a slave connection event. When this duration is reached the slave closes
506    * the current connections event (whatever is the CE_length parameter specified by the master in HCI_CREATE_CONNECTION HCI command),
507    * expressed in units of 625/256 us (~2.44 us)
508    *    - Min value: 0 (if 0 is specified, the master and slave perform only a single TX-RX exchange per connection event)
509    *    - Max value: 1638400 (4000 ms). A higher value can be specified (max 0xFFFFFFFF) but results in a maximum connection time
510    *      of 4000 ms as specified. In this case the parameter is not applied, and the predicted CE length calculated on slave is not shortened
511    */
512   uint32_t MaxConnEventLength;
513 
514   /**
515    * HsStartupTime
516    * Startup time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us).
517    *    - Min value: 0
518    *    - Max value:  820 (~2 ms). A higher value can be specified, but the value that implemented in stack is forced to ~2 ms
519    */
520   uint16_t HsStartupTime;
521 
522   /**
523    * ViterbiEnable
524    * Viterbi implementation in BLE LL reception.
525    *    - 0: Enable
526    *    - 1: Disable
527    */
528   uint8_t ViterbiEnable;
529 
530   /**
531    * Options flags
532    * - bit 0:   1: LL only                          0: LL + host
533    * - bit 1:   1: no service change desc.          0: with service change desc.
534    * - bit 2:   1: device name Read-Only            0: device name R/W
535    * - bit 3:   1: extended advertizing supported   0: extended advertizing not supported
536    * - bit 4:   1: CS Algo #2 supported             0: CS Algo #2 not supported
537    * - bit 5:   1: Reduced GATT database in NVM     0: Full GATT database in NVM
538    * - bit 6:   1: GATT caching is used             0: GATT caching is not used
539    * - bit 7:   1: LE Power Class 1                 0: LE Power Class 2-3
540    * - other bits: complete with Options_extension flag
541    */
542   uint8_t Options;
543 
544   /**
545    * HwVersion
546    * Reserved for future use - shall be set to 0
547    */
548   uint8_t HwVersion;
549 
550   /**
551    * Maximum number of connection-oriented channels in initiator mode.
552    * Range: 0 .. 64
553    */
554   uint8_t max_coc_initiator_nbr;
555 
556   /**
557    * Minimum transmit power in dBm supported by the Controller.
558    * Range: -127 .. 20
559    */
560   int8_t min_tx_power;
561 
562   /**
563    * Maximum transmit power in dBm supported by the Controller.
564    * Range: -127 .. 20
565    */
566   int8_t max_tx_power;
567 
568    /**
569    * RX model configuration
570    * - bit 0:   1: agc_rssi model improved vs RF blockers    0: Legacy agc_rssi model
571    * - other bits: reserved ( shall be set to 0)
572    */
573   uint8_t rx_model_config;
574 
575   /* Maximum number of advertising sets.
576    * Range: 1 .. 8 with limitation:
577    * This parameter is linked to max_adv_data_len such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based
578    * on Max Extended advertising configuration supported.
579    * This parameter is considered by the CPU2 when Options has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set
580    */
581   uint8_t max_adv_set_nbr;
582 
583   /* Maximum advertising data length (in bytes)
584    * Range: 31 .. 1650 with limitation:
585    * This parameter is linked to max_adv_set_nbr such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based
586    * on Max Extended advertising configuration supported.
587    * This parameter is considered by the CPU2 when Options has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set
588    */
589   uint16_t max_adv_data_len;
590 
591   /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB.
592    * Range: -1280 .. 1280
593    */
594   int16_t tx_path_compens;
595 
596   /* RF RX Path Compensation Value (16-bit signed integer). Units: 0.1 dB.
597    * Range: -1280 .. 1280
598    */
599   int16_t rx_path_compens;
600 
601   /* BLE core specification version (8-bit unsigned integer).
602    * values as: 11(5.2), 12(5.3), 13(5.4)
603    */
604   uint8_t ble_core_version;
605 
606    /**
607    * Options flags extension
608    * - bit 0:   1: appearance Writable              0: appearance Read-Only
609    * - bit 1:   1: Enhanced ATT supported           0: Enhanced ATT not supported
610    * - other bits: reserved ( shall be set to 0)
611    */
612   uint8_t Options_extension;
613 
614       } SHCI_C2_Ble_Init_Cmd_Param_t;
615 
616   typedef PACKED_STRUCT{
617     SHCI_Header_t Header;       /** Does not need to be initialized by the user */
618     SHCI_C2_Ble_Init_Cmd_Param_t Param;
619   } SHCI_C2_Ble_Init_Cmd_Packet_t;
620 
621   /**
622    * Options
623    * Each definition below may be added together to build the Options value
624    * WARNING : Only one definition per bit shall be added to build the Options value
625    */
626 #define SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY                              (1<<0)
627 #define SHCI_C2_BLE_INIT_OPTIONS_LL_HOST                              (0<<0)
628 
629 #define SHCI_C2_BLE_INIT_OPTIONS_NO_SVC_CHANGE_DESC                   (1<<1)
630 #define SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC                 (0<<1)
631 
632 #define SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RO                       (1<<2)
633 #define SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW                       (0<<2)
634 
635 #define SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV                              (1<<3)
636 #define SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV                           (0<<3)
637 
638 #define SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2                             (1<<4)
639 #define SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2                          (0<<4)
640 
641 #define SHCI_C2_BLE_INIT_OPTIONS_REDUC_GATTDB_NVM                     (1<<5)
642 #define SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM                      (0<<5)
643 
644 #define SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_USED                    (1<<6)
645 #define SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED                 (0<<6)
646 
647 #define SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_1                        (1<<7)
648 #define SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3                      (0<<7)
649 
650   /**
651    * Options extension
652    * Each definition below may be added together to build the Options value
653    * WARNING : Only one definition per bit shall be added to build the Options value
654    */
655 #define SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_WRITABLE                  (1<<0)
656 #define SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_READONLY                  (0<<0)
657 
658 #define SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_SUPPORTED               (1<<1)
659 #define SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_NOTSUPPORTED            (0<<1)
660 
661     /**
662    * RX models configuration
663    */
664 #define SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY                     (0<<0)
665 #define SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_BLOCKER                    (1<<0)
666 
667   /**
668    * BLE core version
669    */
670 #define SHCI_C2_BLE_INIT_BLE_CORE_5_2               11
671 #define SHCI_C2_BLE_INIT_BLE_CORE_5_3               12
672 #define SHCI_C2_BLE_INIT_BLE_CORE_5_4               13
673 
674    /**
675    * LsSource information
676    */
677 #define SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB                     (0<<0)
678 #define SHCI_C2_BLE_INIT_CFG_BLE_LS_CALIB                       (1<<0)
679 #define SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV                   (0<<1)
680 #define SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV                  (1<<1)
681 #define SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE                     (0<<2)
682 #define SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_HSE_1024                (1<<2)
683 
684 #define SHCI_OPCODE_C2_THREAD_INIT              (( SHCI_OGF << 10) + SHCI_OCF_C2_THREAD_INIT)
685 /** No command parameters */
686 /** No response parameters*/
687 
688 #define SHCI_OPCODE_C2_DEBUG_INIT              (( SHCI_OGF << 10) + SHCI_OCF_C2_DEBUG_INIT)
689   /** Command parameters */
690     typedef PACKED_STRUCT
691     {
692       uint8_t thread_config;
693       uint8_t ble_config;
694       uint8_t mac_802_15_4_config;
695       uint8_t zigbee_config;
696     } SHCI_C2_DEBUG_TracesConfig_t;
697 
698     typedef PACKED_STRUCT
699     {
700       uint8_t ble_dtb_cfg;
701   /**
702    * sys_dbg_cfg1 options flag
703    * - bit 0:   0: IP BLE core in LP mode    1: IP BLE core in run mode (no LP supported)
704    * - bit 1:   0: CPU2 STOP mode Enable     1: CPU2 STOP mode Disable
705    * - bit [2-7]: bits reserved ( shall be set to 0)
706    */
707       uint8_t sys_dbg_cfg1;
708       uint8_t reserved[2];
709       uint16_t STBY_DebugGpioaPinList;
710       uint16_t STBY_DebugGpiobPinList;
711       uint16_t STBY_DebugGpiocPinList;
712       uint16_t STBY_DtbGpioaPinList;
713       uint16_t STBY_DtbGpiobPinList;
714     } SHCI_C2_DEBUG_GeneralConfig_t;
715 
716     typedef PACKED_STRUCT{
717       uint8_t *pGpioConfig;
718       uint8_t *pTracesConfig;
719       uint8_t *pGeneralConfig;
720       uint8_t GpioConfigSize;
721       uint8_t TracesConfigSize;
722       uint8_t GeneralConfigSize;
723     } SHCI_C2_DEBUG_init_Cmd_Param_t;
724 
725     typedef PACKED_STRUCT{
726       SHCI_Header_t Header;       /** Does not need to be initialized by the user */
727       SHCI_C2_DEBUG_init_Cmd_Param_t Param;
728     } SHCI_C2_DEBUG_Init_Cmd_Packet_t;
729     /** No response parameters*/
730 
731     /**
732    * Options
733    * Each definition below may be added together to build the Options value
734    * WARNING : Only one definition per bit shall be added to build the Options value
735    */
736 #define SHCI_C2_DEBUG_OPTIONS_IPCORE_LP                              (0<<0)
737 #define SHCI_C2_DEBUG_OPTIONS_IPCORE_NO_LP                           (1<<0)
738 
739 #define SHCI_C2_DEBUG_OPTIONS_CPU2_STOP_EN                           (0<<1)
740 #define SHCI_C2_DEBUG_OPTIONS_CPU2_STOP_DIS                          (1<<1)
741 
742 
743 #define SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY     (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_ACTIVITY)
744   /** Command parameters */
745     typedef enum
746     {
747       ERASE_ACTIVITY_OFF =  0x00,
748       ERASE_ACTIVITY_ON = 0x01,
749     } SHCI_EraseActivity_t;
750 
751     /** No response parameters*/
752 
753 #define SHCI_OPCODE_C2_CONCURRENT_SET_MODE          (( SHCI_OGF << 10) + SHCI_OCF_C2_CONCURRENT_SET_MODE)
754 /** command parameters */
755     typedef enum
756     {
757       BLE_ENABLE,
758       THREAD_ENABLE,
759       ZIGBEE_ENABLE,
760       MAC_ENABLE,
761     } SHCI_C2_CONCURRENT_Mode_Param_t;
762       /** No response parameters*/
763 
764 #define SHCI_OPCODE_C2_CONCURRENT_GET_NEXT_BLE_EVT_TIME          (( SHCI_OGF << 10) + SHCI_OCF_C2_CONCURRENT_GET_NEXT_BLE_EVT_TIME)
765 /** command parameters */
766     typedef PACKED_STRUCT
767     {
768       uint32_t relative_time;
769     } SHCI_C2_CONCURRENT_GetNextBleEvtTime_Param_t;
770       /** No response parameters*/
771 
772 #define SHCI_OPCODE_C2_CONCURRENT_ENABLE_NEXT_802154_EVT_NOTIFICATION    (( SHCI_OGF << 10) + SHCI_OCF_C2_CONCURRENT_ENABLE_NEXT_802154_EVT_NOTIFICATION)
773     /** No command parameters */
774     /** No response parameters*/
775 
776 #define SHCI_OPCODE_C2_FLASH_STORE_DATA          (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_STORE_DATA)
777 #define SHCI_OPCODE_C2_FLASH_ERASE_DATA          (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_DATA)
778 /** command parameters */
779     typedef enum
780     {
781       BLE_IP,
782       THREAD_IP,
783       ZIGBEE_IP,
784     } SHCI_C2_FLASH_Ip_t;
785       /** No response parameters*/
786 
787 #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER    (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER)
788 
789 #define SHCI_OPCODE_C2_MAC_802_15_4_INIT        (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT)
790 
791 #define SHCI_OPCODE_C2_REINIT                   (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT)
792 
793 #define SHCI_OPCODE_C2_ZIGBEE_INIT              (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT)
794 
795 #define SHCI_OPCODE_C2_LLD_TESTS_INIT           (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT)
796 
797 #define SHCI_OPCODE_C2_BLE_LLD_INIT             (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT)
798 
799 #define SHCI_OPCODE_C2_EXTPA_CONFIG             (( SHCI_OGF << 10) + SHCI_OCF_C2_EXTPA_CONFIG)
800   /** Command parameters */
801     enum
802     {
803       EXT_PA_ENABLED_LOW,
804       EXT_PA_ENABLED_HIGH,
805     }/* gpio_polarity */;
806 
807     enum
808     {
809       EXT_PA_DISABLED,
810       EXT_PA_ENABLED,
811     }/* gpio_status */;
812 
813     typedef PACKED_STRUCT{
814       uint32_t gpio_port;
815       uint16_t gpio_pin_number;
816       uint8_t gpio_polarity;
817       uint8_t gpio_status;
818     } SHCI_C2_EXTPA_CONFIG_Cmd_Param_t;
819 
820     /** No response parameters*/
821 
822 #define SHCI_OPCODE_C2_SET_FLASH_ACTIVITY_CONTROL   (( SHCI_OGF << 10) + SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL)
823   /** Command parameters */
824     typedef enum
825     {
826       FLASH_ACTIVITY_CONTROL_PES,
827       FLASH_ACTIVITY_CONTROL_SEM7,
828     }SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t;
829 
830     /** No response parameters*/
831 
832 #define SHCI_OPCODE_C2_CONFIG   (( SHCI_OGF << 10) + SHCI_OCF_C2_CONFIG)
833 
834   /** Command parameters */
835     typedef PACKED_STRUCT{
836       uint8_t PayloadCmdSize;
837       uint8_t Config1;
838       uint8_t EvtMask1;
839       uint8_t Spare1;
840       uint32_t BleNvmRamAddress;
841       uint32_t ThreadNvmRamAddress;
842       uint16_t RevisionID;
843       uint16_t DeviceID;
844     } SHCI_C2_CONFIG_Cmd_Param_t;
845 
846 #define SHCI_OPCODE_C2_802_15_4_DEINIT    (( SHCI_OGF << 10) + SHCI_OCF_C2_802_15_4_DEINIT)
847 
848 #define SHCI_OPCODE_C2_SET_SYSTEM_CLOCK   (( SHCI_OGF << 10) + SHCI_OCF_C2_SET_SYSTEM_CLOCK)
849   /** Command parameters */
850     typedef enum
851     {
852       SET_SYSTEM_CLOCK_HSE_TO_PLL,
853       SET_SYSTEM_CLOCK_PLL_ON_TO_HSE,
854       SET_SYSTEM_CLOCK_PLL_OFF_TO_HSE,
855     }SHCI_C2_SET_SYSTEM_CLOCK_Cmd_Param_t;
856 
857 /**
858  * PayloadCmdSize
859  * Value that shall be used
860  */
861 #define SHCI_C2_CONFIG_PAYLOAD_CMD_SIZE   (sizeof(SHCI_C2_CONFIG_Cmd_Param_t) - 1)
862 
863 /**
864  * Device revision ID
865  */
866 #define SHCI_C2_CONFIG_CUT2_0                        (0x2000)
867 #define SHCI_C2_CONFIG_CUT2_1                        (0x2001)
868 #define SHCI_C2_CONFIG_CUT2_2                        (0x2003)
869 
870 /**
871  * Device ID
872  */
873 #define SHCI_C2_CONFIG_STM32WB55xx                    (0x495)
874 #define SHCI_C2_CONFIG_STM32WB15xx                    (0x494)
875 
876 /**
877  * Config1
878  * Each definition below may be added together to build the Config1 value
879  * WARNING : Only one definition per bit shall be added to build the Config1 value
880  */
881 #define SHCI_C2_CONFIG_CONFIG1_BIT0_BLE_NVM_DATA_TO_INTERNAL_FLASH    (0<<0)
882 #define SHCI_C2_CONFIG_CONFIG1_BIT0_BLE_NVM_DATA_TO_SRAM              (1<<0)
883 #define SHCI_C2_CONFIG_CONFIG1_BIT1_THREAD_NVM_DATA_TO_INTERNAL_FLASH (0<<1)
884 #define SHCI_C2_CONFIG_CONFIG1_BIT1_THREAD_NVM_DATA_TO_SRAM           (1<<1)
885 
886 /**
887  * EvtMask1
888  * Each definition below may be added together to build the EvtMask1 value
889  */
890 #define SHCI_C2_CONFIG_EVTMASK1_BIT0_ERROR_NOTIF_ENABLE               (1<<0)
891 #define SHCI_C2_CONFIG_EVTMASK1_BIT1_BLE_NVM_RAM_UPDATE_ENABLE        (1<<1)
892 #define SHCI_C2_CONFIG_EVTMASK1_BIT2_THREAD_NVM_RAM_UPDATE_ENABLE     (1<<2)
893 #define SHCI_C2_CONFIG_EVTMASK1_BIT3_NVM_START_WRITE_ENABLE           (1<<3)
894 #define SHCI_C2_CONFIG_EVTMASK1_BIT4_NVM_END_WRITE_ENABLE             (1<<4)
895 #define SHCI_C2_CONFIG_EVTMASK1_BIT5_NVM_START_ERASE_ENABLE           (1<<5)
896 #define SHCI_C2_CONFIG_EVTMASK1_BIT6_NVM_END_ERASE_ENABLE             (1<<6)
897 
898 /**
899  * BleNvmRamAddress
900  * The buffer shall have a size of BLE_NVM_SRAM_SIZE number of 32bits
901  * The buffer shall be allocated in SRAM2
902  */
903 #define BLE_NVM_SRAM_SIZE (507)
904 
905 /**
906  * ThreadNvmRamAddress
907  * The buffer shall have a size of THREAD_NVM_SRAM_SIZE number of 32bits
908  * The buffer shall be allocated in SRAM2
909  */
910 #define THREAD_NVM_SRAM_SIZE (1016)
911 
912 
913   /** No response parameters*/
914 
915  /* Exported type --------------------------------------------------------*/
916 #define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD    (0xA94656B9)
917 
918 /*
919   *   At startup, the information relative to the wireless binary are stored in RAM through a structure defined by
920   *   MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part)
921   *   each of those coded on 32 bits as shown on the table below:
922   *
923   *
924   *               |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |
925   *               -------------------------------------------------------------------------------------------------
926   * Version       |   Major version       |    Minor version      |    Sub version        | Branch    |ReleaseType|
927   *               -------------------------------------------------------------------------------------------------
928   * MemorySize    |   SRAM2B (kB)         |    SRAM2A (kB)        |    SRAM1 (kB)         | FLASH (4kb)           |
929   *               -------------------------------------------------------------------------------------------------
930   * Info stack    |   Reserved            |    Reserved           |    Reserved           | Type (MAC,Thread,BLE) |
931   *               -------------------------------------------------------------------------------------------------
932   * Reserved      |   Reserved            |    Reserved           |    Reserved           | Reserved              |
933   *               -------------------------------------------------------------------------------------------------
934   *
935   */
936 
937 /* Field Version */
938 #define INFO_VERSION_MAJOR_OFFSET                   24
939 #define INFO_VERSION_MAJOR_MASK                     0xff000000
940 #define INFO_VERSION_MINOR_OFFSET                   16
941 #define INFO_VERSION_MINOR_MASK                     0x00ff0000
942 #define INFO_VERSION_SUB_OFFSET                     8
943 #define INFO_VERSION_SUB_MASK                       0x0000ff00
944 #define INFO_VERSION_BRANCH_OFFSET                  4
945 #define INFO_VERSION_BRANCH_MASK                    0x0000000f0
946 #define INFO_VERSION_TYPE_OFFSET                    0
947 #define INFO_VERSION_TYPE_MASK                      0x00000000f
948 
949 #define INFO_VERSION_TYPE_RELEASE                   1
950 
951 /* Field Memory */
952 #define INFO_SIZE_SRAM2B_OFFSET                     24
953 #define INFO_SIZE_SRAM2B_MASK                       0xff000000
954 #define INFO_SIZE_SRAM2A_OFFSET                     16
955 #define INFO_SIZE_SRAM2A_MASK                       0x00ff0000
956 #define INFO_SIZE_SRAM1_OFFSET                      8
957 #define INFO_SIZE_SRAM1_MASK                        0x0000ff00
958 #define INFO_SIZE_FLASH_OFFSET                      0
959 #define INFO_SIZE_FLASH_MASK                        0x000000ff
960 
961 /* Field stack information */
962 #define INFO_STACK_TYPE_OFFSET                      0
963 #define INFO_STACK_TYPE_MASK                        0x000000ff
964 #define INFO_STACK_TYPE_NONE                        0
965 
966 #define INFO_STACK_TYPE_BLE_FULL                    0x01
967 #define INFO_STACK_TYPE_BLE_HCI                     0x02
968 #define INFO_STACK_TYPE_BLE_LIGHT                   0x03
969 #define INFO_STACK_TYPE_BLE_BEACON                  0x04
970 #define INFO_STACK_TYPE_BLE_BASIC                   0x05
971 #define INFO_STACK_TYPE_BLE_FULL_EXT_ADV            0x06
972 #define INFO_STACK_TYPE_BLE_HCI_EXT_ADV             0x07
973 #define INFO_STACK_TYPE_THREAD_FTD                  0x10
974 #define INFO_STACK_TYPE_THREAD_MTD                  0x11
975 #define INFO_STACK_TYPE_ZIGBEE_FFD                  0x30
976 #define INFO_STACK_TYPE_ZIGBEE_RFD                  0x31
977 #define INFO_STACK_TYPE_MAC                         0x40
978 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC       0x50
979 #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYNAMIC      0x51
980 #define INFO_STACK_TYPE_BLE_THREAD_LIGHT_DYNAMIC    0x52
981 #define INFO_STACK_TYPE_802154_LLD_TESTS            0x60
982 #define INFO_STACK_TYPE_802154_PHY_VALID            0x61
983 #define INFO_STACK_TYPE_BLE_PHY_VALID               0x62
984 #define INFO_STACK_TYPE_BLE_LLD_TESTS               0x63
985 #define INFO_STACK_TYPE_BLE_RLV                     0x64
986 #define INFO_STACK_TYPE_802154_RLV                  0x65
987 #define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC       0x70
988 #define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_STATIC       0x71
989 #define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC      0x78
990 #define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_DYNAMIC      0x79
991 #define INFO_STACK_TYPE_RLV                         0x80
992 #define INFO_STACK_TYPE_BLE_MAC_STATIC              0x90
993 
994 typedef struct {
995 /**
996  * Wireless Info
997  */
998   uint8_t VersionMajor;
999   uint8_t VersionMinor;
1000   uint8_t VersionSub;
1001   uint8_t VersionBranch;
1002   uint8_t VersionReleaseType;
1003   uint8_t MemorySizeSram2B;     /*< Multiple of 1K */
1004   uint8_t MemorySizeSram2A;     /*< Multiple of 1K */
1005   uint8_t MemorySizeSram1;      /*< Multiple of 1K */
1006   uint8_t MemorySizeFlash;      /*< Multiple of 4K */
1007   uint8_t StackType;
1008 /**
1009  * Fus Info
1010  */
1011   uint8_t FusVersionMajor;
1012   uint8_t FusVersionMinor;
1013   uint8_t FusVersionSub;
1014   uint8_t FusMemorySizeSram2B;  /*< Multiple of 1K */
1015   uint8_t FusMemorySizeSram2A;  /*< Multiple of 1K */
1016   uint8_t FusMemorySizeFlash;   /*< Multiple of 4K */
1017 }WirelessFwInfo_t;
1018 
1019 
1020 /* Exported functions ------------------------------------------------------- */
1021 
1022   /**
1023   * SHCI_C2_FUS_GetState
1024   * @brief Read the FUS State
1025   *        If the user is not interested by the Error code response, a null value may
1026   *        be passed as parameter
1027   *
1028   *        Note:  This command is fully supported only by the FUS.
1029   *               When the wireless firmware receives that command, it responds SHCI_FUS_CMD_NOT_SUPPORTED the first time.
1030   *               When the wireless firmware receives that command a second time, it reboots the full device with the FUS running on CPU2
1031   *
1032   * @param  p_rsp : return the error code when the FUS State Value = 0xFF
1033   * @retval FUS State Values
1034   */
1035   uint8_t SHCI_C2_FUS_GetState( SHCI_FUS_GetState_ErrorCode_t *p_rsp );
1036 
1037   /**
1038   * SHCI_C2_FUS_FwUpgrade
1039   * @brief Request the FUS to install the CPU2 firmware update
1040   *        Note:  This command is only supported by the FUS.
1041   *
1042   * @param  fw_src_add: Address of the firmware image location
1043   * @param  fw_dest_add: Address of the firmware destination
1044   * @retval Status
1045   */
1046   SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade( uint32_t fw_src_add,  uint32_t fw_dest_add );
1047 
1048   /**
1049   * SHCI_C2_FUS_FwDelete
1050   * @brief Delete the wireless stack on CPU2
1051   *        Note:  This command is only supported by the FUS.
1052   *
1053   * @param  None
1054   * @retval Status
1055   */
1056   SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete( void );
1057 
1058   /**
1059   * SHCI_C2_FUS_UpdateAuthKey
1060   * @brief Request the FUS to update the authentication key
1061   *        Note:  This command is only supported by the FUS.
1062   *
1063   * @param  pCmdPacket
1064   * @retval Status
1065   */
1066   SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam );
1067 
1068   /**
1069   * SHCI_C2_FUS_LockAuthKey
1070   * @brief Request the FUS to prevent any future update of the authentication key
1071   *        Note:  This command is only supported by the FUS.
1072   *
1073   * @param  None
1074   * @retval Status
1075   */
1076   SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey( void );
1077 
1078   /**
1079   * SHCI_C2_FUS_StoreUsrKey
1080   * @brief Request the FUS to store the user key
1081   *        Note:  This command is supported by both the FUS and the wireless stack.
1082   *
1083   * @param  pParam : command parameter
1084   * @param  p_key_index : Index allocated by the FUS to the stored key
1085   *
1086   * @retval Status
1087   */
1088   SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey( SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index );
1089 
1090   /**
1091   * SHCI_C2_FUS_LoadUsrKey
1092   * @brief Request the FUS to load the user key into the AES
1093   *        Note:  This command is supported by both the FUS and the wireless stack.
1094   *
1095   * @param  key_index : index of the user key to load in AES1
1096   * @retval Status
1097   */
1098   SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey( uint8_t key_index );
1099 
1100   /**
1101   * SHCI_C2_FUS_StartWs
1102   * @brief Request the FUS to reboot on the wireless stack
1103   *        Note:  This command is only supported by the FUS.
1104   *
1105   * @param  None
1106   * @retval Status
1107   */
1108   SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void );
1109 
1110   /**
1111   * SHCI_C2_FUS_LockUsrKey
1112   * @brief Request the FUS to lock the user key so that it cannot be updated later on
1113   *        Note:  This command is supported by both the FUS and the wireless stack.
1114   *
1115   * @param  key_index : index of the user key to lock
1116   * @retval Status
1117   */
1118   SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index );
1119 
1120   /**
1121   * SHCI_C2_FUS_UnloadUsrKey
1122   * @brief Request the FUS to Unload the user key so that the CPU1 may use the AES with another Key
1123   *        Note:  This command is supported by both the FUS and the wireless stack.
1124   *
1125   * @param  key_index : index of the user key to unload
1126   * @retval Status
1127   */
1128   SHCI_CmdStatus_t SHCI_C2_FUS_UnloadUsrKey( uint8_t key_index );
1129 
1130   /**
1131   * SHCI_C2_FUS_ActivateAntiRollback
1132   * @brief Request the FUS to enable the AntiRollback feature so that it is not possible to update the wireless firmware
1133   *        with an older version than the current one.
1134   *        Note:
1135   *               - This command is only supported by the FUS.
1136   *               - Once this feature is enabled, it is not possible anymore to disable it.
1137   *
1138   * @param  None
1139   * @retval Status
1140   */
1141   SHCI_CmdStatus_t SHCI_C2_FUS_ActivateAntiRollback( void );
1142 
1143   /**
1144   * SHCI_C2_BLE_Init
1145   * @brief Provides parameters and starts the BLE Stack
1146   *
1147   * @param  pCmdPacket : Parameters are described SHCI_C2_Ble_Init_Cmd_Packet_t declaration
1148   * @retval Status
1149   */
1150   SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket );
1151 
1152   /**
1153   * SHCI_C2_THREAD_Init
1154   * @brief Starts the THREAD Stack
1155   *
1156   * @param  None
1157   * @retval Status
1158   */
1159   SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void );
1160 
1161   /**
1162   * SHCI_C2_LLDTESTS_Init
1163   * @brief Starts the LLD tests CLI
1164   *
1165   * @param  param_size : Nb of bytes
1166   * @param  p_param : pointer with data to give from M4 to M0
1167   * @retval Status
1168   */
1169   SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param );
1170 
1171     /**
1172   * SHCI_C2_BLE_LLD_Init
1173   * @brief Starts the LLD tests BLE
1174   *
1175   * @param  param_size : Nb of bytes
1176   * @param  p_param : pointer with data to give from M4 to M0
1177   * @retval Status
1178   */
1179   SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param );
1180 
1181     /**
1182   * SHCI_C2_ZIGBEE_Init
1183   * @brief Starts the Zigbee Stack
1184   *
1185   * @param  None
1186   * @retval Status
1187   */
1188   SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void );
1189 
1190   /**
1191   * SHCI_C2_DEBUG_Init
1192   * @brief Starts the Traces
1193   *
1194   * @param  None
1195   * @retval Status
1196   */
1197   SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket );
1198 
1199   /**
1200   * SHCI_C2_FLASH_EraseActivity
1201   * @brief Provides the information of the start and the end of a flash erase window on the CPU1
1202   *        The protection will be active until next end of radio event.
1203   *
1204   * @param  erase_activity: Start/End of erase activity
1205   * @retval Status
1206   */
1207   SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activity );
1208 
1209   /**
1210   * SHCI_C2_CONCURRENT_SetMode
1211   * @brief Enable/Disable Thread on CPU2 (M0+)
1212   *
1213   * @param  Mode: BLE or Thread enable flag
1214   * @retval Status
1215   */
1216   SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode );
1217 
1218   /**
1219   * SHCI_C2_CONCURRENT_GetNextBleEvtTime
1220   * @brief Get the next BLE event date (relative time)
1221   *
1222   * @param  Command Packet
1223   * @retval None
1224   */
1225   SHCI_CmdStatus_t SHCI_C2_CONCURRENT_GetNextBleEvtTime( SHCI_C2_CONCURRENT_GetNextBleEvtTime_Param_t *pParam );
1226 
1227   /**
1228   * SHCI_C2_CONCURRENT_EnableNext_802154_EvtNotification
1229   * @brief Activate the next 802.15.4 event notification (one shot)
1230   *
1231   * @param  None
1232   * @retval None
1233   */
1234   SHCI_CmdStatus_t SHCI_C2_CONCURRENT_EnableNext_802154_EvtNotification( void );
1235 
1236   /**
1237   * SHCI_C2_FLASH_StoreData
1238   * @brief Store Data in Flash
1239   *
1240   * @param  Ip: BLE or THREAD
1241   * @retval Status
1242   */
1243   SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip );
1244 
1245   /**
1246   * SHCI_C2_FLASH_EraseData
1247   * @brief Erase Data in Flash
1248   *
1249   * @param  Ip: BLE or THREAD
1250   * @retval Status
1251   */
1252   SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip );
1253 
1254   /**
1255   * SHCI_C2_RADIO_AllowLowPower
1256   * @brief Allow or forbid IP_radio (802_15_4 or BLE) to enter in low power mode.
1257   *
1258   * @param  Ip: BLE or 802_15_5
1259   * @param  FlagRadioLowPowerOn: True or false
1260   * @retval Status
1261   */
1262   SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t  FlagRadioLowPowerOn);
1263 
1264 
1265   /**
1266   * SHCI_C2_MAC_802_15_4_Init
1267   * @brief Starts the MAC 802.15.4 on M0
1268   *
1269   * @param  None
1270   * @retval Status
1271   */
1272   SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void );
1273 
1274   /**
1275    * SHCI_GetWirelessFwInfo
1276    * @brief This function read back the information relative to the wireless binary loaded.
1277    *         Refer yourself to MB_WirelessFwInfoTable_t structure to get the significance
1278    *         of the different parameters returned.
1279    * @param  pWirelessInfo : Pointer to WirelessFwInfo_t.
1280    *
1281    * @retval SHCI_Success
1282    */
1283   SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo );
1284 
1285   /**
1286   * SHCI_C2_Reinit
1287   * @brief This is required to allow the CPU1 to fake a set C2BOOT when it has already been set.
1288   *        In order to fake a C2BOOT, the CPU1 shall :
1289   *        - Send SHCI_C2_Reinit()
1290   *        - call SEV instruction
1291   *        WARNING:
1292   *        This function is intended to be used by the SBSFU
1293   *
1294   * @param  None
1295   * @retval Status
1296   */
1297   SHCI_CmdStatus_t SHCI_C2_Reinit( void );
1298 
1299   /**
1300   * SHCI_C2_ExtpaConfig
1301   * @brief Send the Ext PA configuration
1302   *        When the CPU2 receives the command, it controls the Ext PA as requested by the configuration
1303   *        This configures only which IO is used to enable/disable the ExtPA and the associated polarity
1304   *        This command has no effect on the other IO that is used to control the mode of the Ext PA (Rx/Tx)
1305   *
1306   * @param gpio_port: GPIOx where x can be (A..F) to select the GPIO peripheral for STM32WBxx family
1307   * @param gpio_pin_number: This parameter can be one of GPIO_PIN_x (= LL_GPIO_PIN_x)  where x can be (0..15).
1308   * @param gpio_polarity: This parameter can be either
1309   *                       - EXT_PA_ENABLED_LOW: ExtPA is enabled when GPIO is low
1310   *                       - EXT_PA_ENABLED_HIGH: ExtPA is enabled when GPIO is high
1311   * @param gpio_status: This parameter can be either
1312   *                       - EXT_PA_DISABLED: Stop driving the ExtPA
1313   *                       - EXT_PA_ENABLED: Drive the ExtPA according to radio activity
1314   *                                          (ON before the Event and OFF at the end of the event)
1315   * @retval Status
1316   */
1317   SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status);
1318 
1319   /**
1320   * SHCI_C2_SetFlashActivityControl
1321   * @brief Set the mechanism to be used on CPU2 to prevent the CPU1 to either write or erase in flash
1322   *
1323   * @param Source: It can be one of the following list
1324   *                -  FLASH_ACTIVITY_CONTROL_PES : The CPU2 set the PES bit to prevent the CPU1 to either read or write in flash
1325   *                -  FLASH_ACTIVITY_CONTROL_SEM7 : The CPU2 gets the semaphore 7 to prevent the CPU1 to either read or write in flash.
1326   *                                                 This requires the CPU1 to first get semaphore 7 before erasing or writing the flash.
1327   *
1328   * @retval Status
1329   */
1330   SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source);
1331 
1332   /**
1333   * SHCI_C2_Config
1334   * @brief Send the system configuration to the CPU2
1335   *
1336   * @param pCmdPacket: address of the buffer holding following parameters
1337   *                    uint8_t PayloadCmdSize : Size of the payload - shall be SHCI_C2_CONFIG_PAYLOAD_CMD_SIZE
1338   *                    uint8_t Config1 :
1339   *                     - bit0 :  0 - BLE NVM Data  data are flushed in internal secure flash
1340   *                               1 - BLE NVM Data are written in SRAM cache pointed by BleNvmRamAddress
1341   *                     - bit1 :  0 - THREAD NVM Data  data are flushed in internal secure flash
1342   *                               1 - THREAD NVM Data are written in SRAM cache pointed by ThreadNvmRamAddress
1343   *                     - bit2 to bit7 : Unused, shall be set to 0
1344   *                    uint8_t EvtMask1 :
1345   *                            When a bit is set to 0, the event is not reported
1346   *                            bit0 : Asynchronous Event with Sub Evt Code 0x9201 (= SHCI_SUB_EVT_ERROR_NOTIF)
1347   *                            ...
1348   *                            bit31 : Asynchronous Event with Sub Evt Code 0x9220
1349   *                    uint8_t Spare1 : Unused, shall be set to 0
1350   *                    uint32_t BleNvmRamAddress :
1351   *                               Only considered when Config1.bit0 = 1
1352   *                               When set to 0, data are kept in internal SRAM on CPU2
1353   *                               Otherwise, data are copied in the cache pointed by BleNvmRamAddress
1354   *                               The size of the buffer shall be BLE_NVM_SRAM_SIZE (number of 32bits)
1355   *                               The buffer shall be allocated in SRAM2
1356   *                    uint32_t ThreadNvmRamAddress :
1357   *                               Only considered when Config1.bit1 = 1
1358   *                               When set to 0, data are kept in internal SRAM on CPU2
1359   *                               Otherwise, data are copied in the cache pointed by ThreadNvmRamAddress
1360   *                               The size of the buffer shall be THREAD_NVM_SRAM_SIZE (number of 32bits)
1361   *                               The buffer shall be allocated in SRAM1
1362   *
1363   *                    Please check macro definition to be used for this function
1364   *                    They are defined in this file next to the definition of SHCI_OPCODE_C2_CONFIG
1365   *
1366   * @retval Status
1367   */
1368   SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket);
1369 
1370   /**
1371    * SHCI_C2_802_15_4_DeInit
1372    * @brief Deinit 802.15.4 layer (to be used before entering StandBy mode)
1373    *
1374    * @param  None
1375    * @retval Status
1376    */
1377   SHCI_CmdStatus_t SHCI_C2_802_15_4_DeInit( void );
1378 
1379   /**
1380   * SHCI_C2_SetSystemClock
1381   * @brief Request CPU2 to change system clock
1382   *
1383   * @param clockSel: It can be one of the following list
1384   *                -  SET_SYSTEM_CLOCK_HSE_TO_PLL : CPU2 set system clock to PLL, PLL must be configured and started before.
1385   *                -  SET_SYSTEM_CLOCK_PLL_ON_TO_HSE : CPU2 set System clock to HSE, PLL is still ON after command execution.
1386   *                -  SET_SYSTEM_CLOCK_PLL_OFF_TO_HSE : CPU2 set System clock to HSE, PLL is turned OFF after command execution.
1387   *
1388   * @retval Status
1389   */
1390   SHCI_CmdStatus_t SHCI_C2_SetSystemClock( SHCI_C2_SET_SYSTEM_CLOCK_Cmd_Param_t clockSel );
1391 
1392 
1393 #ifdef __cplusplus
1394 }
1395 #endif
1396 
1397 #endif /*__SHCI_H */
1398 
1399 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
1400