Bluetooth Stack Platform Interface

group wiced_bt_platform_group

Interface between Stack and platform.

Typedefs

typedef void (*wiced_bt_internal_post_stack_init_cb)(void)

Function prototype for the post Stack Init Callback.

typedef wiced_bool_t (*wiced_bt_internal_stack_evt_handler_cb)(uint8_t *p_event)

Function prototype for the HCI event monitor function that the application may suppply.

The application MUST return TRUE if the it handled the event and does not want the stack to process the event. If the application returns FALSE, the stack will process the event.

Functions

wiced_result_t wiced_bt_stack_platform_initialize(wiced_bt_stack_platform_t *platform_interfaces)

Initialize the platform interfaces, by providing porting functions specific to the underlying platform.

Return

WICED_BT_SUCCESS : on success; WICED_BT_ERROR : if an error occurred

wiced_result_t wiced_bt_stack_platform_deinit(void)

DeInitialize the platform interfaces and free the memory allocated by wiced_bt_stack_platform_initialize API.

note

: After calling this API, DON'T call any BT API without calling wiced_bt_stack_platform_initialize again.

Return

WICED_BT_SUCCESS : on success; WICED_BT_ERROR : if an error occurred

void wiced_bt_process_acl_data(uint8_t *pData, uint32_t length)

Called by the porting layer to process the incoming ACL data received from the remote bluetooth device.

Return

void

Parameters
  • [in] pData: : Pointer to the ACL data to be processed

  • [in] length: : Length of the ACL data buffer

void wiced_bt_process_hci_events(uint8_t *pData, uint32_t length)

Called by the porting layer to process the incoming HCI events from the local bluetooth controller.

Return

void

Parameters
  • [in] pData: : Pointer to the HCI Events to be processed

  • [in] length: : Length of the event buffer

void wiced_bt_process_sco_data(uint8_t *pData, uint32_t length)

Called by the porting layer to process the incoming SCO data received from the remote bluetooth device.

Return

void

Parameters
  • [in] pData: : Pointer to the SCO data to be processed

  • [in] length: : Length of the SCO data buffer

void wiced_bt_process_isoc_data(uint8_t *pData, uint32_t length)

Called by the porting layer to process the incoming ISOC data received from the remote bluetooth device.

Return

void

Parameters
  • [in] pData: : Pointer to the ISOC data to be processed

  • [in] length: : Length of the ISOC data buffer

void wiced_bt_process_timer(void)

Called by the porting layer on expiry of the timer to process pending timers.

Return

void

void wiced_bt_stack_indicate_lower_tx_complete(void)

Called by the lower layer transport driver to restart sending ACL data to the controller Note: Porting layer API.

This API is expected to be invoked by the lower layer transport driver, to restart transfers from the stack to the controller. The lower tx layer is expected to have space for atleast one complete ACL buffer Typically used in cases where the lower Tx has lesser number of buffers than allowed by controller

void wiced_bt_continue_reset(void)

Called by the porting layer to complete/continue the reset process Typically called after downloading firmware patches to the controller.

Return

void

uint32_t wiced_bt_set_stack_config(const wiced_bt_cfg_settings_t *p_bt_new_cfg_settings)

Set the stack config.

Invoked by the porting layer

Return

0 if there is any error in the configuration otherwise the dynamic memory size requirements of the stack for the configuration.

Parameters
  • [in] p_bt_new_cfg_settings: : Stack configuration settings

void wiced_bt_stack_init_internal(wiced_bt_management_cback_t mgmt_cback, wiced_bt_internal_post_stack_init_cb post_stack_cb, wiced_bt_internal_stack_evt_handler_cb evt_handler_cb)

Internal stack init.

Return

Dynamic memory size requirements of the stack for the configuration

Parameters
  • [in] mgmt_cback: : Application BT Management callback

  • [in] post_stack_cb: : Internal post stack init callback

  • [in] evt_handler_cb: : Internal stack event handler

void wiced_bt_stack_shutdown(void)

This function blocks until all de-initialisation procedures are complete.

It is recommended that the application disconnect any outstanding connections prior to invoking this function.

Return

None

struct wiced_bt_stack_platform_t
#include <wiced_bt_stack_platform.h>

Wiced BT Stack Platform.

Public Members

pf_wiced_exception pf_exception

Exception callback.

void *(*pf_os_malloc)(uint32_t size)

Platform function to allocate memory.

Called by stack code to allocate memory from the OS/Platform. Implementing function is expected to return memory allocated from the OS/Platform

Return

: Pointer to allocated memory

Parameters
  • [in] size: : Size of memory to be allocated

