Common APIs#
This section describes the Common APIs
Variables#
Initialize WiSeConnect driver. This is a non-blocking API. Designate memory to all driver components from the buffer provided by the application. ...........Initilize Scheduler, Events, and Queues needed.
Functions#
Return the common control block status. This is a non-blocking API.
Set the common control block status. This is a non-blocking API.
Configure the WLAN/Coex operating mode and also configures features based on bitmaps available in rsi_wlan_config.h. In case of failure, appropriate error code is returned to the application. Default configurations (for reference) are available in rsi_wlan_common_config.h. Based on the features required for a specific example, modify the rsi_wlan_config.h provided in the respective example folder. For more information about the bitmaps, refer Opermode-Parameters This is a blocking API.
Enable or disable UART flow control. This is a blocking API.
To write content on TA flash from M4. This is a blocking API.
Secure handshake. This is a blocking API.
Resets the module to a state that was before execution of rsi_wireless_init To choose the new configuration(operating mode) rsi_wireless_init() API needs to be called after this API. This is a blocking API.
Select antenna type on the device. This is a blocking API.
Select internal or external RF type, clock frequency and to pass Feature enables dynamically. This is a blocking API.
Select internal or external RF type and clock frequency.
This is a blocking API.
Get firmware version present in the device. This is a blocking API.
Get module type. This is a blocking API.
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.
To enable or disable BT. This is a blocking API.
Handles driver events. Called in application main loop for non-OS platforms.
With OS, this is a blocking API and without OS this API is a non-blocking API.
De-Initialize driver components by clearing all the memory given for driver operations through rsi_driver_init() API. With OS case, you need to take care of OS variables initialized in rsi_driver_init(). This API must be called by the thread/task/master thread that it is not dependent on the OS variables allocated/initialized in rsi_driver_init() API.
This is a non-blocking API.
In OS case, delete driver task before calling rsi_driver_deinit() API.
Get current driver version. This is a non-blocking API.
Set the host rtc timer. This is a blocking API.
Get ram log on UART/UART2. This is a blocking API.
Provide the memory required by the application. This is a non-blocking API.
De-register event handler for the given event. This is a non-blocking API.
Register SAPI wait timeout handler. This is a non-blocking API.
Fetch current time from hardware Real Time Clock. This is a blocking API.
Configure XO Ctune value from host.
Verifies ECDSA 256 digital signature. This is a blocking API.
Trigger an assert. This is a blocking API.
Configure TA GPIOs from host. This is a non-blocking API.
Drive the module GPIOs high or low from host. This is a non-blocking API.
Read status of TA GPIOs from host. This is a non-blocking API.
Read status of NWP GPIOs from host. This is a non-blocking API.
Drive the NWP GPIOs from host. This is a non-blocking API.
set/change the region on user based configuration
Power cycle the module and set the firmware image type to be loaded. This is a blocking API.
De-Initialize the module and reset the module.
Reset is driven to the module by asserting the reset pin for some duration and releasing it.
This is a non-blocking API.
Get the interrupt status.
Upgrade the firmware in the module from the host. The firmware file is given in chunks to this API.
Each chunk must be a multiple of 4096 bytes unless it is the last chunk.
This is blocking API.
Get RAM dump. This is blocking API.
Variable Documentation#
buffer_addr#
uint8_t* buffer_addr
Initialize WiSeConnect driver. This is a non-blocking API. Designate memory to all driver components from the buffer provided by the application. ...........Initilize Scheduler, Events, and Queues needed.
Returns
Success - Returns the memory used, which is less than or equal to buffer length provided.
Failure - Non-Zero values**RSI_ERROR_TIMEOUT** - If UART initialization fails in SPI / UART mode \n **RSI_ERROR_INVALID_PARAM** - If maximum sockets is greater than 10
101
of file common/rsi_common_apis.c
Function Documentation#
rsi_common_get_status#
int32_t rsi_common_get_status (void )
Return the common control block status. This is a non-blocking API.
[in] |
Returns
0 - Success
Non-Zero Value - Failure
Note
Precondition - rsi_device_init() API should be called before this API
66
of file common/rsi_common_apis.c
rsi_common_set_status#
void rsi_common_set_status (int32_t status)
Set the common control block status. This is a non-blocking API.
[in] | status | - Status of common control block |
Returns
0 - Success
Non-Zero Value - Failure
80
of file common/rsi_common_apis.c
rsi_driver_init#
int32_t rsi_driver_init (uint8_t * buffer, uint32_t length)
N/A | buffer | |
N/A | length |
102
of file common/rsi_common_apis.c
rsi_wireless_init#
int32_t rsi_wireless_init (uint16_t opermode, uint16_t coex_mode)
Configure the WLAN/Coex operating mode and also configures features based on bitmaps available in rsi_wlan_config.h. In case of failure, appropriate error code is returned to the application. Default configurations (for reference) are available in rsi_wlan_common_config.h. Based on the features required for a specific example, modify the rsi_wlan_config.h provided in the respective example folder. For more information about the bitmaps, refer Opermode-Parameters This is a blocking API.
[in] | opermode | - WLAN Operating mode |
[in] | coex_mode | - Coexistence mode 0 - WLAN only mode |
rsi_device_init() API needs to be called before this API.
Note
Precondition - rsi_device_init() API needs to be called before this API
WLAN operating mode 1 - WiFi-Direct mode is not supported.
Coex modes are supported only in 384K memory configuration.
Coex mode 4(Bluetooth classic), 8 (Dual mode), and 12(BLE mode) are not supported.
To achieve the same functionality, use coex mode 5, 9, and 13 respectively instead of coex mode 4, 8, and 12.
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0x0021,0x0025,0xFF73,0x002C,0xFF6E,0xFF6F, 0xFF70,0xFFC5)
Note
Refer to Error Codes for the description of above error codes.
452
of file common/rsi_common_apis.c
rsi_cmd_uart_flow_ctrl#
int32_t rsi_cmd_uart_flow_ctrl (uint8_t uartflow_en)
Enable or disable UART flow control. This is a blocking API.
[in] | uartflow_en | - Enable or Disable UART hardware flow control |
Returns
0 - Success
Non-Zero Value - Failure
Note
Hardware flow control feature is not supported in Auto-Join/Auto-Create mode.
In such a case, the feature has to be enabled separately.
652
of file common/rsi_common_apis.c
rsi_cmd_to_wr_comm_flash#
int32_t rsi_cmd_to_wr_comm_flash (uint32_t wr_addr, uint8_t * write_data, uint16_t wr_data_len, uint8_t flash_sector_erase_enable)
To write content on TA flash from M4. This is a blocking API.
[in] | wr_addr | - address at which data will be written on TA flash memory |
[in] | write_data | - Input data |
[in] | wr_data_len | - total length |
N/A | flash_sector_erase_enable |
Returns
0 - Success
Non-Zero Value - Failure
718
of file common/rsi_common_apis.c
rsi_cmd_m4_ta_secure_handshake#
int32_t rsi_cmd_m4_ta_secure_handshake (uint8_t sub_cmd_type, uint8_t input_len, uint8_t * input_data, uint8_t output_len, uint8_t * output_data)
Secure handshake. This is a blocking API.
[in] | sub_cmd_type | - Sub command |
[in] | input_len | - Input data |
[in] | input_data | - Length length |
[in] | output_len | - Output length |
[in] | output_data | - Output data |
Returns
0 - Success
Non-Zero Value - Failure
834
of file common/rsi_common_apis.c
rsi_wireless_deinit#
int32_t rsi_wireless_deinit (void )
Resets the module to a state that was before execution of rsi_wireless_init To choose the new configuration(operating mode) rsi_wireless_init() API needs to be called after this API. This is a blocking API.
[in] |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc)
Note
To restart the RS9116W module from the host, the application needs to call rsi_driver_deinit() followed by rsi_driver_init() and rsi_device_init(). For OS cases, additionally needs to call rsi_task_destroy(driver_task_handle) to delete the driver task before calling rsi_driver_deinit() and should create again, after rsi_device_init() using rsi_task_create()
Refer to Error Codes for the description of above error codes.
925
of file common/rsi_common_apis.c
rsi_wireless_antenna#
int32_t rsi_wireless_antenna (uint8_t type, uint8_t gain_2g, uint8_t gain_5g)
Select antenna type on the device. This is a blocking API.
[in] | type | - 0 : RF_OUT_2/Internal Antenna is selected |
[in] | gain_2g | - Currently not supported |
[in] | gain_5g | - Currently not supported |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffc, 0x0025, 0x002C)
Note
Precondition - rsi_wlan_radio_init API needs to be called before this API.
Refer to Error Codes for the description of above error codes.
1046
of file common/rsi_common_apis.c
rsi_send_feature_frame_dyn#
int32_t rsi_send_feature_frame_dyn (uint32_t feature_enables)
Select internal or external RF type, clock frequency and to pass Feature enables dynamically. This is a blocking API.
[in] | feature_enables | - Feature enables |
Returns
0 - Success
Negative Value - Failure (Possible Error Codes -0xfffffffe, 0xfffffffd, 0xfffffffc, 0x0021, 0xFF74)
Note
Precondition - rsi_wireless_init() API needs to be called before this API.
Refer to Error Codes for the description of above error codes.
1138
of file common/rsi_common_apis.c
rsi_send_feature_frame#
int32_t rsi_send_feature_frame (void )
Select internal or external RF type and clock frequency.
This is a blocking API.
N/A |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0x0021, 0xFF74)
If return value is less than 0
Note
Precondition - rsi_wireless_init API needs to be called before this API.
Refer to Error Codes for the description of above error codes.
1226
of file common/rsi_common_apis.c
rsi_get_fw_version#
int32_t rsi_get_fw_version (uint8_t * response, uint16_t length)
Get firmware version present in the device. This is a blocking API.
[in] | response | - Length of the response buffer in bytes to hold result. |
[out] | length | - Response of the requested command. |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0xfffffffa, 0x0021, 0x0025, 0x002c)
Note
Refer to Error Codes for the description of above error codes.
1321
of file common/rsi_common_apis.c
rsi_get_module_type#
int32_t rsi_get_module_type (uint8_t * response)
Get module type. This is a blocking API.
[out] | response | - Response of the requested command. |
Need to call after the device initialization, rsi_device_init API
Returns
0 - Success
Non-Zero Value - Failure
If return value is less than 0
-3: Command given in wrong state
-4: Buffer not available to serve the command
-6: Insufficient input buffer given
If return value is greater than 0
0x0021, 0x0025, 0x002c
Note
Refer to Error Codes section for above error codes Error Codes .
1430
of file common/rsi_common_apis.c
rsi_common_debug_log#
int32_t rsi_common_debug_log (int32_t assertion_type, int32_t assertion_level)
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.
[in] | assertion_type | - Assertion_type (Possible values 0 - 15) |
[in] | assertion_level | - Assertion_level (Possible values 0 - 15) |
Returns
0 - Success
Non-Zero value - Failure (Possible Error Codes - 0xfffffffe)
Note
Refer to Error Codes for the description of above error codes.
To minimize the debug prints host is supposed to give the same API with assertion type and assertion level as 0.
Baud rate for UART 2 on host application side should be 460800.
Enable few feature bit maps for getting debug logs on UART:
(#define RSI_CUSTOM_FEATURE_BIT_MAP FEAT_CUSTOM_FEAT_EXTENTION_VALID) and
(#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_UART_SEL_FOR_DEBUG_PRINTS)
1544
of file common/rsi_common_apis.c
rsi_switch_proto#
int32_t rsi_switch_proto (uint8_t type, void(*)(uint16_t mode, uint8_t *bt_disabled_status) callback, mode, bt_disabled_status)
To enable or disable BT. This is a blocking API.
[in] | type | - Type |
[in] | callback | - Indicate BT enable or disable based on mode value |
[out] | mode | - Indicate BT enable or disable |
[out] | bt_disabled_status | - BT disabled status either success or failure to host |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xFF)
Note
Refer to Error Codes for the description of above error codes.
1627
of file common/rsi_common_apis.c
rsi_wireless_driver_task#
void rsi_wireless_driver_task (void )
Handles driver events. Called in application main loop for non-OS platforms.
With OS, this is a blocking API and without OS this API is a non-blocking API.
[in] |
Returns
None
1720
of file common/rsi_common_apis.c
rsi_driver_deinit#
int32_t rsi_driver_deinit (void )
De-Initialize driver components by clearing all the memory given for driver operations through rsi_driver_init() API. With OS case, you need to take care of OS variables initialized in rsi_driver_init(). This API must be called by the thread/task/master thread that it is not dependent on the OS variables allocated/initialized in rsi_driver_init() API.
This is a non-blocking API.
[in] |
Returns
0 - Success
Non-Zero Value - Failure
Note
Precondition - rsi_driver_init API needs to be called before this API.
1745
of file common/rsi_common_apis.c
rsi_destroy_driver_task_and_driver_deinit#
int32_t rsi_destroy_driver_task_and_driver_deinit (rsi_task_handle_t * task_handle)
In OS case, delete driver task before calling rsi_driver_deinit() API.
[in] | task_handle | - Task handle/instance to be deleted |
Returns
0 - Success
Non-Zero Value - Failure
Note
Precondition - rsi_driver_init API needs to be called before this API.
1991
of file common/rsi_common_apis.c
rsi_driver_version#
int32_t rsi_driver_version (uint8_t * request)
Get current driver version. This is a non-blocking API.
[in] | request | - Pointer to fill driver version |
Returns
0 - Success
Non-Zero Value - Failure
2015
of file common/rsi_common_apis.c
rsi_set_rtc_timer#
int32_t rsi_set_rtc_timer (module_rtc_time_t * timer)
Set the host rtc timer. This is a blocking API.
[in] | timer | - Pointer to fill RTC time. second --> seconds [0-59] |
Returns
0 - Success
Non-Zero Value - Failure
Note
Precondition - rsi_wireless_init() API needs to be called before this API
Hour is 24-hour format only (valid values are 0 to 23). Valid values for Month are 0 to 11 (January to December).
2043
of file common/rsi_common_apis.c
rsi_get_ram_log#
int32_t rsi_get_ram_log (uint32_t addr, uint32_t length)
Get ram log on UART/UART2. This is a blocking API.
[in] | addr | - Address in RS9116 module |
[in] | length | - Chunk length to read from RS9116 module |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0x0021, 0x003E)
Note
rsi_wireless_init() needs to be called before this API.
Refer to Error Codes for the description of above error codes.
2131
of file common/rsi_common_apis.c
rsi_driver_memory_estimate#
int32_t rsi_driver_memory_estimate (void )
Provide the memory required by the application. This is a non-blocking API.
[in] |
Returns
Driver pool size
2204
of file common/rsi_common_apis.c
rsi_uregister_events_callbacks#
void rsi_uregister_events_callbacks (void(*)(uint32_t event_num) callback_handler_ptr)
De-register event handler for the given event. This is a non-blocking API.
[out] | callback_handler_ptr | - Event number |
Returns
0 - Success
Non-Zero Value- Failure
2221
of file common/rsi_common_apis.c
rsi_register_wait_timeout_error_callbacks#
void rsi_register_wait_timeout_error_callbacks (void(*)(int32_t status, uint32_t cmd_type) callback_handler_ptr, cmd_type)
Register SAPI wait timeout handler. This is a non-blocking API.
[out] | callback_handler_ptr | - Status |
[out] | cmd_type | - Command |
Returns
0 - Success
Non-Zero - Failure
2237
of file common/rsi_common_apis.c
rsi_get_rtc_timer#
int32_t rsi_get_rtc_timer (module_rtc_time_t * response)
Fetch current time from hardware Real Time Clock. This is a blocking API.
[out] | response | - Response of the requested command. |
rsi_set_rtc_timer() API needs to be called before this API. Also this API needs to be called only after rsi_wlan_scan() API or rsi_wlan_radio_init() API.
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0x0021, 0x0025)
Note
Precondition - rsi_set_rtc_timer() API needs to be called before this API.
rsi_wlan_scan() API or rsi_wlan_radio_init() API needs to be called before this API.Hour is 24-hour format only (valid values are 0 to 23). Valid values for Month are 0 to 11 (January to December).
Refer to Error Codes for the description of above error codes.
2270
of file common/rsi_common_apis.c
rsi_set_config#
int32_t rsi_set_config (uint32_t code, uint8_t value)
Configure XO Ctune value from host.
[in] | code | - XO_CTUNE_FROM_HOST |
[in] | value | - Value to be configured |
Returns
0 - Success
Non-Zero Value - Failure
2346
of file common/rsi_common_apis.c
rsi_ecdsa_256_verify_hash#
int32_t rsi_ecdsa_256_verify_hash (uint8_t * signature, uint16_t signature_length, uint8_t * digest, uint16_t digest_length, uint8_t * key, uint16_t key_length)
Verifies ECDSA 256 digital signature. This is a blocking API.
[in] | signature | - The signature buffer |
[in] | signature_length | - Length of the signature |
[in] | digest | - Digest of the message that needs to be verified |
[in] | digest_length | - Total digest length |
[in] | key | - The public key used to verify hash. |
[in] | key_length | - Total key length |
Returns
0 - Success
Non-Zero Value - Failure
Note
Refer Error Codes section for above error codes Error Codes.
2425
of file common/rsi_common_apis.c
rsi_assert#
int32_t rsi_assert (void )
Trigger an assert. This is a blocking API.
[in] |
Returns
0 - Success
Non-Zero Value - Failure
2520
of file common/rsi_common_apis.c
rsi_gpio_pininit#
int32_t rsi_gpio_pininit (uint8_t gpio_type, uint8_t pin_num, uint8_t configuration)
Configure TA GPIOs from host. This is a non-blocking API.
[in] | gpio_type | - GPIO types : |
[in] | pin_num | - GPIO Number : |
[in] | configuration | - BIT[0 - 1] : Drive strength |
Returns
0 - Success
Non-Zero Value - Failure
Note
It is not recommended to configure ULP_GPIO_6 as it is used for WoW feature
You need to define the CONFIGURE_GPIO_FROM_HOST to enable this API
2607
of file common/rsi_common_apis.c
rsi_gpio_writepin#
int32_t rsi_gpio_writepin (uint8_t gpio_type, uint8_t pin_num, uint8_t value)
Drive the module GPIOs high or low from host. This is a non-blocking API.
[in] | gpio_type | - GPIO types : |
[in] | pin_num | - GPIO Number : |
[in] | value | - Value to be driven on GPIO |
Returns
0 - Success
Non-Zero Value - Failure
Note
It is not recommended to configure ULP_GPIO_6 as it is used for WoW feature
You need to define the CONFIGURE_GPIO_FROM_HOST to enable this API
2683
of file common/rsi_common_apis.c
rsi_gpio_readpin#
int32_t rsi_gpio_readpin (uint8_t gpio_type, uint8_t pin_num, uint8_t * gpio_value)
Read status of TA GPIOs from host. This is a non-blocking API.
[in] | gpio_type | - GPIO types : |
[in] | pin_num | - GPIO Number : |
[in] | gpio_value | - Address of variable to store the value |
Returns
0 - Success
Non-Zero Value - Failure
Note
It is not recommended to configure ULP_GPIO_6 as it is used for WoW feature.
You need to define the CONFIGURE_GPIO_FROM_HOST to enable this API.
2756
of file common/rsi_common_apis.c
rsi_gpio_read#
int32_t rsi_gpio_read (uint8_t gpio_num)
Read status of NWP GPIOs from host. This is a non-blocking API.
[in] | gpio_num | - GPIO Number : |
Returns
0 - Status of NWP GPIO is LOW
1 - status of NWP GPIO is HIGH
Non-Zero Value (< 0) - Failure
2827
of file common/rsi_common_apis.c
rsi_gpio_write#
int32_t rsi_gpio_write (uint8_t gpio_num, uint8_t write)
Drive the NWP GPIOs from host. This is a non-blocking API.
[in] | gpio_num | - GPIO Number : |
[in] | write | - Value to be driven on GPIO |
Returns
0 - Success
Non-Zero Value - Failure
Note
You need to define the CONFIGURE_GPIO_FROM_HOST to enable this API
2866
of file common/rsi_common_apis.c
rsi_set_region#
int32_t rsi_set_region (void )
set/change the region on user based configuration
[in] |
Returns
0 - Success
Non-Zero Value - Failure
2886
of file common/rsi_common_apis.c
rsi_device_init#
int32_t rsi_device_init (uint8_t select_option)
Power cycle the module and set the firmware image type to be loaded. This is a blocking API.
[in] | select_option | - LOAD_NWP_FW : To load Firmware image |
Returns
Non-Zero Value - Failure
Note
Precondition - rsi_driver_init() must be called before this API.
Add the ENABLE_POC_IN_TOGGLE macro in the preprocessor to enable toggling of the POC_IN pin if it is controlled by the host to power cycle the module. For STM32 and EFM32 hosts, pins have been configured to drive the POC_IN pin. For EFR32, a pin has to be configured by the user to drive the POC_IN pin.
Returns
Success - RSI_SUCCESS
Failure - Non-Zero Value
58
of file common/rsi_device_init_apis.c
rsi_device_deinit#
int32_t rsi_device_deinit (void )
De-Initialize the module and reset the module.
Reset is driven to the module by asserting the reset pin for some duration and releasing it.
This is a non-blocking API.
[in] |
Returns
0 - Success
Non-Zero Value - Failure
266
of file common/rsi_device_init_apis.c
rsi_get_intr_status#
uint8_t rsi_get_intr_status ( NA)
Get the interrupt status.
[in] | NA |
Returns
1 - when there is an interrupt
0 - when there is no interrupt
359
of file common/rsi_device_init_apis.c
rsi_bl_upgrade_firmware#
int16_t rsi_bl_upgrade_firmware (uint8_t * firmware_image, uint32_t fw_image_size, uint8_t flags)
Upgrade the firmware in the module from the host. The firmware file is given in chunks to this API.
Each chunk must be a multiple of 4096 bytes unless it is the last chunk.
This is blocking API.
[in] | firmware_image | - This is a pointer to firmware image buffer |
[in] | fw_image_size | - This is the size of firmware image |
[in] | flags | - 1 - RSI_FW_START_OF_FILE, set for the first chunk |
Note
In rsi_bootloader_instructions() API, by default the RSI_HAL_MAX_WR_BUFF_LEN macro (Max supported write buffer size) is 4096 bytes. You can reduce this buffer size (minimum value of 1600 bytes is expected) as per HAL memory availability at the cost of the increase in execution time of this API.
This macro can be configured in rsi_user.h file.
Example: uint8_t dummy[RSI_HAL_MAX_WR_BUFF_LEN];For safe firmware upgrade via the bootloader,
it will take approx. 65 sec duration for upgrading the firmware of 1.5 MB file.For fast firmware upgrade via the bootloader,
it will take approx. 35 sec duration for upgrading the firmware of 1.5 MB file.
Returns
0 - Success
Non-Zero Value - Failure
284
of file driver/rsi_device_init.c
rsi_get_ram_dump#
int32_t rsi_get_ram_dump (uint32_t addr, uint16_t length, uint8_t * buf)
Get RAM dump. This is blocking API.
[in] | addr | - Address of memory location in RS9116 |
[in] | length | - Length of the content to read |
[out] | buf | - Buffer to keep the read content |
Returns
0 - Success
Non-Zero Value - Failure
Note
Precondition - rsi_wireless_init() API needs to be called before this API.
606
of file driver/rsi_device_init.c