Bluetooth_rtos_adaptation

Adaptation for running Bluetooth in RTOS.

Functions

void sli_bt_cmd_handler_rtos_delegate (uint32_t header, sl_bgapi_handler handler, const void *payload)
 Hooks for API, called from tasks using Bluetooth API.
 
sl_status_t sl_bt_rtos_has_event_waiting ()
 Check if there any Bluetooth stack event waiting This API will not clear the event waiting flag.
 
sl_status_t sl_bt_rtos_event_wait (bool blocking)
 Wait Bluetooth stack to generate an event This API will clear the event waiting flag.
 
sl_status_t sl_bt_rtos_set_event_handled ()
 Message Bluetooth stack that event is handled This will set event handled flag.
 
sl_status_t sl_bt_bluetooth_pend ()
 Mutex functions for using Bluetooth from multiple tasks.
 
sl_status_t sl_bt_bluetooth_post ()
 Mutex functions for using Bluetooth from multiple tasks.
 
sl_status_t sl_bt_rtos_init ()
 Initialize Bluetooth for running in RTOS.
 
const sl_bt_msg_tsl_bt_rtos_get_event ()
 Gets the pointer to current Bluetooth event.
 

Detailed Description

Adaptation for running Bluetooth in RTOS.

License

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

The licensor of this software is Silicon Laboratories Inc. Your use of this software is governed by the terms of Silicon Labs Master Software License Agreement (MSLA) available at www.silabs.com/about-us/legal/master-software-license-agreement. This software is distributed to you in Source Code format and is governed by the sections of the MSLA applicable to Source Code.

Bluetooth RTOS adaptation

The Bluetooth RTOS adaptation component implements the relevant interfaces for running the Bluetooth stack in an RTOS. When initialized in sl_bt_rtos_init(), the component creates the required RTOS tasks for the Bluetooth stack itself, and an event task that is used to deliver sl_bt_process_event() and sl_bt_on_event() callbacks to the application.

To guarantee thread safety and avoid the risk of deadlocks, the Bluetooth RTOS adaptation implementation makes the following promises with regard to the locking mechanism provided in the API:

  1. The stack will never directly call sl_bt_process_event() or sl_bt_on_event() from within the same callstack that is calling a command function. The callbacks always come from a processing loop in an event task created for this purpose.
  2. The stack will never internally obtain the sl_bt_bluetooth_pend() lock. It is safe for the application to obtain the lock also from within the sl_bt_on_event() callback.

Function Documentation

◆ sl_bt_rtos_has_event_waiting()

sl_status_t sl_bt_rtos_has_event_waiting ( )

Check if there any Bluetooth stack event waiting This API will not clear the event waiting flag.

Note
This API is meant to be used in applications define own Bluetooth event handler, it should be only used if SL_BT_DISABLE_EVENT_TASK is defined.
Returns
SL_STATUS_OK if event is waiting, otherwise SL_STATUS_FAIL or error

◆ sl_bt_rtos_event_wait()

sl_status_t sl_bt_rtos_event_wait ( bool  blocking)

Wait Bluetooth stack to generate an event This API will clear the event waiting flag.

Note
This API is meant to be used in applications define own Bluetooth event handler, it should be only used if SL_BT_DISABLE_EVENT_TASK is defined.
Parameters
[in]blockingspecifies if the function would block until event is generated
Returns
SL_STATUS_OK if the event is generated or some error

◆ sl_bt_rtos_set_event_handled()

sl_status_t sl_bt_rtos_set_event_handled ( )

Message Bluetooth stack that event is handled This will set event handled flag.

Note
This API is meant to be used in applications define own Bluetooth event handler, it should be only used if SL_BT_DISABLE_EVENT_TASK is defined.
Returns
SL_STATUS_OK if successful or some error

◆ sl_bt_bluetooth_pend()

sl_status_t sl_bt_bluetooth_pend ( )

Mutex functions for using Bluetooth from multiple tasks.

Returns
SL_STATUS_OK if mutex has been obtained

◆ sl_bt_bluetooth_post()

sl_status_t sl_bt_bluetooth_post ( )

Mutex functions for using Bluetooth from multiple tasks.

Returns
SL_STATUS_OK the mutex has been released

◆ sl_bt_rtos_init()

sl_status_t sl_bt_rtos_init ( )

Initialize Bluetooth for running in RTOS.

Returns
SL_STATUS_OK if succeeds, otherwise error

◆ sl_bt_rtos_get_event()

const sl_bt_msg_t* sl_bt_rtos_get_event ( )

Gets the pointer to current Bluetooth event.

Caller needs to make sure this is used for Bluetooth event processing only when sl_bt_rtos_event_wait indicates an event is waiting to be processed. Otherwise the event may contain outdated data.

Returns
pointer to the Bluetooth event