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 #pragma once 31 32 #include "sl_status.h" 33 #include "sl_wifi_device.h" 34 #include "sl_wifi_host_interface.h" 35 #include "sl_si91x_host_interface.h" 36 #include "sl_rsi_utility.h" 37 #include "sl_si91x_constants.h" 38 #include "cmsis_os2.h" 39 40 //! @cond Doxygen_Suppress 41 #define VERIFY_STATUS(s) \ 42 do { \ 43 if (s != SL_STATUS_OK) \ 44 return s; \ 45 } while (0) 46 47 /** 48 * All flags used in si91x event mask 49 * There are three main groups of flags, each with SL_SI91X_COMMAND_TYPE_COUNT number of unique flags 50 */ 51 #define SL_SI91X_TX_PENDING_FLAG(x) (1 << (x)) 52 #define SL_SI91X_RESPONSE_FLAG(x) (1 << (SI91X_CMD_MAX + x)) 53 #define SL_SI91X_EXTRA_EVENT_FLAG(x) (1 << (SI91X_CMD_MAX + SI91X_CMD_MAX + x)) 54 55 //! TX Flags 56 #define SL_SI91X_COMMON_TX_PENDING_EVENT SL_SI91X_TX_PENDING_FLAG(SI91X_COMMON_CMD) 57 #define SL_SI91X_WLAN_TX_PENDING_EVENT SL_SI91X_TX_PENDING_FLAG(SI91X_WLAN_CMD) 58 #define SL_SI91X_NETWORK_TX_PENDING_EVENT SL_SI91X_TX_PENDING_FLAG(SI91X_NETWORK_CMD) 59 #define SL_SI91X_BT_TX_PENDING_EVENT SL_SI91X_TX_PENDING_FLAG(SI91X_BT_CMD) 60 #define SL_SI91X_GENERIC_SOCKET_TX_PENDING_EVENT SL_SI91X_TX_PENDING_FLAG(SI91X_SOCKET_CMD) 61 62 // Indicates RX response received for COMMON command type 63 #define NCP_HOST_COMMON_RESPONSE_EVENT SL_SI91X_RESPONSE_FLAG(SI91X_COMMON_CMD) 64 65 // Indicates synchronous RX response received for WLAN command type 66 #define NCP_HOST_WLAN_RESPONSE_EVENT SL_SI91X_RESPONSE_FLAG(SI91X_WLAN_CMD) 67 68 // Indicates synchronous RX response received for NETWORK command type 69 #define NCP_HOST_NETWORK_RESPONSE_EVENT SL_SI91X_RESPONSE_FLAG(SI91X_NETWORK_CMD) 70 71 // Indicates RX response received for SOCKET command type 72 #define NCP_HOST_SOCKET_RESPONSE_EVENT SL_SI91X_RESPONSE_FLAG(SI91X_SOCKET_CMD) 73 74 // Indicates RX response received for BLE command type 75 #define NCP_HOST_BT_RESPONSE_EVENT SL_SI91X_RESPONSE_FLAG(SI91X_BT_CMD) 76 77 // Triggered by IRQ to indicate something to read 78 #define SL_SI91X_NCP_HOST_BUS_RX_EVENT SL_SI91X_EXTRA_EVENT_FLAG(0) 79 #define SL_SI91X_SOCKET_DATA_TX_PENDING_EVENT SL_SI91X_EXTRA_EVENT_FLAG(1) 80 #define SL_SI91X_SOCKET_COMMAND_TX_PENDING_EVENT SL_SI91X_EXTRA_EVENT_FLAG(2) 81 #define SL_SI91X_GENERIC_DATA_TX_PENDING_EVENT SL_SI91X_EXTRA_EVENT_FLAG(3) 82 #define SL_SI91X_TA_BUFFER_FULL_CLEAR_EVENT SL_SI91X_EXTRA_EVENT_FLAG(4) 83 #define SL_SI91X_TERMINATE_BUS_THREAD_EVENT (1 << 21) 84 #define SL_SI91X_TERMINATE_BUS_THREAD_EVENT_ACK (1 << 22) 85 86 #define SL_SI91X_ALL_TX_PENDING_COMMAND_EVENTS \ 87 (SL_SI91X_COMMON_TX_PENDING_EVENT | SL_SI91X_WLAN_TX_PENDING_EVENT | SL_SI91X_NETWORK_TX_PENDING_EVENT \ 88 | SL_SI91X_BT_TX_PENDING_EVENT | SL_SI91X_GENERIC_SOCKET_TX_PENDING_EVENT) 89 90 typedef enum { SL_NCP_NORMAL_POWER_MODE, SL_NCP_LOW_POWER_MODE, SL_NCP_ULTRA_LOW_POWER_MODE } sl_si91x_power_mode_t; 91 92 typedef struct sl_si91x_power_configuration sl_si91x_power_configuration_t; 93 //! @endcond 94 95 /***************************************************************************/ /** 96 * @brief 97 * Initialize the driver. 98 * @param[in] config 99 * @ref sl_wifi_device_configuration_t Pointer to device configuration. 100 * @param[in] event_handler 101 * [sl_wifi_event_handler_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-types#sl-wifi-event-handler-t) Function pointer to receive asynchronous events. 102 * @return 103 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 104 ******************************************************************************/ 105 sl_status_t sl_si91x_driver_init(const sl_wifi_device_configuration_t *config, sl_wifi_event_handler_t event_handler); 106 107 /***************************************************************************/ /** 108 * @brief 109 * De-initialize the driver. 110 * @pre Pre-conditions: 111 * - 112 * @ref sl_si91x_driver_init should be called before this API. 113 * @return 114 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 115 ******************************************************************************/ 116 sl_status_t sl_si91x_driver_deinit(void); 117 118 //! @cond Doxygen_Suppress 119 /***************************************************************************/ /** 120 * @brief 121 * Register a function and optional argument for scan results callback. 122 * @param[in] command 123 * Command type to be sent to NWP firmware. 124 * @param[in] queue_type 125 * @ref sl_si91x_command_type_t Command type 126 * @param[in] data 127 * Command packet to be sent to the NWP firmware. 128 * @param[in] data_length 129 * Length of command packet. 130 * @param[in] wait_period 131 * @ref sl_si91x_wait_period_t Timeout for the command response. 132 * @param[in] sdk_context 133 * Pointer to the context. 134 * @param[in] data_buffer 135 * [sl_wifi_buffer_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-buffer-t) Pointer to a data buffer pointer for the response data to be returned in. 136 * @pre Pre-conditions: 137 * - 138 * @ref sl_si91x_driver_init should be called before this API. 139 * @return 140 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 141 ******************************************************************************/ 142 sl_status_t sl_si91x_driver_send_command(uint32_t command, 143 sl_si91x_command_type_t queue_type, 144 const void *data, 145 uint32_t data_length, 146 sl_si91x_wait_period_t wait_period, 147 void *sdk_context, 148 sl_wifi_buffer_t **data_buffer); 149 150 /***************************************************************************/ /** 151 * @brief 152 * Register a function and optional argument for scan results callback. 153 * @param[in] command 154 * Command type to be sent to NWP firmware. 155 * @param[in] data 156 * Command packet to be sent to the NWP firmware. 157 * @param[in] data_length 158 * Length of command packet. 159 * @param[in] wait_period 160 * @ref sl_si91x_wait_period_t Timeout for the command response. 161 * @pre 162 * @ref sl_si91x_driver_init should be called before this API. 163 * @return 164 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 165 ******************************************************************************/ 166 sl_status_t sl_si91x_driver_send_side_band_crypto(uint32_t command, 167 const void *data, 168 uint32_t data_length, 169 sl_si91x_wait_period_t wait_period); 170 171 /***************************************************************************/ /** 172 * @brief 173 * Send commands to the NWP; whose response needs to be handled asynchronously. 174 * Note: This function doesn't acquire "command_in_flight" boolean 175 * @param[in] command 176 * Command type to be sent to NWP firmware. 177 * @param[in] queue_type 178 * @ref sl_si91x_command_type_t Command type 179 * @param[in] data 180 * Command packet to be sent to the NWP firmware. 181 * @param[in] data_length 182 * Length of the command packet. 183 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 184 ******************************************************************************/ 185 sl_status_t sl_si91x_driver_send_async_command(uint32_t command, 186 sl_si91x_command_type_t queue_type, 187 void *data, 188 uint32_t data_length); 189 /***************************************************************************/ /** 190 * @brief 191 * Wait for a command response. 192 * @param[in] command 193 * @ref rsi_wlan_cmd_request_t Command type to wait . 194 * @param[in] wait_period 195 * @ref sl_si91x_wait_period_t Wait time in milliseconds to wait for command response. 196 * @pre Pre-conditions: 197 * - 198 * @ref sl_si91x_driver_init should be called before this API. 199 * @return 200 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 201 ******************************************************************************/ 202 sl_status_t sl_si91x_driver_wait_for_response(rsi_wlan_cmd_request_t command, sl_si91x_wait_period_t wait_period); 203 204 /***************************************************************************/ /** 205 * @brief 206 * Send a socket command. 207 * @param[in] request 208 * @ref sli_si91x_socket_send_request_t Pointer to socket command packet. 209 * @param[in] data 210 * Pointer to socket data. 211 * @param[in] wait_time 212 * Timeout for the command response. 213 * @pre Pre-conditions: 214 * - 215 * @ref sl_si91x_driver_init should be called before this API. 216 * @return 217 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 218 ******************************************************************************/ 219 sl_status_t sl_si91x_driver_send_socket_data(const sli_si91x_socket_send_request_t *request, 220 const void *data, 221 uint32_t wait_time); 222 223 /***************************************************************************/ /** 224 * @brief 225 * Send a Bluetooth command. 226 * @param[in] command 227 * @ref rsi_wlan_cmd_request_t Command type to be sent. 228 * @param[in] queue_type 229 * @ref sl_si91x_command_type_t Command type. 230 * @param[in] data 231 * [sl_wifi_buffer_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-buffer-t) Pointer to Bluetooth data. 232 * @param[in] sync_command 233 * Sync or Async command. 234 * @pre Pre-conditions: 235 * - 236 * @ref sl_si91x_driver_init should be called before this API. 237 * @return 238 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 239 ******************************************************************************/ 240 sl_status_t sl_si91x_driver_send_bt_command(rsi_wlan_cmd_request_t command, 241 sl_si91x_command_type_t command_type, 242 sl_wifi_buffer_t *data, 243 uint8_t sync_command); 244 //! @endcond 245 246 /***************************************************************************/ /** 247 * @brief 248 * Load a certificate into a specified index. 249 * @param[in] certificate_type 250 * Type of certificate being loaded 251 * @param[in] certificate_index 252 * Index where the certificate is to be loaded. 253 * @param[in] buffer 254 * Pointer to the buffer containing the certificate to be loaded. 255 * @param[in] certificate_length 256 * Length of the certificate buffer. 257 * @pre Pre-conditions: 258 * - 259 * @ref sl_si91x_driver_init should be called before this API. 260 * @return 261 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 262 ******************************************************************************/ 263 sl_status_t sl_si91x_wifi_set_certificate_index(uint8_t certificate_type, 264 uint8_t certificate_index, 265 const uint8_t *buffer, 266 uint32_t certificate_length); 267 268 /** \addtogroup SL_SI91X_TYPES 269 * @{ */ 270 /// Firmware version information 271 typedef struct { 272 uint8_t chip_id; ///< Chip ID 273 uint8_t rom_id; ///< ROM ID 274 uint8_t major; ///< Major version number 275 uint8_t minor; ///< Minor version number 276 uint8_t security_version; ///< Security enabled or disabled 277 uint8_t patch_num; ///< Patch number 278 uint8_t customer_id; ///< Customer ID 279 uint16_t build_num; ///< Build number 280 } sl_si91x_firmware_version_t; 281 282 /// Network wirless processor (NWP) configuration structure 283 typedef struct { 284 uint32_t code; ///< Configuration code. The possible values are: 285 ///< - SL_SI91X_XO_CTUNE_FROM_HOST 286 ///< - SL_SI91X_ENABLE_NWP_WDT_FROM_HOST 287 ///< - SL_SI91X_DISABLE_NWP_WDT_FROM_HOST 288 union { 289 uint8_t config_val; ///< Configuration value as per the code selected above. 290 // Below structure is used in case of SL_SI91X_ENABLE_NWP_WDT_FROM_HOST 291 struct { 292 uint8_t wdt_timer_val; ///< Timer value in seconds for the watchdog timer. 293 uint8_t wdt_enable_in_ps; ///< Enable watchdog timer in power save mode. 294 }; 295 } values; ///< Values 296 } sl_si91x_nwp_configuration_t; 297 298 /// NWP get configuration structure 299 typedef struct { 300 uint32_t sub_command_type; ///< Requested configuration. Currently, only `GET_OPN_BOARD_CONFIG` is supported. 301 } sl_si91x_nwp_get_configuration_t; 302 303 /// Assertion structure 304 typedef struct { 305 sl_si91x_assertion_type_t assert_type; ///< Assertion type. It must be in the range of 0 to 15 (both included). 306 sl_si91x_assertion_level_t assert_level; ///< Assertion level. It must be in the range of 0 to 15 (both included). 307 } sl_si91x_assertion_t; 308 /** @} */ 309 310 /** \addtogroup SI91X_DRIVER_FUNCTIONS 311 * \ingroup SL_SI91X_API 312 * @{ */ 313 /***************************************************************************/ /** 314 * @brief 315 * Sets the Real Time Clock (RTC) of the module. 316 * 317 * @details 318 * This function sets the RTC time of the module using the provided @ref sl_si91x_module_rtc_time_t structure. 319 * It is a blocking call, meaning it will wait until the operation is complete before returning. 320 * 321 * @param[in] timer 322 * Pointer to an @ref sl_si91x_module_rtc_time_t structure that contains the RTC time to be set. 323 * 324 * @pre 325 * Pre-conditions: 326 * - The [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) API must be called prior to this API. 327 * - The @ref SL_SI91X_CUSTOM_FEAT_RTC_FROM_HOST bit must be enabled in the @ref SI91X_CUSTOM_FEATURE_BITMAP during the [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) process. 328 * 329 * @return 330 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 331 * 332 * @note 333 * Ensure that the Real-Time Clock (RTC) timer is configured to enable SSL certificate validation. 334 ******************************************************************************/ 335 sl_status_t sl_si91x_set_rtc_timer(const sl_si91x_module_rtc_time_t *timer); 336 337 /***************************************************************************/ /** 338 * @brief 339 * Retrieves the current time from the module's Real Time Clock (RTC). 340 * 341 * @details 342 * This function fetches the current time from the module's RTC and stores it in the provided @ref sl_si91x_module_rtc_time_t structure. 343 * It is a blocking call, meaning it will wait until the operation is complete before returning. 344 * 345 * @param[out] response 346 * Pointer to an @ref sl_si91x_module_rtc_time_t structure where the RTC's current time will be stored. 347 * @pre 348 * Pre-conditions: 349 * - The @ref sl_si91x_set_rtc_timer() API must be called to set the RTC time before attempting to retrieve it. 350 * - The @ref SL_SI91X_CUSTOM_FEAT_RTC_FROM_HOST bit must be enabled in the @ref SI91X_CUSTOM_FEATURE_BITMAP during the [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) process to allow RTC time setting and retrieval from the host. 351 * 352 * @return 353 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 354 ******************************************************************************/ 355 sl_status_t sl_si91x_get_rtc_timer(sl_si91x_module_rtc_time_t *response); 356 357 #if defined(SLI_SI91X_MCU_INTERFACE) || defined(DOXYGEN) 358 /*==============================================*//** 359 * @brief 360 * Sends M4 specific commands to NWP to access shared resources such as flash, XTAL etc. 361 * 362 * @details 363 * This function sends M4 specific commands using the specified sub-command type and input data. 364 * 365 * This is a blocking API. 366 * 367 * In SoC mode, this API only sends commands from the M4 core to the TA core. 368 * 369 * @pre Pre-conditions: 370 * - 371 * [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 372 * 373 * @param[in] sub_cmd_type 374 * Specifies the sub-command type for the secure handshake. 375 * 376 * @param[in] input_data 377 * Pointer to the input data that contains the information used during the secure handshake. 378 * 379 * @param[in] input_len 380 * Specifies the length of the input data. 381 * 382 * @param[in] output_len 383 * Specifies the length of the output data. 384 * 385 * @param[out] output_data 386 * Pointer to a buffer where the response data will be stored after the secure handshake process. 387 * 388 * @return 389 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 390 * 391 * @note 392 * The `output_len` and `output_data` parameters are currently unused and reserved for future use. 393 * @note 394 * This API is only applicable in SoC mode. 395 * @note 396 * - Currently, only `SL_SI91X_ENABLE_XTAL` is supported for `sub_cmd_type`. 397 * - `SL_SI91X_ENABLE_XTAL` is of `uint8_t` datatype and user can pass 1 to enable and 0 to disable it. 398 * - For alarm based sleep wakeup applications, `SL_SI91X_ENABLE_XTAL` is used to enable/disable the XTAL. 399 ***************************************************/ 400 sl_status_t sl_si91x_m4_ta_secure_handshake(uint8_t sub_cmd_type, 401 uint8_t input_len, 402 const uint8_t *input_data, 403 uint8_t output_len, 404 const uint8_t *output_data); 405 #endif 406 407 /***************************************************************************/ /** 408 * @brief 409 * Sets different timeouts given by sl_si91x_timeout_type_t for the Si91x device. 410 * 411 * @details 412 * This API configures various timeout settings such as authentication, association, channel active scan, 413 * channel passive scan timeout, and keep-alive timeout for the module. 414 * The timeout type determines the specific timeout being set, and the timeout value specifies the duration. 415 * 416 * @pre 417 * This API should be called after [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init). 418 * 419 * @param[in] timeout_type 420 * Identifies which timeout type to set. Possible values are defined in @ref sl_si91x_timeout_type_t. 421 * 422 * @param[in] timeout_value 423 * The timeout value to set. The time resolution depends on the timeout_type. 424 * 425 * @return 426 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 427 * 428 * @note 429 * - After a successful IP configuration, Gratuitous ARP is used as the periodic WLAN Keep-Alive packet with the configured keep_alive_timeout interval. 430 * - If there is no IP configuration, NULL Data Packets are used as the WLAN Keep-Alive packet. 431 * - As an alternative, users can use @ref sl_si91x_set_timeout to set all timeouts before calling `sl_wifi_init()`. 432 *******************************************************************************/ 433 sl_status_t sl_si91x_configure_timeout(sl_si91x_timeout_type_t timeout_type, uint16_t timeout_value); 434 435 /***************************************************************************/ /** 436 * @brief 437 * Sets different module timeouts in a single call for the Si91X device. 438 * 439 * @details 440 * This API sets all the timeout configurations in a single call. 441 * It includes settings for the active channel scan timeout, authentication association timeout, and keep-alive timeout for the module. 442 * 443 * @param[in] timeout_config 444 * Timeout configuration of type @ref sl_si91x_timeout_t. 445 * 446 * @note 447 * - This API should ONLY be called before [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init). 448 * - Repeated calls to this API will overwrite the timeout values stored in the SDK and will be applied on the next call to [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init). 449 * - As an alternative, users can set individual timeouts using @ref sl_si91x_configure_timeout() after calling `sl_wifi_init()`. 450 *******************************************************************************/ 451 void sl_si91x_set_timeout(const sl_si91x_timeout_t *timeout_config); 452 453 /***************************************************************************/ /** 454 * @brief 455 * Retrieves TA RAM log/dump via Si91x UART/UART2. 456 * 457 * @details 458 * This function reads a chunk of data from the specified address in the Si91x module's RAM via UART or UART2. 459 * It is useful for debugging purposes by allowing access to the RAM log or dump. 460 * 461 * Selection of debug UART can be done by using @ref SL_SI91X_EXT_FEAT_UART_SEL_FOR_DEBUG_PRINTS 462 * 463 * @param[in] address 464 * Address in Si91x module from which to start reading. 465 * 466 * @param[in] length 467 * Length of the chunk to read from the Si91x module. 468 * 469 * @return 470 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 471 ******************************************************************************/ 472 sl_status_t sl_si91x_get_ram_log(uint32_t address, uint32_t length); 473 474 /***************************************************************************/ 475 /** 476 * @brief 477 * Allows the Network Processor (NWP) to write content to the common flash from M4. 478 * 479 * @details 480 * This function enables the NWP to write data to the common flash memory from the M4 core. It is a blocking API. 481 * 482 * @param[in] write_address 483 * The address in the common flash memory where the write operation should begin. 484 * - For the M4 region, the write address should start from 0x8000000. Possible values range from the M4 image end address to the M4 region end address. 485 * - For the NWP region, the write address should range from 0 to (20K-1). 486 * - For sector erase, it should be multiples of 4K. 487 * 488 * @param[in] write_data 489 * Pointer to the data to be written. 490 * 491 * @param[in] write_data_length 492 * The total length of the data, which should be multiples of 4K for sector erase. 493 * 494 * @param[in] flash_sector_erase_enable 495 * Enable or disable sector erase. 496 * - 1: Erases multiples of 4 KB of data. 497 * - 0: Disable, allows writing data onto flash. 498 * 499 * @return 500 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 501 ******************************************************************************/ 502 sl_status_t sl_si91x_command_to_write_common_flash(uint32_t write_address, 503 const uint8_t *write_data, 504 uint16_t write_data_length, 505 uint8_t flash_sector_erase_enable); 506 507 /***************************************************************************/ /** 508 * @brief 509 * Sends a command to read data from the NWP flash memory of the SI91x wireless device. 510 * 511 * @details 512 * This function sends a command to the SI91x wireless device to read data from the NWP flash memory at the specified address. The read data is stored in the provided output buffer. 513 * 514 * This is a blocking API. 515 * 516 * @param[in] read_address 517 * The address in the NWP flash memory to read from. The address should range from 0 to (20K-1). 518 * 519 * @param[in] length 520 * The number of bytes to read from the NWP flash memory. 521 * 522 * @param[out] output_buffer 523 * Pointer to the buffer where the read data will be stored. 524 * 525 * @return 526 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 527 ******************************************************************************/ 528 sl_status_t sl_si91x_command_to_read_common_flash(uint32_t read_address, size_t length, uint8_t *output_buffer); 529 530 /***************************************************************************/ /** 531 * @brief 532 * Retrieve the firmware version currently installed on the SiWx91x device. 533 * 534 * @details 535 * This function retrieves the firmware version currently installed on the SiWx91x device. The version information is stored in the provided `sl_si91x_firmware_version_t` object. 536 * 537 * This is a blocking API. 538 * 539 * @pre Pre-conditions: 540 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 541 * 542 * @param[out] version 543 * Pointer to an `sl_si91x_firmware_version_t` object that will be populated with the firmware version information. 544 * 545 * @return 546 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 547 ******************************************************************************/ 548 sl_status_t sl_si91x_get_firmware_version(sl_si91x_firmware_version_t *version); 549 550 /***************************************************************************/ /** 551 * @brief 552 * Retrieve the firmware image size from the firmware image file. 553 * 554 * @details 555 * This function reads the firmware image file from the provided buffer and returns the size of the firmware image. 556 * 557 * This is a non-blocking API. 558 * 559 * @param[in] buffer 560 * Pointer to the buffer containing the firmware image file. 561 * 562 * @param[out] fw_image_size 563 * Pointer to a variable where the size of the firmware image will be stored. The value returned in this parameter is valid only if this API returns SL_STATUS_OK (0). 564 * 565 * @return 566 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 567 ******************************************************************************/ 568 sl_status_t sl_si91x_get_firmware_size(void *buffer, uint32_t *fw_image_size); 569 570 /***************************************************************************/ 571 /** 572 * @brief 573 * Set configuration to NWP. 574 * 575 * @details 576 * This function sets the configuration for the Network Processor (NWP) based on the provided `sl_si91x_nwp_configuration_t` structure. 577 * 578 * The configuration values are determined by the `code` element of the structure. 579 * 580 * @pre Pre-conditions: 581 * - [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 582 * 583 * @param[in] nwp_config 584 * Configuration as identified by @ref sl_si91x_nwp_configuration_t. 585 * Possible values for `config.code` are defined below: 586 * - For `SL_SI91X_XO_CTUNE_FROM_HOST`: 587 * - `nwp_config.values.config_val` is used to configure NWP's XO Ctune value. 588 * - For `SL_SI91X_ENABLE_NWP_WDT_FROM_HOST`: 589 * - `nwp_config.values.wdt_timer_val` is used to configure the NWP WDT ISR timer, currently set to 32 seconds. 590 * - `nwp_config.values.wdt_enable_in_ps` is used to enable WDT in powersave mode. 591 * - For `SL_SI91X_DISABLE_NWP_WDT_FROM_HOST`: 592 * - Disables NWP WDT ISR timer. `nwp_config.values.config_val` is not utilized by the NWP. 593 * 594 * @return 595 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 596 ******************************************************************************/ 597 sl_status_t sl_si91x_set_nwp_config_request(sl_si91x_nwp_configuration_t nwp_config); 598 599 /***************************************************************************/ /** 600 * @brief 601 * Retrieve the configuration value from the firmware based on the requested sub_command_type element of `sl_si91x_nwp_get_configuration_t` structure. 602 * @pre Pre-conditions: 603 * - 604 * [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 605 * @param[in] nwp_config 606 * Configuration as identified by @ref sl_si91x_nwp_get_configuration_t. 607 * Possible values for nwp_config.sub_command_type are defined below: 608 * - For GET_OPN_BOARD_CONFIG: 609 * - nwp_config.sub_command_type is used to get board OPN part number. 610 * - OTP bits should be programmed with the board OPN part number otherwise the API will return NULL characters for OTP bits. 611 * - Currently, all other values are NOT SUPPORTED. 612 * @param[out] response 613 * Buffer to hold board OPN part number. The value returned in this param is valid only if this API returns SL_STATUS_OK(0). 614 * @return 615 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 616 ******************************************************************************/ 617 sl_status_t sl_si91x_get_nwp_config(const sl_si91x_nwp_get_configuration_t *nwp_config, uint8_t *response); 618 619 /***************************************************************************/ /** 620 * @brief 621 * Debug prints on UART interfaces 1 and 2. Host can get 5 types of debug prints based on the assertion level and assertion type. This is a blocking API. 622 * @pre Pre-conditions: 623 * - 624 * [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 625 * @param[in] assertion 626 * Configuration as identified by @ref sl_si91x_assertion_t. 627 * - Assertion type (Possible values are 0 - 15): 628 * - 0000 (LMAC core) 629 * - 0001 (SME) 630 * - 0010 (UMAC) 631 * - 0100 (NETX) 632 * - 1000 (Enables assertion indication and provides ram dump in critical assertion) 633 * - Assertion level (Possible values are 0 - 15): 634 * - 0 is only for specific prints & 15 is to enable all prints. 635 * - 0000 (Assertion required) 636 * - 0010 (Recoverable) 637 * - 0100 (Information) 638 * @return 639 * sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details. 640 ******************************************************************************/ 641 sl_status_t sl_si91x_debug_log(sl_si91x_assertion_t *assertion); 642 /** @} */ 643 644 /***************************************************************************/ /** 645 * @brief 646 * Configures the join feature bitmap for the Si91X device. 647 * 648 * @details 649 * This function sets the join feature bitmap configuration for the specified Wi-Fi interface. 650 * 651 * The join feature bitmap determines various connection parameters and behaviors. 652 * 653 * By default, the `SL_SI91X_JOIN_FEAT_LISTEN_INTERVAL_VALID` bitmap is enabled. 654 * 655 * Users can call this API before calling [sl_wifi_connect](../wiseconnect-api-reference-guide-wi-fi/wifi-client-api#sl-wifi-connect), [sl_wifi_start_ap](../wiseconnect-api-reference-guide-wi-fi/wifi-ap-api#sl-wifi-start-ap), [sl_wifi_start_wps](../wiseconnect-api-reference-guide-wi-fi/wifi-wps-api#sl-wifi-start-wps) to overwrite the join feature bitmap. 656 * 657 * @param[in] interface 658 * The selected Wi-Fi interface. Refer to [sl_wifi_interface_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-constants#sl-wifi-interface-t) for possible values. 659 * 660 * @param[in] join_feature_bitmap 661 * The join feature bitmap configuration. One of the values from @ref SI91X_JOIN_FEATURE_BIT_MAP. 662 * 663 * @return 664 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 665 *******************************************************************************/ 666 sl_status_t sl_si91x_set_join_configuration(sl_wifi_interface_t interface, uint8_t join_feature_bitmap); 667 668 /***************************************************************************/ /** 669 * @brief 670 * Retrieves the join feature bitmap configuration for the Si91X device. 671 * 672 * @details 673 * This function gets the current join feature bitmap configuration for the specified Wi-Fi interface. 674 * The join feature bitmap determines various connection parameters and behaviors. 675 * 676 * By default, the `SL_SI91X_JOIN_FEAT_LISTEN_INTERVAL_VALID` bitmap is enabled. 677 * 678 * @param[in] interface 679 * The selected Wi-Fi interface. Refer to [sl_wifi_interface_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-constants#sl-wifi-interface-t) for possible values. 680 * 681 * @param[out] join_feature_bitmap 682 * Pointer to a variable where the current join feature bitmap configuration will be stored. One or more values from @ref SI91X_JOIN_FEATURE_BIT_MAP. 683 * 684 * @return 685 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 686 *******************************************************************************/ 687 sl_status_t sl_si91x_get_join_configuration(sl_wifi_interface_t interface, uint8_t *join_feature_bitmap); 688 689 /***************************************************************************/ /** 690 * @brief 691 * Trigger an assert in firmware. 692 * 693 * @details 694 * This function is used to signal that an assertion has occurred in the firmware. It helps in debugging by indicating that a specific condition has failed. 695 * 696 * This is blocking API. 697 * 698 * @return 699 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 700 *******************************************************************************/ 701 sl_status_t sl_si91x_assert(void); 702 703 /***************************************************************************/ /** 704 * @brief 705 * Writes calibration data to non-volatile device memory. 706 * @param[in] data 707 * @ref si91x_calibration_data_t Pointer to buffer containing calibration data. 708 * @pre Pre-conditions: 709 * - 710 * @ref sl_si91x_driver_init should be called before this API. 711 * @return 712 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 713 ******************************************************************************/ 714 sl_status_t sl_si91x_write_calibration_data(const si91x_calibration_data_t *data); 715 716 /** \addtogroup SI91X_RADIO_FUNCTIONS 717 * \ingroup SL_SI91X_API 718 * @{ */ 719 720 /***************************************************************************/ /** 721 * @brief 722 * Start the transmit test. 723 * 724 * @details 725 * This function starts the transmit test using the provided configuration. 726 * 727 * This is a blocking API. 728 * 729 * This API is relevant in PER mode 730 * 731 * @pre Pre-conditions: 732 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 733 * 734 * @param[in] tx_test_info 735 * Pointer to an @ref sl_si91x_request_tx_test_info_t structure containing the configuration for the transmit test. 736 * 737 * @return 738 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 739 * 740 * @note Before starting Continuous Wave mode, user must start Continuous mode with power and channel values that are intended to be used in Continuous Wave mode i.e. \n 741 * - Start Continuous mode with intended power value and channel values - Pass any valid values for rate and length. 742 * - Stop Continuous mode 743 * - Start Continuous Wave mode 744 * @note If user wants to switch continuous wave mode, first need to stop the per mode and again need to give continous wave mode which user wants to switch. 745 ******************************************************************************/ 746 sl_status_t sl_si91x_transmit_test_start(const sl_si91x_request_tx_test_info_t *tx_test_info); 747 748 /***************************************************************************/ 749 /** 750 * @brief 751 * Stop the transmit test. 752 * 753 * @details 754 * This function stops the ongoing transmit test on the Si91x device. 755 * 756 * This is a blocking API. 757 * 758 * This API is relevant in PER mode. 759 * 760 * @pre Pre-conditions: 761 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 762 * 763 * @return 764 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 765 * 766 * @note 767 * User should configure a minimum delay (approx. 10 milliseconds) before and after @ref sl_si91x_transmit_test_start API to observe a stable output at requested dBm level. 768 ******************************************************************************/ 769 sl_status_t sl_si91x_transmit_test_stop(void); 770 771 /***************************************************************************/ /** 772 * @brief 773 * Provide feedback of frequency error in KHz. 774 * 775 * @details 776 * This function provides feedback of the frequency error in KHz. The frequency error is specified using the `sl_si91x_freq_offset_t` structure. 777 * 778 * This is a blocking API. 779 * 780 * @pre Pre-conditions: 781 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 782 * 783 * @param[in] frequency_calibration 784 * Pointer to an @ref sl_si91x_freq_offset_t structure containing the frequency error in KHz. 785 * 786 * @return 787 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 788 *******************************************************************************/ 789 sl_status_t sl_si91x_frequency_offset(const sl_si91x_freq_offset_t *frequency_calibration); 790 791 /***************************************************************************/ /** 792 * @brief 793 * Set the device region. 794 * 795 * @details 796 * This function sets the operational region of the Si91x device. The region is specified using the `sl_si91x_region_code_t` enumeration. 797 * 798 * @param[in] operation_mode 799 * Operation mode of the device, specified by @ref sl_si91x_operation_mode_t. 800 * 801 * @param[in] band 802 * Operational band of the device, specified by @ref sl_si91x_band_mode_t. 803 * 804 * @param[in] region_code 805 * Region code to be set in the device, specified by @ref sl_si91x_region_code_t. 806 * 807 * @pre Pre-conditions: 808 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 809 * 810 * @return 811 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 812 * @note 813 * In FCC-certified SiWx91x ACx modules the behavior is as follows 814 * 1. For FCC-certified modules, using this API will result in an SL_STATUS_SI91X_FEATURE_NOT_AVAILABLE error unless the module is in SL_SI91X_TRANSMIT_TEST_MODE. 815 * 2. STA mode channels 1 to 11 are actively scanned and 12,13,14 are passively scanned. 816 * 3. AP mode and Concurrent mode supports only 1 to 11 channels. 817 * 4. The AP will not broadcast the Country Information Element (IE). 818 ******************************************************************************/ 819 sl_status_t sl_si91x_set_device_region(sl_si91x_operation_mode_t operation_mode, 820 sl_si91x_band_mode_t band, 821 sl_si91x_region_code_t region_code); 822 823 /***************************************************************************/ /** 824 * @brief 825 * Command the firmware to update the existing Flash/EFuse calibration data. 826 * 827 * @details 828 * This function commands the firmware to update the existing Flash/EFuse calibration data using the provided calibration configuration. 829 * 830 * This is a blocking API. 831 * 832 * @pre Pre-conditions: 833 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init), `sl_si91x_transmit_test_start`, and `sl_si91x_frequency_offset` should be called before this API. 834 * 835 * @param[in] calib_write 836 * Write calibration configuration of type @ref sl_si91x_calibration_write_t. 837 * 838 * @return 839 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 840 * 841 * @note 842 * Executing this API will overwrite calibration values in certified modules. 843 * In FCC-certified modules, this API will trigger an error SL_STATUS_SI91X_FEATURE_NOT_AVAILABLE if used, except when in SL_SI91X_TRANSMIT_TEST_MODE mode. 844 ******************************************************************************/ 845 sl_status_t sl_si91x_calibration_write(sl_si91x_calibration_write_t calib_write); 846 847 /***************************************************************************/ 848 /** 849 * @brief 850 * Read the calibration data from the Flash/EFuse storage. 851 * 852 * @details 853 * This function reads the calibration data from the specified storage (Flash or EFuse) and provides it in the `calibration_read` parameter. 854 * 855 * This is a blocking API. 856 * 857 * @pre Pre-conditions: 858 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 859 * 860 * @param[in] target 861 * Specifies the storage to read the calibration data from. 862 * - 0: READ_FROM_EFUSE (read calibration data from the EFuse) 863 * - 1: READ_FROM_FLASH (read calibration data from the Flash) 864 * 865 * @param[out] calibration_read 866 * Pointer to an @ref sl_si91x_calibration_read_t structure where the read calibration data will be stored. 867 * 868 * @return 869 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 870 ******************************************************************************/ 871 sl_status_t sl_si91x_calibration_read(sl_si91x_calibration_read_t target, 872 sl_si91x_calibration_read_t *calibration_read); 873 874 /***************************************************************************/ 875 /** 876 * @brief 877 * Provide feedback on the error caused by the EVM offset. 878 * 879 * @details 880 * This function provides feedback on the error caused by the Error Vector Magnitude (EVM) offset. The EVM offset is specified using the `sl_si91x_evm_offset_t` structure. 881 * 882 * This is a blocking API. 883 * 884 * @pre Pre-conditions: 885 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 886 * 887 * @param[in] evm_offset 888 * Pointer to an `sl_si91x_evm_offset_t` structure containing the EVM offset. 889 * 890 * @return 891 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 892 * @note 893 * In FCC-certified modules, this API will trigger an error SL_STATUS_SI91X_FEATURE_NOT_AVAILABLE if used, except when in SL_SI91X_TRANSMIT_TEST_MODE mode. 894 ******************************************************************************/ 895 sl_status_t sl_si91x_evm_offset(const sl_si91x_evm_offset_t *evm_offset); 896 897 /***************************************************************************/ 898 /** 899 * @brief 900 * Command the firmware to update the existing Flash/EFuse calibration data. 901 * 902 * @details 903 * This function commands the firmware to update the existing Flash/EFuse calibration data using the provided EVM calibration configuration. 904 * 905 * This is a blocking API. 906 * 907 * @pre Pre-conditions: 908 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init), @ref sl_si91x_evm_offset, and @ref sl_si91x_transmit_test_start should be called before this API. 909 * 910 * @param[in] evm_write 911 * Pointer to an @ref sl_si91x_evm_write_t structure containing the EVM calibration configuration. 912 * 913 * @return 914 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 915 * @note 916 * In FCC-certified modules, this API will trigger an error SL_STATUS_SI91X_FEATURE_NOT_AVAILABLE if used, except when in SL_SI91X_TRANSMIT_TEST_MODE mode. 917 ******************************************************************************/ 918 sl_status_t sl_si91x_evm_write(const sl_si91x_evm_write_t *evm_write); 919 920 /***************************************************************************/ /** 921 * @brief 922 * Command the firmware to read data from the Efuse memory location. 923 * 924 * @details 925 * This function commands the firmware to read data from the specified Efuse memory location. The data is read into the provided buffer. 926 * 927 * This is a blocking API. 928 * 929 * @pre Pre-conditions: 930 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 931 * 932 * @param[in] efuse_read 933 * Pointer to an `sl_si91x_efuse_read_t` structure, which contains the Efuse read address offset and read data length. 934 * 935 * @param[out] efuse_read_buf 936 * Pointer to a buffer where the read Efuse data will be stored. 937 * 938 * @return 939 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 940 *******************************************************************************/ 941 sl_status_t sl_si91x_efuse_read(const sl_si91x_efuse_read_t *efuse_read, uint8_t *efuse_read_buf); 942 943 /***************************************************************************/ /** 944 * @brief 945 * Update Flash/EFuse DPD data. 946 * 947 * @details 948 * This function updates the Flash/EFuse DPD (Digital Pre-Distortion) data using the provided DPD calibration data. 949 * 950 * This is a blocking API. 951 * 952 * @pre Pre-conditions: 953 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) and @ref sl_si91x_transmit_test_start should be called before this API. 954 * 955 * @param[in] dpd_calib_data 956 * Pointer to an @ref sl_si91x_get_dpd_calib_data_t structure containing the DPD calibration data. 957 * 958 * @return 959 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 960 * @note 961 * In FCC-certified modules, this API will trigger an errorSL_STATUS_SI91X_FEATURE_NOT_AVAILABLE if used, except when in SL_SI91X_TRANSMIT_TEST_MODE mode. 962 ******************************************************************************/ 963 sl_status_t sl_si91x_dpd_calibration(const sl_si91x_get_dpd_calib_data_t *dpd_calib_data); 964 965 /***************************************************************************/ /** 966 * @brief 967 * Enable wireless radio. 968 * 969 * @details 970 * This function enables the wireless radio on the Si91x device. 971 * @pre Pre-conditions: 972 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 973 * 974 * @return 975 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 976 ******************************************************************************/ 977 sl_status_t sl_si91x_enable_radio(void); 978 979 /***************************************************************************/ 980 /** 981 * @brief 982 * Disable wireless radio. 983 * 984 * @details 985 * This function disables the wireless radio on the Si91x device. 986 * 987 * @pre Pre-conditions: 988 * - [sl_wifi_init](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 989 * 990 * @return 991 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 992 ******************************************************************************/ 993 sl_status_t sl_si91x_disable_radio(void); 994 995 /***************************************************************************/ /** 996 * @brief 997 * Set the Wi-Fi listen interval for the Si91x device. 998 * 999 * @details 1000 * This function sets the Wi-Fi listen interval for the Si91x device. The listen interval determines how often the device wakes up to listen for beacon frames from the access point. 1001 * 1002 * @param[in] listen_interval 1003 * Wi-Fi listen interval in milli seconds. 1004 ******************************************************************************/ 1005 void sl_si91x_set_listen_interval(uint32_t listen_interval); 1006 1007 /** @} */ 1008 1009 /***************************************************************************/ /** 1010 * @brief 1011 * Send a raw command frame. 1012 * @param[in] command 1013 * Command type to be sent. 1014 * @param[in] data 1015 * Pointer to the command data to be sent. 1016 * @param[in] data_length 1017 * Length of the data length 1018 * @param[in] wait_time 1019 * Wait time for the command response. 1020 * @pre Pre-conditions: 1021 * - 1022 * @ref sl_si91x_driver_init should be called before this API. 1023 * @return 1024 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 1025 ******************************************************************************/ 1026 sl_status_t sl_si91x_driver_raw_send_command(uint8_t command, 1027 const void *data, 1028 uint32_t data_length, 1029 uint32_t wait_time); 1030 1031 //! @cond Doxygen_Suppress 1032 /***************************************************************************/ /** 1033 * @brief 1034 * Set device power configuration. 1035 * @param[in] mode 1036 * @ref sl_si91x_power_mode_t Power mode to be set to the device. 1037 * @param[in] config 1038 * @ref sl_si91x_power_configuration_t Pointer to structure containing power configuration. 1039 * @pre Pre-conditions: 1040 * - 1041 * @ref sl_si91x_driver_init should be called before this API. 1042 * @return 1043 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 1044 ******************************************************************************/ 1045 sl_status_t sl_si91x_set_power_mode(sl_si91x_power_mode_t mode, const sl_si91x_power_configuration_t *config); 1046 //! @endcond 1047 1048 /** \addtogroup SI91X_FIRMWARE_UPDATE_FROM_HOST_FUNCTIONS 1049 * \ingroup SI91X_FIRMWARE_UPDATE_FUNCTIONS 1050 * @{ */ 1051 1052 /***************************************************************************/ /** 1053 * @brief 1054 * Send the RPS header content of the firmware file. 1055 * 1056 * @details 1057 * This function sends the RPS (Remote Programming Service) header content of the firmware file to the Si91x device. 1058 * 1059 * This is a blocking API. 1060 * 1061 * @param[in] rps_header 1062 * Pointer to the RPS header content. 1063 * 1064 * @return 1065 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 1066 ******************************************************************************/ 1067 sl_status_t sl_si91x_fwup_start(const uint8_t *rps_header); 1068 1069 /***************************************************************************/ /** 1070 * @brief 1071 * Send the firmware file content. 1072 * 1073 * @details 1074 * This function sends the content of the firmware file to the Si91x device. 1075 * 1076 * This is a blocking API. 1077 * 1078 * @param[in] content 1079 * Pointer to the firmware file content. 1080 * 1081 * @param[in] length 1082 * Length of the content in bytes. 1083 * 1084 * @return 1085 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 1086 ******************************************************************************/ 1087 sl_status_t sl_si91x_fwup_load(const uint8_t *content, uint16_t length); 1088 1089 /***************************************************************************/ /** 1090 * @brief 1091 * Abort the firmware update process on the SiWx91x device and reset all firmware upgrade helper variables in the NWP. This is a blocking API. 1092 * 1093 * @details 1094 * This function aborts the ongoing firmware update process on the SiWx91x device. It is a blocking API and will not return until the process is aborted. 1095 * 1096 * This is a blocking API. 1097 * 1098 * @pre Pre-conditions: 1099 * - @ref sl_si91x_fwup_load should be called before this API. 1100 * 1101 * @return 1102 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 1103 * 1104 * @note 1105 * After successful completion of firmware loading using the @ref sl_si91x_fwup_load API, the user can call this abort API. 1106 * @note 1107 * Ensure to call this abort API before performing a soft or hard reset of the SiWx91x device. 1108 ******************************************************************************/ 1109 sl_status_t sl_si91x_fwup_abort(void); 1110 1111 /***************************************************************************/ /** 1112 * @brief 1113 * Flash firmware to the Wi-Fi module via the bootloader. 1114 * 1115 * @details 1116 * This function flashes the firmware to the Wi-Fi module using the bootloader. The firmware image, its size, and the position flags are provided as parameters. 1117 * 1118 * This is a blocking API. 1119 * 1120 * @param[in] firmware_image 1121 * Pointer to the firmware image. 1122 * 1123 * @param[in] fw_image_size 1124 * Size of the firmware image in bytes. 1125 * 1126 * @param[in] flags 1127 * Flags indicating the chunk position in the file: 1128 * - 0: Middle of the file 1129 * - 1: Start of the file 1130 * - 2: End of the file 1131 * 1132 * @return 1133 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 1134 ******************************************************************************/ 1135 sl_status_t sl_si91x_bl_upgrade_firmware(uint8_t *firmware_image, uint32_t fw_image_size, uint8_t flags); 1136 1137 /***************************************************************************/ /** 1138 * @brief 1139 * Enable fast firmware upgrade mode. 1140 * 1141 * @details 1142 * This function enables the fast firmware upgrade mode on the Si91x device. It optimizes the firmware upgrade process for speed. 1143 * 1144 * @return 1145 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 1146 ******************************************************************************/ 1147 sl_status_t sl_si91x_set_fast_fw_up(void); 1148 1149 /** @} */ 1150 1151 /** \addtogroup SI91X_FIRMWARE_UPDATE_FROM_MODULE_FUNCTIONS 1152 * \ingroup SI91X_FIRMWARE_UPDATE_FUNCTIONS 1153 * @{ */ 1154 /***************************************************************************/ /** 1155 * @brief 1156 * Create an OTAF client and initialize it with a given configuration. 1157 * 1158 * @details 1159 * This function creates an OTAF (Over-The-Air Firmware) client and initializes it with the provided configuration parameters. 1160 * 1161 * It supports both synchronous and asynchronous firmware upgrades. 1162 * 1163 * In synchronous mode, the response is received via [sl_net_event_handler_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-net-types#sl-net-event-handler-t) with [SL_NET_OTA_FW_UPDATE_EVENT](../wiseconnect-api-reference-guide-nwk-mgmt/sl-net-constants#sl-net-event-t) as the event. 1164 * 1165 * @pre Pre-conditions: 1166 * - [sl_net_up](../wiseconnect-api-reference-guide-nwk-mgmt/net-interface-functions#sl-net-up) API needs to be called before this API. 1167 * 1168 * @param[in] server_ip 1169 * OTAF server IP address of type [sl_ip_address_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-ip-address-t). 1170 * 1171 * @param[in] server_port 1172 * OTAF server port number. 1173 * 1174 * @param[in] chunk_number 1175 * Firmware content request chunk number. 1176 * 1177 * @param[in] timeout 1178 * TCP receive packet timeout. 1179 * 1180 * @param[in] tcp_retry_count 1181 * TCP retransmissions count. 1182 * 1183 * @param[in] asynchronous 1184 * OTAF upgrade done asynchronously when this is set to true, else synchronous upgrade. 1185 * 1186 * @return 1187 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 1188 * 1189 * @note 1190 * For a safe firmware upgrade via TCP server, it will take approximately 65 seconds to upgrade the firmware of a 1.5 MB file. 1191 ******************************************************************************/ 1192 sl_status_t sl_si91x_ota_firmware_upgradation(sl_ip_address_t server_ip, 1193 uint16_t server_port, 1194 uint16_t chunk_number, 1195 uint16_t timeout, 1196 uint16_t tcp_retry_count, 1197 bool asynchronous); 1198 1199 /** @} */ 1200 1201 /***************************************************************************/ /** 1202 * @brief 1203 * Get the current Opermode of the module. 1204 * @return 1205 * sl_si91x_operation_mode_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 1206 ******************************************************************************/ 1207 sl_si91x_operation_mode_t get_opermode(void); 1208 1209 /***************************************************************************/ /** 1210 * @brief 1211 * Si91X specific get listen interval 1212 * @return uint32_t 1213 * Wi-Fi Listen interval 1214 *******************************************************************************/ 1215 uint32_t sl_si91x_get_listen_interval(void); 1216 1217 /***************************************************************************/ /** 1218 * @brief Si91X specific Wi-Fi transceiver mode driver function to send Tx data 1219 * @param[in] control - Meta data for the payload. 1220 * @param[in] payload - Pointer to payload to be sent to LMAC. 1221 * @param[in] payload_len - Length of the payload. 1222 * @param[in] wait_time - Wait time for the command response. 1223 * @return sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 1224 *******************************************************************************/ 1225 sl_status_t sl_si91x_driver_send_transceiver_data(sl_wifi_transceiver_tx_data_control_t *control, 1226 const uint8_t *payload, 1227 uint16_t payload_len, 1228 uint32_t wait_time); 1229 1230 //! @cond Doxygen_Suppress 1231 /***************************************************************************/ /** 1232 * @brief 1233 * Register a function and optional argument for scan results callback. 1234 * @param[in] command 1235 * Command type to be sent to NWP firmware. 1236 * @param[in] queue_type 1237 * @ref sl_si91x_command_type_t Command type 1238 * @param[in] data 1239 * Command packet to be sent to the NWP firmware. 1240 * @param[in] data_length 1241 * Length of command packet. 1242 * @param[in] wait_period 1243 * @ref sl_si91x_wait_period_t Timeout for the command response. 1244 * @param[in] sdk_context 1245 * Pointer to the context. 1246 * @param[in] data_buffer 1247 * [sl_wifi_buffer_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-buffer-t) Pointer to a data buffer pointer for the response data to be returned in. 1248 * @param[in] custom_host_desc 1249 * Custom Variable to send additional data to the firmware through the host descriptor. 1250 * @pre Pre-conditions: 1251 * - 1252 * @ref sl_si91x_driver_init should be called before this API. 1253 * @return 1254 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 1255 ******************************************************************************/ 1256 sl_status_t sl_si91x_custom_driver_send_command(uint32_t command, 1257 sl_si91x_command_type_t command_type, 1258 const void *data, 1259 uint32_t data_length, 1260 sl_si91x_wait_period_t wait_period, 1261 void *sdk_context, 1262 sl_wifi_buffer_t **data_buffer, 1263 uint8_t custom_host_desc); 1264 //! @endcond 1265 1266 /***************************************************************************/ /** 1267 * @brief 1268 * Wait for response packet 1269 * @pre Pre-conditions: 1270 * - 1271 * [sl_wifi_init()](../wiseconnect-api-reference-guide-wi-fi/wifi-common-api#sl-wifi-init) should be called before this API. 1272 * @param[in] queue 1273 * Buffer queue 1274 * @param[in] event_flag 1275 * Event flags 1276 * @param[in] event_mask 1277 * Packet id 1278 * @param[in] packet_id 1279 * Packet id 1280 * @param[in] wait_period 1281 * Wait period 1282 * @param[out] packet_buffer 1283 * Pointer that will contain the response packet buffer when the function successfully returns. 1284 * @return 1285 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 1286 ******************************************************************************/ 1287 sl_status_t sli_si91x_driver_wait_for_response_packet(sl_si91x_buffer_queue_t *queue, 1288 osEventFlagsId_t event_flag, 1289 uint32_t event_mask, 1290 uint16_t packet_id, 1291 sl_si91x_wait_period_t wait_period, 1292 sl_wifi_buffer_t **packet_buffer); 1293