AIROC™ BTSDK v4.9 - Documentation | ||||
This section describes the API's necessary to configure AIROC transport, send and receive data over the transport. More...
Typedefs | |
typedef struct _wiced_trans_buffer_pool_t | wiced_transport_buffer_pool_t |
wiced transport buffer pool | |
typedef void(* | wiced_transport_status_handler_t )(wiced_transport_type_t type) |
Wiced transport status handler. | |
typedef uint32_t(* | wiced_tranport_data_handler_t )(uint8_t *p_data, uint32_t data_len) |
Wiced transport data handler Handles the data received over transport. More... | |
typedef void(* | wiced_transport_tx_complete_t )(wiced_transport_buffer_pool_t *p_pool) |
Wiced transport tx complete indication. More... | |
struct { | |
wiced_transport_uart_mode_t mode | |
UART mode, HCI or Raw. | |
uint32_t baud_rate | |
UART baud rate. | |
} | wiced_uart_transport_cfg_t |
UART transport config. | |
struct { | |
uint8_t dev_role | |
SPI HW to play either master (1) or slave (2) | |
uint32_t spi_gpio_cfg | |
Pins to use for the data and clk lines. More... | |
uint16_t spi_pin_pull_config | |
Pin pull-up or pull-down. | |
uint32_t clock_speed | |
Clock speed (non-zero for master, zero for slave). More... | |
SPI_ENDIAN endian | |
Direction of bit data flow (MSB or LSB first) | |
SPI_SS_POLARITY polarity | |
Active high or active low for chip select line. | |
SPI_MODE mode | |
SPI mode (0-3). More... | |
uint8_t cs_pin | |
GPIO pin of chip select line. | |
uint8_t slave_ready_pin | |
GPIO pin to be used as slave ready. | |
} | wiced_spi_transport_cfg_t |
SPI transport config. | |
union { | |
wiced_spi_transport_cfg_t spi_cfg | |
wiced_uart_transport_cfg_t uart_cfg | |
} | wiced_transport_interface_cfg_t |
Wiced transport interface config. | |
struct { | |
uint32_t buffer_size | |
uint32_t buffer_count | |
} | wiced_transport_rx_buff_pool_cfg_t |
Wiced receive buffer pool configuration. More... | |
struct { | |
wiced_transport_type_t type | |
Wiced transport type. More... | |
wiced_transport_interface_cfg_t cfg | |
Wiced transport interface config. More... | |
wiced_transport_rx_buff_pool_cfg_t rx_buff_pool_cfg | |
Wiced rx buffer pool config. More... | |
wiced_transport_status_handler_t p_status_handler | |
Wiced transport status handler. More... | |
wiced_tranport_data_handler_t p_data_handler | |
Wiced transport receive data handler. More... | |
wiced_transport_tx_complete_t p_tx_complete_cback | |
Wiced transport tx complete callback. More... | |
} | wiced_transport_cfg_t |
Wiced transport config. | |
Enumerations | |
enum | wiced_transport_type_t { WICED_TRANSPORT_UART, WICED_TRANSPORT_SPI, WICED_TRANSPORT_UNDEFINED } |
Wiced transport types. More... | |
enum | wiced_transport_uart_mode_t { WICED_TRANSPORT_UART_HCI_MODE, WICED_TRANSPORT_UART_RAW_MODE } |
Wiced uart transport mode. More... | |
Functions | |
wiced_result_t | wiced_trans_spi_sleep_config (wiced_bt_gpio_numbers_t bt_dev_wake_gpio, wiced_wake_gpio_mode_t bt_dev_wake_mode) |
Application can invoke this function to confgure and enable low power mode of operation. More... | |
wiced_result_t | wiced_transport_init (const wiced_transport_cfg_t *p_cfg) |
Function wiced_transport_init. More... | |
wiced_transport_buffer_pool_t * | wiced_transport_create_buffer_pool (uint32_t buffer_size, uint32_t buffer_count) |
Function wiced_transport_create_buffer_pool. More... | |
void * | wiced_transport_allocate_buffer (wiced_transport_buffer_pool_t *p_pool) |
Function wiced_transport_allocate_buffer. More... | |
uint32_t | wiced_transport_get_buffer_size (wiced_transport_buffer_pool_t *p_pool) |
Function wiced_transport_get_buffer_size. More... | |
uint32_t | wiced_transport_get_buffer_count (wiced_transport_buffer_pool_t *p_pool) |
Function wiced_transport_get_buffer_count. More... | |
wiced_result_t | wiced_transport_send_buffer (uint16_t code, uint8_t *p_buf, uint16_t length) |
Function wiced_transport_send_buffer. More... | |
void | wiced_transport_free_buffer (void *p_buf) |
Function wiced_transport_free_buffer. More... | |
wiced_result_t | wiced_transport_send_data (uint16_t code, uint8_t *p_data, uint16_t length) |
Function wiced_transport_send_data. More... | |
wiced_result_t | wiced_transport_send_hci_trace (wiced_transport_buffer_pool_t *hci_trans_pool, wiced_bt_hci_trace_type_t type, uint16_t length, uint8_t *p_data) |
Function wiced_transport_send_hci_trace. More... | |
This section describes the API's necessary to configure AIROC transport, send and receive data over the transport.
This section describes the API's to configure and use the SPI as AIROC transport.
typedef uint32_t(* wiced_tranport_data_handler_t)(uint8_t *p_data, uint32_t data_len) |
Wiced transport data handler Handles the data received over transport.
This function should return value depending on the configured transport/transport mode. Freeing of the buffer is also required depending on the mode.Refer the notes below.
Note**: If the application is operating in WICED_TRANSPORT_UART_RAW_MODE, application should return the number of bytes read ie, the data that application could process successfully.RAW UART Transport driver uses a circular buffer to receive the data and returning the data length is required to update the buffer pointers. Application shall not invoke the release buffer API when in raw mode.
If the application is operating in WICED_TRANSPORT_UART_HCI_MODE or using WICED_TRANSPORT_SPI transport, application has to free the buffer in which data is received . Use the API wiced_transport_free_buffer to release the rx buffer. Also return WICED_SUCCESS if data is processed successfully or return error codes otherwise
typedef { ... } wiced_transport_rx_buff_pool_cfg_t |
Wiced receive buffer pool configuration.
Application shall use this to receive packet of size > 264 bytes .Note: If the application is operating in WICED_TRANS_UART_RAW_MODE, application should specify the rx buffer size. RAW UART Transport driver uses a circular buffer to receive the data
typedef void(* wiced_transport_tx_complete_t)(wiced_transport_buffer_pool_t *p_pool) |
Wiced transport tx complete indication.
Indicates the application that a packet is sent using a buffer in the indicated pool. Application shall register this callback if it wants indication on packet sent using buffer allocated from the transport pool created by the application
[in] | p_pool | : Pool pointer, buffer is used from this pool for sending the packet |
wiced_result_t wiced_trans_spi_sleep_config | ( | wiced_bt_gpio_numbers_t | bt_dev_wake_gpio, |
wiced_wake_gpio_mode_t | bt_dev_wake_mode | ||
) |
Application can invoke this function to confgure and enable low power mode of operation.
Application resumes on waking from sleep. Application can also configure the BT_DEV_WAKE GPIO and the active mode of the BT_DEV_WAKE GPIO using this function. BT_DEV_WAKE GPIO - Host can wake the device from sleep by setting the Bluetooth device wake pin active, if the device is in sleep mode
[in] | bt_dev_wake_gpio | : Bluetooth Device Wake pin, Use arm gpio as the BT_DEV_WAKE pin |
[in] | bt_dev_wake_mode | : Active Mode of the BT_DEV_WAKE pin |
void* wiced_transport_allocate_buffer | ( | wiced_transport_buffer_pool_t * | p_pool | ) |
Function wiced_transport_allocate_buffer.
Allocates a buffer from the pool
[in] | p_pool | : Pointer to buffer pool returned from wiced_transport_create_buffer_pool. |
wiced_transport_buffer_pool_t* wiced_transport_create_buffer_pool | ( | uint32_t | buffer_size, |
uint32_t | buffer_count | ||
) |
Function wiced_transport_create_buffer_pool.
Creates a buffer pool for transport usage. Application shall create the buffer pool if it has to send packet of size > 264 bytes. Application shall specify the payload length as the buffer size. Transport will take care of creating a pool of desired size considering the transport header requirements and the application specified payload size. Application cannot release/free the pool memory once created.
[in] | buffer_size | : Size of each buffer in pool. Application shall specify the payload length as the buffer size. |
[in] | buffer_count | : Number of buffers in the pool |
void wiced_transport_free_buffer | ( | void * | p_buf | ) |
Function wiced_transport_free_buffer.
Frees the transport buffer.
Note: When receiving a packet in WICED_TRANSPORT_UART_HCI_MODE or in WICED_TRANSPORT_SPI mode, application should take care of freeing the rx buffers. When sending a packet, transport will take care of freeing the buffer after the packet is sent.
[in] | p_buf | :Pointer to the buffer to be freed |
uint32_t wiced_transport_get_buffer_count | ( | wiced_transport_buffer_pool_t * | p_pool | ) |
Function wiced_transport_get_buffer_count.
To get the number of buffers available in the pool
[in] | p_pool | : Pointer to buffer pool created using wiced_transport_create_buffer_pool |
uint32_t wiced_transport_get_buffer_size | ( | wiced_transport_buffer_pool_t * | p_pool | ) |
Function wiced_transport_get_buffer_size.
Returns the size of buffer of in the pool
[in] | p_pool | : Pointer to buffer pool returned from wiced_transport_create_buffer_pool |
wiced_result_t wiced_transport_init | ( | const wiced_transport_cfg_t * | p_cfg | ) |
Function wiced_transport_init.
Initializes and configures the transport and also registers the handlers to be invoked on transport detection and on receiving the data
[in] | p_cfg | :wiced transport config |
wiced_result_t wiced_transport_send_buffer | ( | uint16_t | code, |
uint8_t * | p_buf, | ||
uint16_t | length | ||
) |
Function wiced_transport_send_buffer.
Send the packet to the host over the transport using the buffer allocated by the application. This function takes care of preparing the header and sending the data. In case of WICED_TRANSPORT_UART_RAW_MODE, the header is not included in the message and is ignored by the API.The buffer will be freed by the transport after sending the packet.
Note: Application has to allocate buffer from transport pool using wiced_transport_allocate_buffer and copy the payload to this buffer and send the payload pointer. This allows the application to use custom size buffers and avoid overrun of generic buffers, which is shared across firmware code.
[in] | code | :Group code and command code. Ignored in case of WICED_TRANSPORT_UART_RAW_MODE |
[in] | p_buf | :Pointer to the payload |
[in] | length | :Payload length |
wiced_result_t wiced_transport_send_data | ( | uint16_t | code, |
uint8_t * | p_data, | ||
uint16_t | length | ||
) |
Function wiced_transport_send_data.
Send the packet to the host over the transport. This function allocates a buffer internally and prepare the header, copy the payload and then sends the packet over the transport. In case of WICED_TRANSPORT_UART_RAW_MODE, the header is not included in the message and is ignored by the API. Maximum size of the buffer that can be allocated is 264 bytes
Transport internally uses a buffer from the pool which is available for all general purposes Following are the configuration of the internal pool 1: buffer size - 32 bytes, buffer count - 48 2: buffer size - 64 bytes, buffer count - 16 3: buffer size - 264 bytes, buffer count - 10
[in] | code | :Group code and command code.Ignored in case of WICED_TRANSPORT_UART_RAW_MODE |
[in] | p_data | :Pointer to the payload |
[in] | length | :Payload length |
wiced_result_t wiced_transport_send_hci_trace | ( | wiced_transport_buffer_pool_t * | hci_trans_pool, |
wiced_bt_hci_trace_type_t | type, | ||
uint16_t | length, | ||
uint8_t * | p_data | ||
) |
Function wiced_transport_send_hci_trace.
Send the hci trace data over the transport.
[in] | hci_trans_pool | :Pass the pointer to the pool created by the application if application has created a dedicated transport pool for communicating to host. Pass NULL if the application wants the stack to take care of allocating the buffer for sending the data to host |
[in] | type | :HCI trace type |
[in] | p_data | :Pointer to the data payload |
[in] | length | :Data payload length |