void (*pf_os_free)(void *p_mem)

Platform memory free.

Called by stack code to free memory back to the OS/Platform. Implementing function is expected to free the memory allocated using pf_os_malloc (refer pf_os_malloc ) call from the OS/Platform

Return

: None

Parameters
  • [in] p_mem: : Ptr to memory to be freed

uint64_t (*pf_get_tick_count_64)(void)

Platform function to get tick count.

Called by stack timer code to get the free running 64 bit tick count

Return

: 64 bit current tick count

Parameters
  • [in] None:

void (*pf_set_next_timeout)(uint64_t abs_tick_count)

Platform function to set the next timeout.

Called by stack timer code set the next timeout

Return

: void

Parameters
  • [in] abs_tick_count: : 64 bit tick count instant at which the timeout has to occur

wiced_bt_lock_t stack_lock

Stack lock.

uint8_t *(*pf_get_acl_to_lower_buffer)(wiced_bt_transport_t transport, uint32_t size)

Platform function to get ACL buffer to send to lower.

Called by stack to get a buffer to fill in the data to be sent to ‘transport’ (BLE or BR/EDR) of ‘size’

Return

: Pointer to buffer which will be filled with data

Parameters
  • [in] transport: : Transport on which the buffer is to be sent

  • [in] size: : Size of the buffer

wiced_result_t (*pf_write_acl_to_lower)(wiced_bt_transport_t transport, uint8_t *p_data, uint16_t len)

Platform function to write ACL buffer to lower.

Called by stack to send the buffer allocated using pf_get_acl_to_lower_buffer after filling it with the data to send.

Return

: wiced_result_t

Parameters
  • [in] transport: : Transport on which the buffer is to be sent

  • [in] p_data: : Pointer received using pf_get_acl_to_lower_buffer

  • [in] len: : Length of data at p_data

wiced_result_t (*pf_write_iso_to_lower)(wiced_bt_transport_t transport, uint8_t *p_data, uint16_t len)

Platform function to write ISO buffer to lower.

Called by stack to send the buffer allocated using pf_get_acl_to_lower_buffer after filling it with the data to send.

Return

: wiced_result_t

Parameters
  • [in] transport: : Transport on which the buffer is to be sent

  • [in] p_data: : Pointer received using pf_get_acl_to_lower_buffer

  • [in] len: : Length of data at p_data

wiced_result_t (*pf_write_cmd_to_lower)(uint8_t *p_cmd, uint16_t cmd_len)

Platform function to write CMD buffer to lower.

Called by stack to send HCI CMD buffer to lower

Return

: wiced_result_t

Parameters
  • [in] p_cmd: : Pointer to HCI CMD data

  • [in] cmd_len: : Length of data at p_cmd

uint8_t *(*pf_get_sco_to_lower_buffer)(uint32_t size)

Platform function to get SCO buffer to send to lower.

Called by stack to get a SCO buffer to fill in the data to be sent to HCI of ‘size’

Return

: Pointer to buffer which will be filled with data

Parameters
  • [in] size: : Size of the buffer

wiced_result_t (*pf_write_sco_to_lower)(uint8_t *p_sco_data, uint8_t len)

Platform function to write SCO buffer to lower.

Called to send SCO CMD buffer to lower

Return

: wiced_result_t

Parameters
  • [in] p_sco_data: : Pointer to SCO data

  • [in] len: : Length of data at p_data

void (*pf_hci_trace_cback_t)(wiced_bt_hci_trace_type_t type, uint16_t len, uint8_t *p_data)

Callback function to trace HCI messages.

Called by stack to allow application to trace the HCI messages. Application/Porting code is expected to treat received data as read only, and make a copy of the data to reference it outside of the callback

Return

: void

Parameters
  • [in] type: : HCI event data type

  • [in] len: : Length of data at p_data

  • [in] p_data: : Pointer to data

void (*pf_debug_trace)(char *p_trace_buf, int trace_buf_len, wiced_bt_trace_type_t trace_type)

Callback function to dump out trace messages This interface function can be NULL if no debug tracing is supported.

Called by stack to allow application to write debug trace messages

Return

: void

Parameters
  • [in] p_trace_buf: : Pointer to the trace buffer

  • [in] trace_buf_len: : Length of the trace buffer

  • [in] trace_type: : Type of trace message

int trace_buffer_len

trace_buffer_len : Trace buffer len

char *trace_buffer

trace_buffer : Pointer to the trace buffer Applications can set this to NULL to disable traces

void (*pf_patch_download)(void)

Used for additional controller initialization by the porting layer to be performed after the HCI reset.

Can be set to NULL if no additional initialization required