Common APIs#
This section describes the Common APIs
Functions#
Return common block status. This is a non-blocking API.
Set the common block status. This is a non-blocking API.
Initialize WiSeConnect or Module features. This is a blocking API. RSI_SUCCESS return value indicates that the opermode and coex value were set successfully in the FW. In case of failure, appropriate error code is returned to the application. Apart from setting WLAN/Coex Operating mode, this API also configures other features based on selected Feature Bitmaps. In this API, configured feature bitmaps are internally processed and sent to firmware. These feature bitmaps are also called Opermode Command Parameters. 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 these feature bitmaps, refer SP18.
Enable or disable UART flow control. This is a blocking API.
Secure handshake. This is a blocking API.
Reset WiSeConnect module, load the firmware and restart the driver.This API should be called before rsi_wireless_init API, if user wants to change the previous configuration given through rsi_wireless_init. This is a blocking API.
Select antenna type on the device. This is a blocking API.
Select internal or external RF type and clock frequency for user 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.
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.
Handle driver events. Called in application main loop for non-OS platforms. /n With OS, this API is blocking and with baremetal this API is non-blocking.
De-Initialize driver components. Clear all the memory given for driver operations in rsi_driver_init() API. In OS case, User need to take care of OS variables initialized in rsi_driver_init(). This is a non-blocking API. This API must be called by the thread/task/Master thread that it is not dependent on. OS variables allocated/initialized in rsi_driver_init() 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.
Trigger an assert. This is a blocking API.
Configure TA GPIOs using Command from host.This is a non-blocking API.
Drive the Module GPIOs high or low using command from host. This is a non-blocking API.
Read status of TA GPIOs using Command from host. This is a non-blocking API.
Power cycle the module and set the firmware image type to be loaded for WiSeConnect features. Initialize the module SPI. This is a blocking API.
De-Initialize the module and reset the module. Reset is driven to the module by asserting the RESET_PS pin for some duration and releasing it. Need to control the RESET_PS pin to reset the module. This is a non-blocking API.
Upgrade the firmware in the WiSeConnect device 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.For the first chunk, set RSI_FW_START_OF_FILE in flags.For the last chunk set RSI_FW_END_OF_FILE in flags. This is blocking API.
Get ram dump through master reads. This is blocking API.
Function Documentation#
rsi_common_get_status#
int32_t rsi_common_get_status (void )
Return common block status. This is a non-blocking API.
[in] |
Returns
0 - Success Non-Zero Value - Failure
60
of file common/rsi_common_apis.c
rsi_common_set_status#
void rsi_common_set_status (int32_t status)
Set the common block status. This is a non-blocking API.
[in] | status | - Status of common control block |
Returns
0 - Success Non-Zero Value - Failure
74
of file common/rsi_common_apis.c
rsi_wireless_init#
int32_t rsi_wireless_init (uint16_t opermode, uint16_t coex_mode)
Initialize WiSeConnect or Module features. This is a blocking API. RSI_SUCCESS return value indicates that the opermode and coex value were set successfully in the FW. In case of failure, appropriate error code is returned to the application. Apart from setting WLAN/Coex Operating mode, this API also configures other features based on selected Feature Bitmaps. In this API, configured feature bitmaps are internally processed and sent to firmware. These feature bitmaps are also called Opermode Command Parameters. 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 these feature bitmaps, refer SP18.
[in] | opermode | - WLAN Operating mode 0 - Client mode 2 - Enterprise security client mode 6 - Access point mode 8 - Transmit test mode 9 - Concurrent mode |
[in] | coex_mode | - Coexistence mode 0 - WLAN only mode 1 - WLAN 4 - Bluetooth 5 - WLAN + Bluetooth 8 - Dual Mode (Bluetooth and BLE) 9 - WLAN + Dual Mode 12- BLE mode 13- WLAN + BLE |
rsi_driver_init() followed by rsi_device_init() API needs to be called before this API.
Note
1. Coex modes are supported only in 384K memory configuration.
2. Coex mode 4(Bluetooth classic), 8 (Dual mode), and 12(BLE mode) are not supported.
3. To achieve the same functionality, use coexmode 5, 9, and 13 respectively instead of coexmode 4, 8, and 12.
4. To achieve power save functionality, trigger 'rsi_wlan_radio_init()' API after rsi_wireless_init() API and also issue both WLAN and BT power save commands.
Returns
Success - RSI_SUCCESS Failure - Non-Zero Value
`If return value is less than 0` \n **RSI_ERROR_INVALID_PARAM** - Invalid parameters \n
RSI_ERROR_COMMAND_GIVEN_IN_WRONG_STATE - Command given in wrong state RSI_ERROR_PKT_ALLOCATION_FAILURE - Buffer not available to serve the command Other expected error codes are :
0x0021,0x0025,0xFF73,0x002C,0xFF6E,0xFF6F, 0xFF70,0xFFC5Note
Refer to Error Codes section for the above error codes Error Codes.
439
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 1/2 - Enable and Pin set to be used to for RTS/CTS purpose. 0 - Disable If uart_hw_flowcontrol_enable parameter is 0, uart flow control is disabled. If the parameter is given as 1 or 2, then UART hardware flow control is enabled and Pin set to be used If parameter is given as 1: Pin set used for RTS/CTS functionality is: UART_CTS: GPIO - 11 UART_RTS: GPIO - 7 If parameter is given as 2: Pin set used for RTS/CTS functionality is: UART_CTS: GPIO - 15 UART_RTS: GPIO - 12 |
Returns
0 - Success Negative Value - Failure
730
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 Negative Value - Failure
794
of file common/rsi_common_apis.c
rsi_wireless_deinit#
int32_t rsi_wireless_deinit (void )
Reset WiSeConnect module, load the firmware and restart the driver.This API should be called before rsi_wireless_init API, if user wants to change the previous configuration given through rsi_wireless_init. This is a blocking API.
[in] |
Returns
0 - Success Negative Value - Failure -2: Invalid parameters -3: Command given in wrong state -4: Buffer not available to serve the command
Note
To restart RS9116W module from host, 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()
882
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 1 : RF_OUT_1/uFL connector is selected. |
[in] | gain_2g | - Currently not supported |
[in] | gain_5g | - Currently not supported |
rsi_wireless_antenna API must be given after rsi_wlan_radio_init API.
Note
1. Currently ignore the gain_2g, gain_5g, antenna_path, antenna_type values.
2. Currently wireless_antenna selection is not supported.
Returns
0 - Success Non-Zero Value - Failure If return value is less than 0 -4: Buffer not available to serve the command If return value is greater than 0 0x0025, 0x002C
Note
Refer to Error Codes section for the above error codes Error Codes.
1003
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 and clock frequency for user to pass Feature enables dynamically. This is a blocking API.
[in] | feature_enables | - Feature enables |
rsi_wireless_init() API needs to be called before this API
Note
BIT[0] - Enable Preamble duty cycling.
BIT[4] - Enable LP chain for stand-by associate mode.
BIT[5] - Enable hardware beacon drop during power save.
Remaining bits are reserved.
Returns
0 - Success Negative Value - Failure If return value is less than 0 -2 : Invalid parameters -3 : Command given in wrong state -4 : Buffer not available to serve the command If return value is greater than 0 0x0021, 0xFF74
Note
Refer to Error Codes section for above error codes Error Codes.
1095
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 |
rsi_wireless_init() API needs to be called before this API
Returns
0 - Success Non-Zero Value - Failure If return value is less than 0 -2 : Invalid parameters -3 : Command given in wrong state -4 : Buffer not available to serve the command If return value is greater than 0 0x0021, 0xFF74
Note
Refer to Error Codes section for above error codes Error Codes.
1181
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 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 .
1272
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) 0000 - LMAC core, 0001 - SME, 0010 - UMAC, 0100 - NETX, 1000 - Enables assertion indication and provides ram dump in critical assertion. |
[in] | assertion_level | - Assertion_level (Possible values 0 - 15). value 1 is least value/only specific prints, 15 is the highest level/Enable all prints. 0000 - Assertion required, 0010 - Recoverable, 0100 - Information |
Returns
0 - Success Non-Zero value - Failure -2 - Parameters invalid
Note
1. To minimize the debug prints host is supposed to give the same command with assertion type and assertion level as 0.
Baud rate for UART 2 on host application side should be 460800.
Enable few Feature bit map for getting debug logs on UART: // To set custom feature select bit map #define RSI_CUSTOM_FEATURE_BIT_MAP FEAT_CUSTOM_FEAT_EXTENTION_VALID // To set Extended custom feature select bit map #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_UART_SEL_FOR_DEBUG_PRINTS
1366
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 Negative Value - Failure 0xFF - BT_ACTIVITY_PENDING
Note
Refer Error Codes section for above error codes Error Codes .
1444
of file common/rsi_common_apis.c
rsi_wireless_driver_task#
void rsi_wireless_driver_task (void )
Handle driver events. Called in application main loop for non-OS platforms. /n With OS, this API is blocking and with baremetal this API is non-blocking.
[in] |
Returns
Void
1531
of file common/rsi_common_apis.c
rsi_driver_deinit#
int32_t rsi_driver_deinit (void )
De-Initialize driver components. Clear all the memory given for driver operations in rsi_driver_init() API. In OS case, User need to take care of OS variables initialized in rsi_driver_init(). This is a non-blocking API. This API must be called by the thread/task/Master thread that it is not dependent on. OS variables allocated/initialized in rsi_driver_init() API.
[in] |
Need to call after the driver initialization
Returns
0 - Success Non-Zero Value - Failure
1553
of file common/rsi_common_apis.c
rsi_driver_version#
int32_t rsi_driver_version (uint8_t * request)
N/A | request |
1755
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 |
rsi_wireless_init() API needs to be called before this API
Returns
0 - Success Non-Zero Value - Failure
Note
Hour is 24-hour format only (valid values are 0 to 23). Valid values for Month are 0 to 11 (January to December).
1774
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 |
rsi_wireless_init() API needs to be called before this API.
Returns
0 - Success Non-Zero Value - Failure If return value is less than 0 -2: Invalid parameters -3: Command given in wrong state If return value is greater than 0 0x0021,0x003E
Note
Refer to Error Codes section for above error codes Error Codes.
1852
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
1918
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
1935
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
1949
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.
Note
Response parameters: second --> Current real time clock seconds. minute --> Current real time clock minute. hour --> Current real time clock hour. day --> Current real time clock day. month --> Current real time clock month. year --> Current real time clock year. Weekday--> Current real time clock Weekday.
Returns
0 - Success Non-Zero Value - Failure 0x0021, 0x0025
Note
Hour is 24-hour format only (valid values are 0 to 23). Valid values for Month are 0 to 11 (January to December).
1977
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
2046
of file common/rsi_common_apis.c
rsi_gpio_pininit#
int32_t rsi_gpio_pininit (uint8_t pin_num, uint8_t configuration)
Configure TA GPIOs using Command from host.This is a non-blocking API.
[in] | pin_num | - GPIO Number : Valid values 0 - 15 |
[in] | configuration | - BIT[4]- 1 - Input mode 0 - Output mode BIT[0 - 1] - Drive strength : 0 - 2mA , 1 - 4mA , 2 - 8mA, 3 - 12mA BIT[6 - 7] : 0 - Hi-Z, 1- Pull-up, 2- Pull-down |
Returns
0 - Success Non-Zero Value - Failure
2107
of file common/rsi_common_apis.c
rsi_gpio_writepin#
int32_t rsi_gpio_writepin (uint8_t pin_num, uint8_t value)
Drive the Module GPIOs high or low using command from host. This is a non-blocking API.
[in] | pin_num | - GPIO Number : Valid values 0 - 15 |
[in] | value | - Value to be driven on GPIO 1 - Drive high 0 - Drive Low |
Returns
0 - Success Non-Zero Value - Failure
2158
of file common/rsi_common_apis.c
rsi_gpio_readpin#
int32_t rsi_gpio_readpin (uint8_t pin_num, uint8_t * gpio_value)
Read status of TA GPIOs using Command from host. This is a non-blocking API.
[in] | pin_num | - GPIO Number : Valid values 0 - 15 |
[in] | gpio_value | - Address of variable to store the value |
Returns
0 - Success Non-Zero Value - Failure
2207
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 for WiSeConnect features. Initialize the module SPI. This is a blocking API.
[in] | select_option | - LOAD_NWP_FW : To load Firmware image LOAD_DEFAULT_NWP_FW_ACTIVE_LOW : To load active low Firmware image. Active low firmware will generate active low interrupts to indicate that packets are pending on the module, instead of the default active high. |
rsi_driver_init() must be called before this API
Returns
Success - RSI_SUCCESS Failure - Non-Zero Value
55
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_PS pin for some duration and releasing it. Need to control the RESET_PS pin to reset the module. This is a non-blocking API.
[in] |
Returns
0 - Success Non-Zero Value - Failure
245
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 WiSeConnect device 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.For the first chunk, set RSI_FW_START_OF_FILE in flags.For the last chunk set RSI_FW_END_OF_FILE in flags. 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 2 - RSI_FW_END_OF_FILE Set flags to 1 - if it is the first chunk 2 - if it is last chunk 0 - for all other chunks |
Note
1. In rsi_bootloader_instructions() API, By default, RSI_HAL_MAX_WR_BUFF_LEN Macro (Max supported write buffer size) is 4096 bytes. Users 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 at rsi_user.h Example: uint8_t dummy[RSI_HAL_MAX_WR_BUFF_LEN];
2. For safe firmware upgrade via the bootloader, it will take approx. 65 sec duration for upgrading the firmware of 1.5 MB file.
3. 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
288
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 through master reads. 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 |
rsi_wireless_init() API needs to be called before this API.
Returns
0 - Success Non-Zero Value - Failure
549
of file driver/rsi_device_init.c