1 /***************************************************************************/ /**
2  * @file
3  * @brief
4  *******************************************************************************
5  * # License
6  * <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
7  *******************************************************************************
8  *
9  * SPDX-License-Identifier: Zlib
10  *
11  * The licensor of this software is Silicon Laboratories Inc.
12  *
13  * This software is provided 'as-is', without any express or implied
14  * warranty. In no event will the authors be held liable for any damages
15  * arising from the use of this software.
16  *
17  * Permission is granted to anyone to use this software for any purpose,
18  * including commercial applications, and to alter it and redistribute it
19  * freely, subject to the following restrictions:
20  *
21  * 1. The origin of this software must not be misrepresented; you must not
22  *    claim that you wrote the original software. If you use this software
23  *    in a product, an acknowledgment in the product documentation would be
24  *    appreciated but is not required.
25  * 2. Altered source versions must be plainly marked as such, and must not be
26  *    misrepresented as being the original software.
27  * 3. This notice may not be removed or altered from any source distribution.
28  *
29  ******************************************************************************/
30 #include <stdint.h>
31 #pragma once
32 
33 /** \addtogroup SI91X_LOAD_IMAGE_TYPES
34   * @{ */
35 /// Load NWP firmware.
36 #define LOAD_NWP_FW '1'
37 
38 /// Load default NWP firmware active low.
39 /// @note This is ONLY applicable in Network Co-Processor (NCP) mode for Si91x devices.
40 #define LOAD_DEFAULT_NWP_FW_ACTIVE_LOW 0x71
41 /** @} */
42 
43 /** \addtogroup SI91X_TLS_DEFINE
44   * \ingroup SL_SI91X_CONSTANTS
45   * @{ */
46 /*=========================================================================*/
47 // TLS feature parameters description !//
48 /*=========================================================================*/
49 /// Bit to enable SSL feature
50 #define SL_SI91X_ENABLE_TLS BIT(0)
51 
52 /// Bitmap to enable TLS version 1.0
53 #define SL_SI91X_TLS_V_1_0 BIT(2)
54 
55 /// Bitmap to enable TLS version 1.2
56 #define SL_SI91X_TLS_V_1_2 BIT(3)
57 
58 /// Bitmap to enable TLS version 1.1
59 #define SL_SI91X_TLS_V_1_1 BIT(4)
60 
61 #if defined(SLI_SI917) || defined(DOXYGEN) || defined(SLI_SI915)
62 /// Bitmap to enable TLS version 1.3
63 #define SL_SI91X_TLS_V_1_3 BIT(8)
64 #endif
65 /** @} */
66 
67 /** \addtogroup SI91X_HTTP_CLIENT_DEFINE
68   * \ingroup SL_SI91X_CONSTANTS
69   * @{ */
70 /*=========================================================================*/
71 // HTTP Client feature parameters description !//
72 /*=========================================================================*/
73 /// Bit to enable NULL delimiter for HTTP buffer instead of comma
74 #define SL_SI91X_ENABLE_NULL_DELIMETER BIT(1)
75 
76 /// HTTP client post big data support feature bitmap
77 #define SL_SI91X_SUPPORT_HTTP_POST_DATA BIT(5)
78 
79 /// HTTP version 1.1 support feature bitmap
80 #define SL_SI91X_HTTP_V_1_1 BIT(6)
81 
82 /// Bit to enable user given content type in extended header
83 #define SL_SI91X_HTTP_USER_DEFINED_CONTENT_TYPE BIT(7)
84 
85 /// To specify index of SSL cert to be used for HTTPS, for index 0 leave them unset
86 #define SL_SI91X_HTTPS_CERTIFICATE_INDEX_1 BIT(9)
87 /// To specify index of SSL cert to be used for HTTPS, for index 0 leave them unset
88 #define SL_SI91X_HTTPS_CERTIFICATE_INDEX_2 BIT(10)
89 
90 /// To enable SNI
91 #define SL_SI91X_HTTPS_USE_SNI BIT(11)
92 /** @} */
93 
94 //! @cond Doxygen_Suppress
95 // Upgrade images
96 #define BURN_NWP_FW 'B'
97 #define BURN_M4_FW  '4'
98 
99 // M4 FW image number for Bootloader
100 #define M4_FW_IMAGE_NUMBER (1 << 8)
101 
102 // Bootloader selects default NWP FW image number
103 #define SELECT_DEFAULT_NWP_FW_IMAGE_NUMBER '5'
104 
105 #define RSI_PING_PONG_CHUNK_SIZE 4096
106 #define RSI_REG_READ             0xD1
107 #define RSI_REG_WRITE            0xD2
108 #define RSI_SEND_RPS_FILE        '2'
109 #define RSI_FWUP_SUCCESSFUL      'S'
110 #define RSI_EOF_REACHED          'E'
111 #define RSI_PONG_VALID           'O'
112 #define RSI_PING_VALID           'I'
113 #define RSI_PONG_WRITE           0xD4
114 #define RSI_PING_WRITE           0xD5
115 #define RSI_PONG_AVAIL           'O'
116 #define RSI_PING_AVAIL           'I'
117 
118 #define RSI_PING_BUFFER_ADDR 0x418000
119 #define RSI_PONG_BUFFER_ADDR 0x419000
120 
121 #define RSI_ACTIVE_LOW_INTR  0x2
122 #define RSI_ACTIVE_HIGH_INTR 0x0
123 
124 #define RSI_OPERMODE_RESPONSE_WAIT_TIME      (1000) // Milliseconds
125 #define RSI_SEND_RAW_DATA_RESPONSE_WAIT_TIME (1000) // Milliseconds
126 
127 #ifndef SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME
128 #define SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME 1000 // 1 second to wait for a command buffer
129 #endif
130 
131 //STM 32 Init Sequence
132 #define SL_SI91X_INIT_CMD 0x005c4a12
133 
134 // SPI transfer type (8 BIT/32 BIT)
135 #define RSI_MODE_8BIT  0
136 #define RSI_MODE_32BIT 1
137 
138 // frame descriptor length
139 #define RSI_FRAME_DESC_LEN 16
140 
141 // SPI interrupt register values
142 // Are these the same as other buses?
143 // buffer full indication register value from module
144 #ifndef RSI_BUFFER_FULL
145 #define RSI_BUFFER_FULL 0x01
146 #endif
147 // buffer empty indication register value from module
148 #define RSI_BUFFER_EMPTY 0x02
149 // RX packet pending register value from module
150 #define RSI_RX_PKT_PENDING 0x08
151 // Assertion Interrupt indication from module
152 #define RSI_ASSERT_INTR 0x80
153 
154 //Bootloader defines
155 #define SL_SI91X_SAFE_UPGRADE_ADDR        0x55408
156 #define SL_SI91X_SAFE_UPGRADE             BIT(12)
157 #define SL_SI91X_FW_START_OF_FILE         BIT(0)
158 #define SL_SI91X_FW_END_OF_FILE           BIT(1)
159 #define SL_SI91X_MIN_CHUNK_SIZE           4096
160 #define SL_SI91X_LOOP_COUNT_UPGRADE_IMAGE 0xFFFF
161 #define SL_SI91X_RESET_LOOP_COUNTER(X)    X = 0;
162 #define SL_SI91X_WHILE_LOOP(X, Y)         while ((X++) < (int32_t)Y)
163 #define SL_SI91X_CHECK_LOOP_COUNTER(X, Y) \
164   {                                       \
165     if (X >= Y)                           \
166       return -1;                          \
167   }
168 
169 //***************************** Macros for Crypto Start **********************************/
170 
171 #define SL_SI91X_KEY_BUFFER_SIZE 32
172 #define SL_SI91X_TAG_SIZE        16
173 #define SL_SI91X_IV_SIZE         16
174 
175 // ECDH defines
176 #define ECDH_BUFFER_SIZE 32
177 
178 // TRNG defines
179 #define TRNG_INIT       1
180 #define TRNG_ENTROPY    2
181 #define TRNG_KEY        3
182 #define TRNG_GENERATION 4
183 
184 #define TRNG_INIT_MSG_LENGTH 16
185 #define TRNG_KEY_SIZE        4
186 #define TRNG_TEST_DATA_SIZE  64
187 
188 // CCM defines
189 #define SL_SI91X_CCM_IV_MIN_SIZE  7
190 #define SL_SI91X_CCM_IV_MAX_SIZE  13
191 #define SL_SI91X_CCM_IV_BUFF_LEN  16  // SL_SI91X_CCM_IV_MAX_SIZE + 3 Bytes for Padding.
192 #define SL_SI91X_CCM_AD_MAX_SIZE  128 // Limiting header length to 128.
193 #define SL_SI91X_CCM_MSG_MAX_SIZE 1200
194 
195 // GCM defines
196 #define SL_SI91X_GCM_IV_SIZE      12
197 #define SL_SI91X_GCM_AD_MAX_SIZE  128
198 #define SL_SI91X_GCM_MSG_MAX_SIZE 1400
199 
200 // Chachapoly defines
201 #define SL_SI91X_KEYR_SIZE               16
202 #define SL_SI91X_KEYS_SIZE               16
203 #define SL_SI91X_CHACHAPOLY_IV_SIZE      12
204 #define SL_SI91X_CHACHAPOLY_MSG_MAX_SIZE 1200
205 
206 //ECDSA defines
207 #define SL_SI91X_PRIVATE_KEY_MAX_SIZE 64
208 #define SL_SI91X_PUBLIC_KEY_MAX_SIZE  136
209 #define SL_SI91X_SIGNATURE_MAX_SIZE   128
210 #define SL_SI91X_ECDSA_MSG_MAX_SIZE   1000
211 
212 // NWP Configuration defines
213 #define SL_SI91X_XO_CTUNE_FROM_HOST        BIT(0)
214 #define SL_SI91X_ENABLE_NWP_WDT_FROM_HOST  BIT(1)
215 #define SL_SI91X_DISABLE_NWP_WDT_FROM_HOST BIT(2)
216 
217 //NWP Get configuration defines
218 #define GET_OPN_BOARD_CONFIG 1
219 
220 //***************************** Macros for Crypto End **********************************/
221 
222 // Command packet 'unused' bytes
223 #define SLI_SI91X_COMMAND_FLAGS_INDEX    10
224 #define SLI_SI91X_COMMAND_RESPONSE_INDEX 11
225 
226 typedef struct {
227   uint32_t buffer_full : 1;
228   uint32_t ready_to_transmit : 1;
229   uint32_t _reserved2 : 1;
230   uint32_t rx_packet_pending : 1;
231   uint32_t _reserved4 : 1;
232   uint32_t _reserved5 : 1;
233   uint32_t _reserved6 : 1;
234   uint32_t _reserved7 : 1;
235 } sl_si91x_interrupt_status_t;
236 
237 // Timeout used in get_channel API
238 #define SL_SI91X_GET_CHANNEL_TIMEOUT 30200
239 //! @endcond
240 
241 /** \addtogroup SL_SI91X_CONSTANTS
242   * @{ */
243 /// Si91x specific keepalive types.
244 typedef enum {
245   SL_SI91X_AP_KEEP_ALIVE_DISABLE = 0, ///< Disable keepalive functionality.
246   SL_SI91X_AP_DEAUTH_BASED_KEEP_ALIVE =
247     1, ///< AP performs keepalive functionality based on the RX packets received from its stations.
248   ///< If no packet is received from the station within the AP keep alive timeout period, the AP disconnects the station.
249   SL_SI91X_AP_NULL_BASED_KEEP_ALIVE =
250     3 ///< AP performs keepalive functionality by sending a NULL DATA packet to the station.
251       ///< If no ACK is received from the station after a specific number of retries, the AP discards the station.
252 } sl_si91x_ap_keepalive_type_t;
253 
254 /// Assertion type must be in the range of 0 to 15 (both included)
255 typedef enum {
256   SL_SI91X_ASSERTION_TYPE_LMAC = 0, ///< Assertion type specific to the LMAC core.
257   SL_SI91X_ASSERTION_TYPE_SME  = 1, ///< Assertion type specific to the SME (Station Management Entity) core.
258   SL_SI91X_ASSERTION_TYPE_UMAC = 2, ///< Assertion type specific to the UMAC core.
259   SL_SI91X_ASSERTION_TYPE_NETX = 4, ///< Assertion type specific to the NETX (Networking Stack) core.
260   SL_SI91X_ASSERTION_TYPE_CA =
261     8, ///< Enables critical assertion indication and provides a RAM dump during critical assertions.
262   SL_SI91X_ASSERTION_TYPE_ALL = 15 ///< Enables assertion for all cores.
263 } sl_si91x_assertion_type_t;
264 
265 /// Assertion level must be in the range of 0 to 15 (both included)
266 typedef enum {
267   SL_SI91X_ASSERTION_LEVEL_MIN = 0, ///< Minimum assertion level. Indicates that an assertion is mandatory.
268   SL_SI91X_ASSERTION_LEVEL_SP  = 1, ///< Assertion for specific print messages, used for debugging or analysis.
269   SL_SI91X_ASSERTION_LEVEL_REC =
270     2, ///< Recoverable assertion level. Indicates that the system can recover from the assertion.
271   SL_SI91X_ASSERTION_LEVEL_INFO = 4, ///< Informational assertion level, used to log general information.
272   SL_SI91X_ASSERTION_LEVEL_MAX  = 15 ///< Maximum assertion level. Enables all types of print statements.
273 } sl_si91x_assertion_level_t;
274 /** @} */
275 
276 //! @cond Doxygen_Suppress
277 typedef enum {
278   SL_SI91X_RETURN_IMMEDIATELY              = 0,
279   SL_SI91X_WAIT_FOR_RESPONSE_BIT           = (1UL << 30),
280   SL_SI91X_WAIT_FOR_EVER                   = (1UL << 31),
281   SL_SI91X_WAIT_FOR_OTAF_RESPONSE          = (SL_SI91X_WAIT_FOR_RESPONSE_BIT | SL_SI91X_WAIT_FOR_EVER),
282   SL_SI91X_WAIT_FOR_SYNC_SCAN_RESULTS      = (SL_SI91X_WAIT_FOR_RESPONSE_BIT | 12000),
283   SL_SI91X_WAIT_FOR_COMMAND_RESPONSE       = (SL_SI91X_WAIT_FOR_RESPONSE_BIT | 1000),
284   SL_SI91X_WAIT_FOR_SOCKET_ACCEPT_RESPONSE = (SL_SI91X_WAIT_FOR_RESPONSE_BIT | 5000),
285   SL_SI91X_WAIT_FOR_COMMAND_SUCCESS        = 3000,
286   SL_SI91X_WAIT_FOR_DNS_RESOLUTION         = 20000,
287 } sl_si91x_wait_period_t;
288 
289 #define SL_SI91X_WAIT_FOR(x)          (sl_si91x_wait_period_t)(x)
290 #define SL_SI91X_WAIT_FOR_RESPONSE(x) (sl_si91x_wait_period_t)(SL_SI91X_WAIT_FOR_RESPONSE_BIT | (x))
291 
292 typedef enum {
293   // (7+/-1)dBm in 2.4GHz band
294   // (5+/-1)dBm in 5GHz band
295   SL_SI91X_LOW_POWER_LEVEL,
296 
297   // (5+/-1)dBm in 2.4GHz band
298   // (7+/-1)dBm in 5GHz band
299   SL_SI91X_MEDIUM_POWER_LEVEL,
300 
301   SL_SI91X_HIGH_POWER_LEVEL
302 } sl_si91x_transmit_power_level;
303 
304 /*====================================================*/
305 // Constant Defines
306 // SPI Status
307 #define RSI_SPI_SUCCESS       0x58
308 #define RSI_SPI_BUSY          0x54
309 #define RSI_SPI_FAIL          0x52
310 #define RSI_SUCCESS           0
311 #define RSI_ERROR_BUFFER_FULL -3 // module buffer full  error code
312 #define RSI_ERROR_IN_SLEEP    -4 // module in sleep error code
313 
314 //SPI Internal Register Offset
315 #define RSI_SPI_INT_REG_ADDR    0x00 //@ register access method
316 #define RSI_SPI_MODE_REG_ADDR   0x08 //@ register access method
317 #define RSI_SPI_LENGTH_REG_ADDR 0x20
318 
319 #define RSI_INT_MASK_REG_ADDR 0x41050000 // Interrupt mask register
320 #define RSI_INT_CLR_REG_ADDR  0x22000010 // Interrupt clear register
321 
322 // Packet queue identifiers
323 #define RSI_COMMON_Q    0
324 #define RSI_ZB_Q        1
325 #define RSI_BT_Q        2
326 #define RSI_WLAN_MGMT_Q 4
327 #define RSI_WLAN_DATA_Q 5
328 #ifdef SAPIS_BT_STACK_ON_HOST
329 #define RSI_BT_INT_MGMT_Q 6
330 #define RSI_BT_HCI_Q      7
331 #endif
332 
333 // Event IDs
334 #define RSI_RX_EVENT       0 // RX event number used in the driver
335 #define RSI_TX_EVENT       1 // TX event number used in the driver
336 #define RSI_SOCKET_EVENT   2 // Socket event number used in the driver
337 #define RSI_MAX_NUM_EVENTS 3 // Max number events used in the driver
338 
339 #define RSI_HOST_INTF_REG_OUT    0x4105003C
340 #define RSI_HOST_INTF_REG_IN     0x41050034
341 #define RSI_HOST_INTF_STATUS_REG 0x41050004
342 
343 // si91x boot results
344 #define RSI_EOF_REACHED                          'E'
345 #define RSI_BOOTUP_OPTIONS_LAST_CONFIG_NOT_SAVED 0xF1
346 #define RSI_BOOTUP_OPTIONS_CHECKSUM_FAIL         0xF2
347 #define RSI_INVALID_OPTION                       0xF3
348 #define RSI_CHECKSUM_SUCCESS                     0xAA
349 #define RSI_CHECKSUM_FAILURE                     0xCC
350 #define RSI_CHECKSUM_INVALID_ADDRESS             0x4C
351 #define VALID_FIRMWARE_NOT_PRESENT               0x23
352 #define RSI_BOOTLOADER_VERSION_1P0               0x10
353 #define RSI_BOOTLOADER_VERSION_1P1               0x11
354 #define RSI_ROM_VERSION_1P0                      1
355 #define RSI_ROM_VERSION_1P1                      2
356 
357 #define SLI_WIFI_REGISTER_VALID (0xAB)
358 
359 #define RSI_HOST_INTERACT_REG_VALID    (0xAB << 8)
360 #define RSI_HOST_INTERACT_REG_VALID_FW (0xA0 << 8)
361 
362 #define CONFIG_RTSTHRESHOLD 1
363 #define RSI_RTS_THRESHOLD   2346
364 
365 #define RSI_SEND_RAW_DATA    0x1
366 #define RSI_RECEIVE_RAW_DATA 0x0
367 
368 // enumeration for command request used in common control block
369 typedef enum {
370   // Common command requests
371   RSI_COMMON_REQ_OPERMODE       = 0x10,
372   RSI_COMMON_REQ_ANTENNA_SELECT = 0x1B,
373   RSI_COMMON_REQ_FEATURE_FRAME  = 0xC8,
374   RSI_COMMON_REQ_PWRMODE        = 0x15,
375   // Reusing RSI_WLAN_REQ_FW_VERSION as RSI_COMMON_REQ_FW_VERSION
376   RSI_COMMON_REQ_FW_VERSION     = 0x49,
377   RSI_COMMON_REQ_GET_EFUSE_DATA = 0xA0,
378 
379   // Unimplemented common command requests
380   RSI_COMMON_REQ_SOFT_RESET            = 0x1C,
381   RSI_COMMON_REQ_ENCRYPT_CRYPTO        = 0x76,
382   RSI_COMMON_REQ_UART_FLOW_CTRL_ENABLE = 0xA4,
383   RSI_COMMON_REQ_TA_M4_COMMANDS        = 0xB0,
384   RSI_COMMON_REQ_DEBUG_LOG             = 0x26
385 #ifdef RSI_WAC_MFI_ENABLE
386   ,
387   RSI_COMMON_REQ_IAP_GET_CERTIFICATE   = 0xB6,
388   RSI_COMMON_REQ_IAP_INIT              = 0xB7,
389   RSI_COMMON_REQ_IAP_GENERATE_SIGATURE = 0xB8
390 #endif
391 
392 #ifdef SLI_PUF_ENABLE
393   ,
394   RSI_COMMON_REQ_PUF_ENROLL      = 0xD0,
395   RSI_COMMON_REQ_PUF_DIS_ENROLL  = 0xD1,
396   RSI_COMMON_REQ_PUF_START       = 0xD2,
397   RSI_COMMON_REQ_PUF_SET_KEY     = 0xD3,
398   RSI_COMMON_REQ_PUF_DIS_SET_KEY = 0xD4,
399   RSI_COMMON_REQ_PUF_GET_KEY     = 0xD5,
400   RSI_COMMON_REQ_PUF_DIS_GET_KEY = 0xD6,
401   RSI_COMMON_REQ_PUF_LOAD_KEY    = 0xD7,
402   RSI_COMMON_REQ_AES_ENCRYPT     = 0xD8,
403   RSI_COMMON_REQ_AES_DECRYPT     = 0xD9,
404   RSI_COMMON_REQ_AES_MAC         = 0xDA,
405   RSI_COMMON_REQ_PUF_INTR_KEY    = 0xCE
406 #endif
407   ,
408   RSI_COMMON_REQ_SWITCH_PROTO  = 0x77,
409   RSI_COMMON_REQ_GET_RAM_DUMP  = 0x92,
410   RSI_COMMON_REQ_ASSERT        = 0xE1,
411   RSI_COMMON_REQ_SET_RTC_TIMER = 0xE9,
412   RSI_COMMON_REQ_GET_RTC_TIMER = 0xF2,
413   RSI_COMMON_REQ_SET_CONFIG    = 0xBA,
414   RSI_COMMON_REQ_GET_CONFIG    = 0x0C
415 #ifdef CONFIGURE_GPIO_FROM_HOST
416   ,
417   RSI_COMMON_REQ_GPIO_CONFIG = 0x28
418 #endif
419 #ifdef FW_LOGGING_ENABLE
420   ,
421   RSI_COMMON_REQ_DEVICE_LOGGING_INIT = 0x82
422 #endif
423 } rsi_common_cmd_request_t;
424 
425 typedef enum {
426   // Common command responses
427   RSI_COMMON_RSP_OPERMODE       = 0x10,
428   RSI_COMMON_RSP_ANTENNA_SELECT = 0x1B,
429   RSI_COMMON_RSP_FEATURE_FRAME  = 0xC8,
430   RSI_COMMON_RSP_CARDREADY      = 0x89,
431   RSI_COMMON_RSP_PWRMODE        = 0x15,
432 
433   // Unimplemented common command responses
434   RSI_COMMON_RSP_CLEAR                 = 0x00,
435   RSI_COMMON_RSP_SOFT_RESET            = 0x1C,
436   RSI_COMMON_RSP_ULP_NO_RAM_RETENTION  = 0xCD,
437   RSI_COMMON_RSP_ASYNCHRONOUS          = 0xFF,
438   RSI_COMMON_RSP_ENCRYPT_CRYPTO        = 0x76,
439   RSI_COMMON_RSP_UART_FLOW_CTRL_ENABLE = 0xA4,
440   RSI_COMMON_RSP_TA_M4_COMMANDS        = 0xB0,
441   RSI_COMMON_RSP_DEBUG_LOG             = 0x26
442 #ifdef SLI_PUF_ENABLE
443   ,
444   RSI_COMMON_RSP_PUF_ENROLL      = 0xD0,
445   RSI_COMMON_RSP_PUF_DIS_ENROLL  = 0xD1,
446   RSI_COMMON_RSP_PUF_START       = 0xD2,
447   RSI_COMMON_RSP_PUF_SET_KEY     = 0xD3,
448   RSI_COMMON_RSP_PUF_DIS_SET_KEY = 0xD4,
449   RSI_COMMON_RSP_PUF_GET_KEY     = 0xD5,
450   RSI_COMMON_RSP_PUF_DIS_GET_KEY = 0xD6,
451   RSI_COMMON_RSP_PUF_LOAD_KEY    = 0xD7,
452   RSI_COMMON_RSP_AES_ENCRYPT     = 0xD8,
453   RSI_COMMON_RSP_AES_DECRYPT     = 0xD9,
454   RSI_COMMON_RSP_AES_MAC         = 0xDA,
455   RSI_COMMON_RSP_PUF_INTR_KEY    = 0xCE
456 #endif
457 
458 #ifdef RSI_WAC_MFI_ENABLE
459   ,
460   RSI_COMMON_RSP_IAP_GET_CERTIFICATE   = 0xB6,
461   RSI_COMMON_RSP_IAP_INIT              = 0xB7,
462   RSI_COMMON_RSP_IAP_GENERATE_SIGATURE = 0xB8
463 #endif
464   // Reusing RSI_WLAN_REQ_FW_VERSION as RSI_COMMON_REQ_FW_VERSION
465   ,
466   RSI_COMMON_RSP_GET_EFUSE_DATA = 0xA0,
467   RSI_COMMON_RSP_FW_VERSION     = 0x49,
468   RSI_COMMON_RSP_SWITCH_PROTO   = 0x77,
469   RSI_COMMON_RSP_GET_RAM_DUMP   = 0x92,
470   RSI_COMMON_RSP_ASSERT         = 0xE1,
471   RSI_COMMON_RSP_SET_RTC_TIMER  = 0xE9,
472   RSI_COMMON_RSP_GET_RTC_TIMER  = 0xF2,
473   RSI_COMMON_RSP_SET_CONFIG     = 0xBA,
474   RSI_COMMON_RSP_GET_CONFIG     = 0x0C
475 #ifdef CONFIGURE_GPIO_FROM_HOST
476   ,
477   RSI_COMMON_RSP_GPIO_CONFIG = 0x28
478 #endif
479 #ifdef FW_LOGGING_ENABLE
480   ,
481   RSI_COMMON_RSP_DEVICE_LOGGING_INIT = 0x82
482 #endif
483 } rsi_common_cmd_response_t;
484 
485 // enumeration for WLAN command request codes
486 typedef enum {
487   // Wi-Fi commands
488   RSI_WLAN_REQ_CONFIG               = 0xBE,
489   RSI_WLAN_REQ_BAND                 = 0x11,
490   RSI_WLAN_REQ_INIT                 = 0x12,
491   RSI_WLAN_REQ_SCAN                 = 0x13,
492   RSI_WLAN_REQ_JOIN                 = 0x14,
493   RSI_WLAN_REQ_SET_MAC_ADDRESS      = 0x17,
494   RSI_WLAN_REQ_DISCONNECT           = 0x19,
495   RSI_WLAN_REQ_AP_STOP              = 0xAE,
496   RSI_WLAN_REQ_SET_REGION           = 0x1D,
497   RSI_WLAN_REQ_QUERY_NETWORK_PARAMS = 0x18,
498   RSI_WLAN_REQ_AP_CONFIGURATION     = 0x24,
499   RSI_WLAN_REQ_EVM_OFFSET           = 0x36,
500   RSI_WLAN_REQ_EVM_WRITE            = 0x37,
501   RSI_WLAN_REQ_RSSI                 = 0x3A,
502   RSI_WLAN_REQ_EAP_CONFIG           = 0x4C,
503   RSI_WLAN_REQ_FW_VERSION           = 0x49,
504   RSI_WLAN_REQ_MAC_ADDRESS          = 0x4A,
505   RSI_WLAN_REQ_QUERY_GO_PARAMS      = 0x4E,
506   RSI_WLAN_REQ_SET_CERTIFICATE      = 0x4D,
507   RSI_WLAN_REQ_BG_SCAN              = 0x6A,
508   RSI_WLAN_REQ_BEACON_STOP          = 0x63,
509   RSI_WLAN_REQ_WPS_METHOD           = 0x72,
510   RSI_WLAN_REQ_EFUSE_READ           = 0x73,
511   RSI_WLAN_REQ_ROAM_PARAMS          = 0x7B,
512   RSI_WLAN_REQ_RX_STATS             = 0xA2,
513   RSI_WLAN_REQ_RADIO                = 0x81,
514   RSI_WLAN_REQ_EXT_STATS            = 0x68,
515   RSI_WLAN_REQ_TWT_AUTO_CONFIG      = 0x2E,
516   RSI_WLAN_REQ_TWT_PARAMS           = 0x2F,
517   SL_WIFI_REQ_RESCHEDULE_TWT        = 0x3F,
518   RSI_WLAN_REQ_GAIN_TABLE           = 0x47,
519   RSI_WLAN_REQ_TX_TEST_MODE         = 0x7C,
520   RSI_WLAN_REQ_HOST_PSK             = 0xA5,
521   RSI_WLAN_REQ_SET_REGION_AP        = 0xBD,
522   RSI_WLAN_REQ_CALIB_WRITE          = 0xCA,
523   RSI_WLAN_REQ_FILTER_BCAST_PACKETS = 0xC9,
524   RSI_WLAN_REQ_CALIB_READ           = 0xCF,
525   RSI_WLAN_REQ_FULL_FW_VERSION      = 0xE0,
526   RSI_WLAN_REQ_HTTP_OTAF            = 0xF4,
527   RSI_WLAN_REQ_11AX_PARAMS          = 0xFF,
528 
529   // Network commands
530   RSI_WLAN_REQ_PING_PACKET           = 0x29,
531   RSI_WLAN_REQ_IPCONFV4              = 0x41,
532   RSI_WLAN_REQ_DNS_QUERY             = 0x44,
533   RSI_WLAN_REQ_HTTP_CLIENT_GET       = 0x51,
534   RSI_WLAN_REQ_HTTP_CLIENT_POST      = 0x52,
535   RSI_WLAN_REQ_HTTP_CLIENT_PUT       = 0x53,
536   RSI_WLAN_REQ_IPCONFV6              = 0x90,
537   RSI_WLAN_REQ_MULTICAST             = 0xB1,
538   RSI_WLAN_REQ_HTTP_ABORT            = 0xB3,
539   RSI_WLAN_REQ_HTTP_CREDENTIALS      = 0xB4,
540   RSI_WLAN_REQ_EMB_MQTT_CLIENT       = 0xCB,
541   RSI_WLAN_REQ_SNTP_CLIENT           = 0xE4,
542   RSI_WLAN_REQ_HTTP_CLIENT_POST_DATA = 0xEB,
543 
544   // Socket commands
545   RSI_WLAN_REQ_SOCKET_CREATE    = 0x42,
546   RSI_WLAN_REQ_SOCKET_CLOSE     = 0x43,
547   RSI_WLAN_REQ_SOCKET_READ_DATA = 0x6B,
548   RSI_WLAN_REQ_SOCKET_ACCEPT    = 0x6C,
549   RSI_WLAN_REQ_SOCKET_CONFIG    = 0xA7,
550   RSI_WLAN_REQ_SELECT_REQUEST   = 0x74,
551   RSI_WLAN_REQ_SET_SNI_EMBEDDED = 0x6E,
552 
553   // Unimplemented commands
554   RSI_WLAN_REQ_SET_SLEEP_TIMER      = 0x16,
555   RSI_WLAN_REQ_CFG_SAVE             = 0x20,
556   RSI_WLAN_REQ_AUTO_CONFIG_ENABLE   = 0x21,
557   RSI_WLAN_REQ_GET_CFG              = 0x22,
558   RSI_WLAN_REQ_USER_STORE_CONFIG    = 0x23,
559   RSI_WLAN_REQ_SET_WEP_KEYS         = 0x25,
560   RSI_WLAN_REQ_SET_PROFILE          = 0x31,
561   RSI_WLAN_REQ_GET_PROFILE          = 0x32,
562   RSI_WLAN_REQ_DELETE_PROFILE       = 0x33,
563   RSI_WLAN_REQ_SET_MULTICAST_FILTER = 0x40,
564   RSI_WLAN_REQ_CONNECTION_STATUS    = 0x48,
565   RSI_WLAN_REQ_CONFIGURE_P2P        = 0x4B,
566   RSI_WLAN_REQ_WIRELESS_FWUP        = 0x59,
567   RSI_WLAN_REQ_HT_CAPABILITIES      = 0x6D,
568   RSI_WLAN_REQ_REJOIN_PARAMS        = 0x6F,
569   RSI_WLAN_REQ_WMM_PS               = 0x97,
570   RSI_WLAN_REQ_FWUP                 = 0x99,
571 #ifdef RSI_WAC_MFI_ENABLE
572   RSI_WLAN_REQ_ADD_MFI_IE = 0xB5,
573 #endif
574 #ifndef SLI_SI91X_MCU_INTERFACE
575   RSI_WLAN_REQ_CERT_VALID = 0xBC,
576 #endif
577   RSI_WLAN_REQ_FREQ_OFFSET                  = 0xF3,
578   RSI_WLAN_REQ_DYNAMIC_POOL                 = 0xC7,
579   RSI_WLAN_REQ_MDNSD                        = 0xDB,
580   RSI_WLAN_REQ_GET_DPD_DATA                 = 0xDC,
581   RSI_WLAN_REQ_FTP                          = 0xE2,
582   RSI_WLAN_REQ_FTP_FILE_WRITE               = 0xE3,
583   RSI_WLAN_REQ_SMTP_CLIENT                  = 0xE6,
584   RSI_WLAN_REQ_OTA_FWUP                     = 0xEF,
585   RSI_WLAN_REQ_WEBPAGE_LOAD                 = 0x50,
586   RSI_WLAN_REQ_JSON_LOAD                    = 0x9c,
587   RSI_WLAN_REQ_WEBPAGE_ERASE                = 0x9A,
588   RSI_WLAN_REQ_JSON_OBJECT_ERASE            = 0x9B,
589   RSI_WLAN_REQ_WEBPAGE_CLEAR_ALL            = 0x7F,
590   RSI_WLAN_REQ_HOST_WEBPAGE_SEND            = 0x56,
591   RSI_WLAN_REQ_GET_RANDOM                   = 0xF8,
592   RSI_WLAN_REQ_POP3_CLIENT                  = 0xE7,
593   RSI_WLAN_REQ_DHCP_USER_CLASS              = 0xEC,
594   RSI_WLAN_REQ_TIMEOUT                      = 0xEA,
595   RSI_WLAN_REQ_GET_STATS                    = 0xF1,
596   RSI_WLAN_REQ_UPDATE_TCP_WINDOW            = 0xF5,
597   RSI_WLAN_REQ_DNS_UPDATE                   = 0xED,
598   RSI_WLAN_REQ_DNS_SERVER_ADD               = 0x55,
599   RSI_WLAN_REQ_TSF                          = 0x65,
600   RSI_WLAN_REQ_SET_TRANSCEIVER_CHANNEL      = 0x7A,
601   RSI_WLAN_REQ_TRANSCEIVER_PEER_LIST_UPDATE = 0x8B,
602   RSI_WLAN_REQ_TRANSCEIVER_CONFIG_PARAMS    = 0x8C,
603   RSI_WLAN_REQ_SET_TRANSCEIVER_MCAST_FILTER = 0x8D,
604   RSI_WLAN_REQ_TRANSCEIVER_FLUSH_DATA_Q     = 0x8E,
605 } rsi_wlan_cmd_request_t;
606 
607 // enumeration for WLAN command response codes
608 typedef enum {
609   // Wi-Fi command response
610   RSI_WLAN_RSP_BAND                 = 0x11,
611   RSI_WLAN_RSP_INIT                 = 0x12,
612   RSI_WLAN_RSP_SCAN                 = 0x13,
613   RSI_WLAN_RSP_JOIN                 = 0x14,
614   RSI_WLAN_RSP_SET_MAC_ADDRESS      = 0x17,
615   RSI_WLAN_RSP_QUERY_NETWORK_PARAMS = 0x18,
616   RSI_WLAN_RSP_DISCONNECT           = 0x19,
617   RSI_WLAN_RSP_AP_STOP              = 0xAE,
618   RSI_WLAN_RSP_SET_REGION           = 0x1D,
619   RSI_WLAN_RSP_AP_CONFIGURATION     = 0x24,
620   RSI_WLAN_RSP_TWT_AUTO_CONFIG      = 0x2E,
621   RSI_WLAN_RSP_TWT_PARAMS           = 0x2F,
622   SL_WIFI_RSP_RESCHEDULE_TWT        = 0x3F,
623   RSI_WLAN_RSP_EVM_OFFSET           = 0x36,
624   RSI_WLAN_RSP_EVM_WRITE            = 0x37,
625   RSI_WLAN_RSP_RSSI                 = 0x3A,
626   RSI_WLAN_RSP_GAIN_TABLE           = 0x47,
627   RSI_WLAN_RSP_FW_VERSION           = 0x49,
628   RSI_WLAN_RSP_MAC_ADDRESS          = 0x4A,
629   RSI_WLAN_RSP_EAP_CONFIG           = 0x4C,
630   RSI_WLAN_RSP_SET_CERTIFICATE      = 0x4D,
631   RSI_WLAN_RSP_QUERY_GO_PARAMS      = 0x4E,
632   RSI_WLAN_RSP_BEACON_STOP          = 0x63,
633   RSI_WLAN_RSP_BG_SCAN              = 0x6A,
634   RSI_WLAN_RSP_EXT_STATS            = 0x68, // Neither part 22q2 nor alpha 2
635   RSI_WLAN_RSP_EFUSE_READ           = 0x73,
636   RSI_WLAN_RSP_TX_TEST_MODE         = 0x7C,
637   RSI_WLAN_RSP_ROAM_PARAMS          = 0x7B,
638   RSI_WLAN_RSP_RADIO                = 0x81,
639   RSI_WLAN_RSP_RX_STATS             = 0xA2,
640   RSI_WLAN_RSP_HOST_PSK             = 0xA5,
641   RSI_WLAN_RSP_SCAN_RESULTS         = 0xAF,
642   RSI_WLAN_RSP_CONFIG               = 0XBE,
643   RSI_WLAN_RSP_SET_REGION_AP        = 0xBD,
644   RSI_WLAN_RSP_FILTER_BCAST_PACKETS = 0xC9,
645   RSI_WLAN_RSP_CALIB_READ           = 0xCF,
646   RSI_WLAN_RSP_FULL_FW_VERSION      = 0xE0,
647   RSI_WLAN_RSP_GET_STATS            = 0xF1,
648   RSI_WLAN_RSP_HTTP_OTAF            = 0xF4,
649   RSI_WLAN_RSP_11AX_PARAMS          = 0xFF,
650 
651   // Network command response
652   RSI_WLAN_RSP_PING_PACKET           = 0x29,
653   RSI_WLAN_RSP_IPCONFV4              = 0x41,
654   RSI_WLAN_RSP_DNS_QUERY             = 0x44,
655   RSI_WLAN_RSP_HTTP_CLIENT_GET       = 0x51,
656   RSI_WLAN_RSP_HTTP_CLIENT_POST      = 0x52,
657   RSI_WLAN_RSP_HTTP_CLIENT_PUT       = 0x53,
658   RSI_WLAN_RSP_IPCONFV6              = 0xA1,
659   RSI_WLAN_RSP_MULTICAST             = 0xB1,
660   RSI_WLAN_RSP_HTTP_ABORT            = 0xB3,
661   RSI_WLAN_RSP_HTTP_CREDENTIALS      = 0xB4,
662   RSI_WLAN_RSP_EMB_MQTT_CLIENT       = 0xCB,
663   RSI_WLAN_RSP_SNTP_CLIENT           = 0xE4,
664   RSI_WLAN_RSP_HTTP_CLIENT_POST_DATA = 0xEB,
665 
666   // Socket command response
667   RSI_WLAN_RSP_SOCKET_CREATE    = 0x42,
668   RSI_WLAN_RSP_SOCKET_CLOSE     = 0x43,
669   RSI_WLAN_RSP_SOCKET_READ_DATA = 0x6B,
670   RSI_WLAN_RSP_SOCKET_ACCEPT    = 0x6C,
671   RSI_WLAN_RSP_SOCKET_CONFIG    = 0xA7,
672   RSI_WLAN_RSP_SELECT_REQUEST   = 0x74,
673   RSI_WLAN_RSP_SET_SNI_EMBEDDED = 0x6E,
674 
675   //  Unimplemented command for 22q2
676   RSI_WLAN_RSP_CLEAR                  = 0x00,
677   RSI_WLAN_RSP_CFG_SAVE               = 0x20,
678   RSI_WLAN_RSP_AUTO_CONFIG_ENABLE     = 0x21,
679   RSI_WLAN_RSP_GET_CFG                = 0x22,
680   RSI_WLAN_RSP_USER_STORE_CONFIG      = 0x23,
681   RSI_WLAN_RSP_SET_WEP_KEYS           = 0x25,
682   RSI_WLAN_RSP_P2P_CONNECTION_REQUEST = 0x30,
683   RSI_WLAN_RSP_SET_PROFILE            = 0x31,
684   RSI_WLAN_RSP_GET_PROFILE            = 0x32,
685   RSI_WLAN_RSP_DELETE_PROFILE         = 0x33,
686   RSI_WLAN_RSP_CONN_ESTABLISH         = 0x61,
687   RSI_WLAN_RSP_REMOTE_TERMINATE       = 0x62,
688   RSI_WLAN_RSP_IPV4_CHANGE            = 0xAA,
689   RSI_WLAN_RSP_TCP_ACK_INDICATION     = 0xAB,
690   RSI_WLAN_RSP_UART_DATA_ACK          = 0xAC,
691   RSI_WLAN_RSP_SET_MULTICAST_FILTER   = 0x40,
692   RSI_WLAN_RSP_DNS_UPDATE             = 0xED,
693   RSI_WLAN_RSP_CONNECTION_STATUS      = 0x48,
694   RSI_WLAN_RSP_CONFIGURE_P2P          = 0x4B,
695   RSI_WLAN_RSP_WFD_DEVICE             = 0x54,
696   RSI_WLAN_RSP_DNS_SERVER_ADD         = 0x55,
697   RSI_WLAN_RSP_WIRELESS_FWUP_OK       = 0x59,
698   RSI_WLAN_RSP_WIRELESS_FWUP_DONE     = 0x5A,
699   RSI_WLAN_RSP_HT_CAPABILITIES        = 0x6D,
700   RSI_WLAN_RSP_REJOIN_PARAMS          = 0x6F,
701   RSI_WLAN_RSP_WPS_METHOD             = 0x72,
702   RSI_WLAN_RSP_WMM_PS                 = 0x97,
703   RSI_WLAN_RSP_FWUP                   = 0x99,
704 #ifdef RSI_WAC_MFI_ENABLE
705   RSI_WLAN_RSP_ADD_MFI_IE = 0xB5,
706 #endif
707 #ifndef SLI_SI91X_MCU_INTERFACE
708   RSI_WLAN_RSP_CERT_VALID = 0xBC,
709 #endif
710   RSI_WLAN_RSP_CLIENT_CONNECTED             = 0xC2,
711   RSI_WLAN_RSP_CLIENT_DISCONNECTED          = 0xC3,
712   RSI_WLAN_RSP_FREQ_OFFSET                  = 0xF3,
713   RSI_WLAN_RSP_CALIB_WRITE                  = 0xCA,
714   RSI_WLAN_RSP_DYNAMIC_POOL                 = 0xC7,
715   RSI_WLAN_RSP_EMB_MQTT_PUBLISH_PKT         = 0xCC,
716   RSI_WLAN_RSP_MQTT_REMOTE_TERMINATE        = 0xF0,
717   RSI_WLAN_RSP_MDNSD                        = 0xDB,
718   RSI_WLAN_RSP_GET_DPD_DATA                 = 0xDC,
719   RSI_WLAN_RSP_FTP                          = 0xE2,
720   RSI_WLAN_RSP_FTP_FILE_WRITE               = 0xE3,
721   RSI_WLAN_RSP_SNTP_SERVER                  = 0xE5,
722   RSI_WLAN_RSP_SMTP_CLIENT                  = 0xE6,
723   RSI_WLAN_RSP_OTA_FWUP                     = 0xEF,
724   RSI_WLAN_RSP_WEBPAGE_LOAD                 = 0x50,
725   RSI_WLAN_RSP_JSON_LOAD                    = 0x9c,
726   RSI_WLAN_RSP_WEBPAGE_ERASE                = 0x9A,
727   RSI_WLAN_RSP_JSON_OBJECT_ERASE            = 0x9B,
728   RSI_WLAN_RSP_WEBPAGE_CLEAR_ALL            = 0x7F,
729   RSI_WLAN_RSP_HOST_WEBPAGE_SEND            = 0x56,
730   RSI_WLAN_RSP_JSON_UPDATE                  = 0x9D,
731   RSI_WLAN_RSP_GET_RANDOM                   = 0xF8,
732   RSI_WLAN_RSP_ASYNCHRONOUS                 = 0xFF,
733   RSI_WLAN_RSP_JSON_EVENT                   = 0xEE,
734   RSI_WLAN_RSP_POP3_CLIENT                  = 0xE7,
735   RSI_WLAN_RSP_POP3_CLIENT_TERMINATE        = 0xE8,
736   RSI_WLAN_RSP_DHCP_USER_CLASS              = 0xEC,
737   RSI_WLAN_RSP_TIMEOUT                      = 0xEA,
738   RSI_WLAN_RSP_URL_REQUEST                  = 0x64,
739   RSI_WLAN_RSP_MODULE_STATE                 = 0x70,
740   RSI_WLAN_RSP_TWT_ASYNC                    = 0x71,
741   RSI_WLAN_RSP_UPDATE_TCP_WINDOW            = 0xF5,
742   RSI_WLAN_RSP_TSF                          = 0x65,
743   RSI_WLAN_RSP_TRANSCEIVER_SET_CHANNEL      = 0x7A,
744   RSI_WLAN_RSP_TRANSCEIVER_PEER_LIST_UPDATE = 0x8B,
745   RSI_WLAN_RSP_TRANSCEIVER_CONFIG_PARAMS    = 0x8C,
746   RSI_WLAN_RSP_TRANSCEIVER_SET_MCAST_FILTER = 0x8D,
747   RSI_WLAN_RSP_TRANSCEIVER_FLUSH_DATA_Q     = 0x8E,
748   RSI_WLAN_RSP_TRANSCEIVER_TX_DATA_STATUS   = 0x3D,
749   SL_SI91X_WIFI_RX_DOT11_DATA               = 0x03,
750   // Unimplemented commands after 22Q2
751   RSI_WLAN_RATE_RSP_STATS = 0x88
752 } rsi_wlan_cmd_response_t;
753 
754 typedef enum { SET_REGION_CODE_FROM_BEACONS, SET_REGION_CODE_FROM_USER } si91x_set_region_code_command_t;
755 
756 typedef enum { SL_SI91X_SOCKET_REMOTE_TERMINATED_EVENT, SL_SI91X_SOCKET_EVENT_COUNT } sl_si91x_socket_event_t;
757 
758 typedef enum { SL_SI91X_NO_ENCRYPTION, SL_SI91X_TKIP_ENCRYPTION, SL_SI91X_CCMP_ENCRYPTION } sl_si91x_encryption_t;
759 //! @endcond