Common APIs#

This section describes the Common APIs

Variables#

uint8_t *

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#

int32_t

Return the common control block status. This is a non-blocking API.

void
rsi_common_set_status(int32_t status)

Set the common control block status. This is a non-blocking API.

int32_t
rsi_driver_init(uint8_t *buffer, uint32_t length)
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.

int32_t
rsi_cmd_uart_flow_ctrl(uint8_t uartflow_en)

Enable or disable UART flow control. This is a blocking API.

int32_t

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.

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.

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.

int32_t

Select internal or external RF type and clock frequency.
This is a blocking API.

int32_t
rsi_get_fw_version(uint8_t *response, uint16_t length)

Get firmware version present in the device. This is a blocking API.

int32_t
rsi_get_module_type(uint8_t *response)

Get module type. This is a blocking API.

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.

int32_t
rsi_switch_proto(uint8_t type, void(*callback)(uint16_t mode, uint8_t *bt_disabled_status))

To enable or disable BT. This is a blocking API.

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.

int32_t

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.

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.

int32_t
rsi_driver_version(uint8_t *request)

Get current driver version. This is a non-blocking API.

int32_t
rsi_set_rtc_timer(module_rtc_time_t *timer)

Set the host rtc timer. This is a blocking API.

int32_t
rsi_get_ram_log(uint32_t addr, uint32_t length)

Get ram log on UART/UART2. This is a blocking API.

int32_t

Provide the memory required by the application. This is a non-blocking API.

void
rsi_uregister_events_callbacks(void(*callback_handler_ptr)(uint32_t event_num))

De-register event handler for the given event. This is a non-blocking API.

void
rsi_register_wait_timeout_error_callbacks(void(*callback_handler_ptr)(int32_t status, uint32_t cmd_type))

Register SAPI wait timeout handler. This is a non-blocking API.

int32_t
rsi_get_rtc_timer(module_rtc_time_t *response)

Fetch current time from hardware Real Time Clock. This is a blocking API.

int32_t
rsi_set_config(uint32_t code, uint16_t value)

This function sets the configuration for the Network Processor based on configuration code.

int32_t

set/change the region on user based configuration

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.

int32_t

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.

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.

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
    

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.

Parameters
TypeDirectionArgument NameDescription
void[in]

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note


rsi_common_set_status#

void rsi_common_set_status (int32_t status)

Set the common control block status. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]status

- Status of common control block

Returns

  • 0 - Success

  • Non-Zero Value - Failure


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.

Parameters
TypeDirectionArgument NameDescription
uint16_t[in]opermode

- WLAN Operating mode
0 - Client mode
2 - Enterprise security client mode
6 - Access point mode
8 - Transmit test mode
9 - Concurrent mode

uint16_t[in]coex_mode

- Coexistence mode 0 - WLAN only mode
1 - WLAN
5 - WLAN + Bluetooth
9 - WLAN + Dual Mode (Bluetooth and BLE)
13- WLAN + BLE

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.


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.

Parameters
TypeDirectionArgument NameDescription
uint8_t[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 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

  • 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.


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.

Parameters
TypeDirectionArgument NameDescription
void[in]

Returns

  • 0 - Success

  • Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc)

Note


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.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]type

- 0 : RF_OUT_2/Internal Antenna is selected
1 : RF_OUT_1/uFL connector is selected.

uint8_t[in]gain_2g

- Currently not supported

uint8_t[in]gain_5g

- Currently not supported

Returns

  • 0 - Success

  • Non-Zero Value - Failure (Possible Error Codes - 0xfffffffc, 0x0025, 0x002C)

Note


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.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]feature_enables

- Feature enables
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 (Possible Error Codes -0xfffffffe, 0xfffffffd, 0xfffffffc, 0x0021, 0xFF74)

Note


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.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • 0 - Success

  • Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0x0021, 0xFF74)
    If return value is less than 0

Note


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.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[in]response

- Length of the response buffer in bytes to hold result.

uint16_t[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.


rsi_get_module_type#

int32_t rsi_get_module_type (uint8_t * response)

Get module type. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[out]response

- Response of the requested command.
0 - B8
1 - Q7 (QMS)
2 - Q7 + EXT FLASH
3 - DB_T
4 - SB
5 - M7DB (CC0)
6 - M4SB (B00)
7 - B6F
8 - B8SDB
9 - W2
10 - WMS

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 .


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.

Parameters
TypeDirectionArgument NameDescription
int32_t[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.

int32_t[in]assertion_level

- Assertion_level (Possible values 0 - 15)
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 (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)


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.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]type

- Type

void(*)(uint16_t mode, uint8_t *bt_disabled_status)[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.


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.

Parameters
TypeDirectionArgument NameDescription
void[in]

Returns

  • None


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.

Parameters
TypeDirectionArgument NameDescription
void[in]

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note


References buffer_addr , rsi_driver_cb_s::common_cb , rsi_driver_cb_non_rom::common_cmd_sem , rsi_driver_cb_non_rom::common_cmd_send_sem , rsi_common_cb_s::common_mutex , rsi_common_cb_s::common_sem , rsi_common_cb_s::common_tx_pool , rsi_driver_cb_s::common_tx_q , rsi_driver_cb_non_rom::device_state , rsi_driver_cb_non_rom::nwk_cmd_send_sem , rsi_driver_cb_non_rom::nwk_sem , rsi_pkt_pool_s::pkt_sem , rsi_queue_cb_s::queue_mutex , rsi_check_pkt_queue_and_dequeue , rsi_driver_memory_estimate , rsi_mutex_destroy , rsi_release_waiting_semaphore , rsi_semaphore_destroy , rsi_driver_cb_s::rx_pool , rsi_driver_cb_s::scheduler_cb , rsi_scheduler_cb_s::scheduler_sem , rsi_driver_cb_non_rom::send_data_sem , rsi_common_cb_s::state , rsi_wlan_cb_s::state , status , rsi_driver_cb_non_rom::tx_mutex , rsi_driver_cb_s::wlan_cb , rsi_driver_cb_non_rom::wlan_cmd_sem , rsi_driver_cb_non_rom::wlan_cmd_send_sem , rsi_wlan_cb_s::wlan_mutex , rsi_wlan_cb_s::wlan_sem , rsi_wlan_cb_s::wlan_tx_pool , and rsi_driver_cb_s::wlan_tx_q

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.

Parameters
TypeDirectionArgument NameDescription
rsi_task_handle_t *[in]task_handle

- Task handle/instance to be deleted

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note


References rsi_driver_deinit , and status

rsi_driver_version#

int32_t rsi_driver_version (uint8_t * request)

Get current driver version. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[in]request

- Pointer to fill driver version

Returns

  • 0 - Success

  • Non-Zero Value - Failure


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.

Parameters
TypeDirectionArgument NameDescription
module_rtc_time_t *[in]timer

- Pointer to fill RTC time. second --> seconds [0-59]
minute --> minutes [0-59]
hour --> hours since midnight [0-23]
day --> day of the month [1-31]
month --> months since January [0-11]
year --> year since 1990.
Weekday--> Weekday from Sunday to Saturday [1-7]

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note

  • Precondition - rsi_wireless_init() API needs to be called before this API

  • This API is not supported when power save mode is enabled

  • Hour is 24-hour format only (valid values are 0 to 23). Valid values for Month are 0 to 11 (January to December).


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.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]addr

- Address in RS9116 module

uint32_t[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_driver_memory_estimate#

int32_t rsi_driver_memory_estimate (void )

Provide the memory required by the application. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
void[in]

Returns

  • Driver pool size


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.

Parameters
TypeDirectionArgument NameDescription
void(*)(uint32_t event_num)[out]callback_handler_ptr

- Event number

Returns

  • 0 - Success

  • Non-Zero Value- Failure


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.

Parameters
TypeDirectionArgument NameDescription
void(*)(int32_t status, uint32_t cmd_type)[out]callback_handler_ptr

- Status

[out]cmd_type

- Command

Returns

  • 0 - Success

  • Non-Zero - Failure


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.

Parameters
TypeDirectionArgument NameDescription
module_rtc_time_t *[out]response

- Response of the requested command.
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 (Possible Error Codes - 0x0021, 0x0025)

Note

  • Precondition - rsi_set_rtc_timer() API needs to be called before this API.

  • rsi_wireless_init() needs to be called before this API.

  • This API is not supported when power save mode is enabled.

  • 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.


rsi_set_config#

int32_t rsi_set_config (uint32_t code, uint16_t value)

This function sets the configuration for the Network Processor based on configuration code.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]code

- Configuration code. The possible values are as below:

  • XO_CTUNE_FROM_HOST: used to configure NWP's XO Ctune value.

  • SET_XTAL_GOOD_TIME_FROM_HOST: used to configure XTAL(crystal) good time.

  • SET_PMU_GOOD_TIME_FROM_HOST: used to configure PMU good time.

uint16_t[in]value

- Value to be configured

Code

Value Range

XO_CTUNE_FROM_HOST

0 - 255

SET_XTAL_GOOD_TIME_FROM_HOST

2000µs - 10000µs

SET_PMU_GOOD_TIME_FROM_HOST

1100µs - 2000µs

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note

  • Precondition - rsi_wireless_init() should to called before this API.

  • Precondition - To set XTAL and PMU good time from host, call this API before setting the opermode in rsi_wireless_init().


rsi_set_region#

int32_t rsi_set_region (void )

set/change the region on user based configuration

Parameters
TypeDirectionArgument NameDescription
void[in]

Returns

  • 0 - Success
    Non-Zero Value - Failure


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.

Parameters
TypeDirectionArgument NameDescription
uint8_t[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.

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


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.

Parameters
TypeDirectionArgument NameDescription
void[in]

Returns

  • 0 - Success

  • Non-Zero Value - Failure


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.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[in]firmware_image

- This is a pointer to firmware image buffer

uint32_t[in]fw_image_size

- This is the size of firmware image

uint8_t[in]flags

- 1 - RSI_FW_START_OF_FILE, set for the first chunk
2 - RSI_FW_END_OF_FILE, set for the last chunk
0 - for all other chunks

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