mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-22 16:20:54 +00:00
hci_transport/btstack_uart_block: create btstack_uart_block_embedded on top of hal_uart_dma. Pass in uart driver to H4/H5 instances
This commit is contained in:
parent
8da2e96db3
commit
084ad01c1a
@ -1970,7 +1970,7 @@ int main (int argc, char * const * argv){
|
||||
hci_transport_config_uart.baudrate_main = 0;
|
||||
hci_transport_config_uart.flowcontrol = 1;
|
||||
hci_transport_config_uart.device_name = UART_DEVICE;
|
||||
transport = hci_transport_h4_instance();
|
||||
transport = hci_transport_h4_instance(btstack_uart_block_posix_instance());
|
||||
|
||||
#ifdef HAVE_PLATFORM_IPHONE_OS
|
||||
// use default (max) UART baudrate over netgraph interface
|
||||
|
153
platform/embedded/btstack_uart_block_embedded.c
Normal file
153
platform/embedded/btstack_uart_block_embedded.c
Normal file
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (C) 2016 BlueKitchen GmbH
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the names of
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 4. Any redistribution, use, or modification is done solely for
|
||||
* personal benefit and not for any commercial purpose or for
|
||||
* monetary gain.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
||||
* RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Please inquire about commercial licensing options at
|
||||
* contact@bluekitchen-gmbh.com
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* btstack_uart_block_embedded.c
|
||||
*
|
||||
* Common code to access UART via asynchronous block read/write commands on top of hal_uart_dma.h
|
||||
*
|
||||
*/
|
||||
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_uart_block.h"
|
||||
#include "btstack_run_loop_embedded.h"
|
||||
#include "hal_uart_dma.h"
|
||||
|
||||
// uart config
|
||||
static const btstack_uart_config_t * uart_config;
|
||||
|
||||
// data source for integration with BTstack Runloop
|
||||
static btstack_data_source_t transport_data_source;
|
||||
|
||||
static int send_complete;
|
||||
static int receive_complete;
|
||||
|
||||
// callbacks
|
||||
static void (*block_sent)(void);
|
||||
static void (*block_received)(void);
|
||||
|
||||
|
||||
static void btstack_uart_block_received(void){
|
||||
receive_complete = 1;
|
||||
btstack_run_loop_embedded_trigger();
|
||||
}
|
||||
|
||||
static void btstack_uart_block_sent(void){
|
||||
send_complete = 1;
|
||||
btstack_run_loop_embedded_trigger();
|
||||
}
|
||||
|
||||
static int btstack_uart_embedded_init(const btstack_uart_config_t * config){
|
||||
uart_config = config;
|
||||
hal_uart_dma_set_block_received(&btstack_uart_block_received);
|
||||
hal_uart_dma_set_block_sent(&btstack_uart_block_sent);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void btstack_uart_embedded_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type) {
|
||||
switch (callback_type){
|
||||
case DATA_SOURCE_CALLBACK_POLL:
|
||||
if (send_complete){
|
||||
send_complete = 0;
|
||||
block_sent();
|
||||
}
|
||||
if (block_received){
|
||||
block_received = 0;
|
||||
block_received();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int btstack_uart_embedded_open(void){
|
||||
hal_uart_dma_init();
|
||||
hal_uart_dma_set_baud(uart_config->baudrate);
|
||||
|
||||
// set up polling data_source
|
||||
btstack_run_loop_set_data_source_handler(&transport_data_source, &btstack_uart_embedded_process);
|
||||
btstack_run_loop_enable_data_source_callbacks(&transport_data_source, DATA_SOURCE_CALLBACK_POLL);
|
||||
btstack_run_loop_add_data_source(&transport_data_source);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int btstack_uart_embedded_close(void){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void btstack_uart_embedded_set_block_received( void (*block_handler)(void)){
|
||||
block_received = block_handler;
|
||||
}
|
||||
|
||||
static void btstack_uart_embedded_set_block_sent( void (*block_handler)(void)){
|
||||
block_sent = block_handler;
|
||||
}
|
||||
|
||||
static int btstack_uart_embedded_set_parity(int parity){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void btstack_uart_embedded_send_block(const uint8_t *data, uint16_t size){
|
||||
hal_uart_dma_send_block(data, size);
|
||||
}
|
||||
|
||||
static void btstack_uart_embedded_receive_block(uint8_t *buffer, uint16_t len){
|
||||
hal_uart_dma_receive_block(buffer, len);
|
||||
}
|
||||
|
||||
// static void btstack_uart_embedded_set_sleep(uint8_t sleep){
|
||||
// }
|
||||
|
||||
// static void btstack_uart_embedded_set_csr_irq_handler( void (*csr_irq_handler)(void)){
|
||||
// }
|
||||
|
||||
static const btstack_uart_block_t btstack_uart_embedded = {
|
||||
/* int (*init)(hci_transport_config_uart_t * config); */ &btstack_uart_embedded_init,
|
||||
/* int (*open)(void); */ &btstack_uart_embedded_open,
|
||||
/* int (*close)(void); */ &btstack_uart_embedded_close,
|
||||
/* void (*set_block_received)(void (*handler)(void)); */ &btstack_uart_embedded_set_block_received,
|
||||
/* void (*set_block_sent)(void (*handler)(void)); */ &btstack_uart_embedded_set_block_sent,
|
||||
/* int (*set_baudrate)(uint32_t baudrate); */ &hal_uart_dma_set_baud,
|
||||
/* int (*set_parity)(int parity); */ &btstack_uart_embedded_set_parity,
|
||||
/* void (*receive_block)(uint8_t *buffer, uint16_t len); */ &btstack_uart_embedded_receive_block,
|
||||
/* void (*send_block)(const uint8_t *buffer, uint16_t length); */ &btstack_uart_embedded_send_block
|
||||
};
|
||||
|
||||
const btstack_uart_block_t * btstack_uart_block_embedded_instance(void){
|
||||
return &btstack_uart_embedded;
|
||||
}
|
@ -168,7 +168,7 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||
}
|
||||
|
||||
// get h4 singleton
|
||||
const hci_transport_t * hci_transport_h4_instance(void){
|
||||
const hci_transport_t * hci_transport_h4_instance(const btstack_uart_block_t * uart_driver){
|
||||
return &hci_transport_h4_ehcill_dma.transport;
|
||||
}
|
||||
|
||||
|
@ -297,6 +297,6 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||
}
|
||||
|
||||
// get h4 singleton
|
||||
const hci_transport_t * hci_transport_h4_instance(void){
|
||||
const hci_transport_t * hci_transport_h4_instance(const btstack_uart_block_t * uart_driver){
|
||||
return &hci_transport_h4_dma.transport;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
*/
|
||||
|
||||
#include "btstack_uart_block.h"
|
||||
#include "btstack_run_loop.h"
|
||||
#include "btstack_debug.h"
|
||||
|
||||
#include <termios.h> /* POSIX terminal control definitions */
|
||||
@ -50,10 +51,10 @@
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
|
||||
// uart config
|
||||
static const hci_transport_config_uart_t * uart_config;
|
||||
static const btstack_uart_config_t * uart_config;
|
||||
|
||||
// data source for integration with BTstack Runloop
|
||||
static btstack_data_source_t transport_data_source;
|
||||
static btstack_data_source_t transport_data_source;
|
||||
|
||||
// block write
|
||||
static int write_bytes_len;
|
||||
@ -68,7 +69,7 @@ static void (*block_sent)(void);
|
||||
static void (*block_received)(void);
|
||||
|
||||
|
||||
static int btstack_uart_posix_init(const hci_transport_config_uart_t * config){
|
||||
static int btstack_uart_posix_init(const btstack_uart_config_t * config){
|
||||
uart_config = config;
|
||||
return 0;
|
||||
}
|
||||
@ -215,7 +216,7 @@ static int btstack_uart_posix_open(void){
|
||||
|
||||
const char * device_name = uart_config->device_name;
|
||||
const int flowcontrol = uart_config->flowcontrol;
|
||||
const uint32_t baudrate = uart_config->baudrate_init;
|
||||
const uint32_t baudrate = uart_config->baudrate;
|
||||
|
||||
struct termios toptions;
|
||||
int flags = O_RDWR | O_NOCTTY | O_NONBLOCK;
|
||||
|
@ -76,7 +76,9 @@ typedef enum {
|
||||
H4_W4_PAYLOAD,
|
||||
} H4_STATE;
|
||||
|
||||
const btstack_uart_block_t * btstack_uart;
|
||||
// UART Driver + Config
|
||||
static const btstack_uart_block_t * btstack_uart;
|
||||
static btstack_uart_config_t uart_config;
|
||||
|
||||
// write mutex
|
||||
static int uart_write_active;
|
||||
@ -84,9 +86,6 @@ static int uart_write_active;
|
||||
// single instance
|
||||
static hci_transport_t * hci_transport_h4 = NULL;
|
||||
|
||||
|
||||
static hci_transport_config_uart_t * hci_transport_config_uart = NULL;
|
||||
|
||||
static void (*packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t size) = dummy_handler;
|
||||
|
||||
// packet reader state machine
|
||||
@ -191,13 +190,14 @@ static void hci_transport_h4_init(const void * transport_config){
|
||||
return;
|
||||
}
|
||||
|
||||
hci_transport_config_uart = (hci_transport_config_uart_t*) transport_config;
|
||||
// extract UART config from transport config
|
||||
hci_transport_config_uart_t * hci_transport_config_uart = (hci_transport_config_uart_t*) transport_config;
|
||||
uart_config.baudrate = hci_transport_config_uart->baudrate_init;
|
||||
uart_config.flowcontrol = hci_transport_config_uart->flowcontrol;
|
||||
uart_config.device_name = hci_transport_config_uart->device_name;
|
||||
|
||||
// TODO: move btstack_uart_block_t into hci_transport_config_uart
|
||||
|
||||
// use fixed uart block posix implementation for now
|
||||
btstack_uart = btstack_uart_block_posix_instance();
|
||||
btstack_uart->init(hci_transport_config_uart);
|
||||
// setup UART driver
|
||||
btstack_uart->init(&uart_config);
|
||||
btstack_uart->set_block_received(&hci_transport_h4_block_read);
|
||||
btstack_uart->set_block_sent(&hci_transport_h4_block_sent);
|
||||
}
|
||||
@ -242,7 +242,7 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||
}
|
||||
|
||||
// get h4 singleton
|
||||
const hci_transport_t * hci_transport_h4_instance(void) {
|
||||
const hci_transport_t * hci_transport_h4_instance(const btstack_uart_block_t * uart_driver) {
|
||||
if (hci_transport_h4 == NULL) {
|
||||
hci_transport_h4 = (hci_transport_t*)malloc( sizeof(hci_transport_t));
|
||||
memset(hci_transport_h4, 0, sizeof(hci_transport_t));
|
||||
@ -255,5 +255,6 @@ const hci_transport_t * hci_transport_h4_instance(void) {
|
||||
hci_transport_h4->send_packet = hci_transport_h4_send_packet;
|
||||
hci_transport_h4->set_baudrate = hci_transport_h4_set_baudrate;
|
||||
}
|
||||
btstack_uart = uart_driver;
|
||||
return hci_transport_h4;
|
||||
}
|
||||
|
@ -124,9 +124,6 @@ static uint8_t hci_packet_type;
|
||||
static uint16_t hci_packet_size;
|
||||
static uint8_t * hci_packet;
|
||||
|
||||
// device
|
||||
static hci_transport_config_uart_t * hci_transport_config_uart;
|
||||
|
||||
// hci_transport_t instance
|
||||
static hci_transport_t * hci_transport_h5;
|
||||
|
||||
@ -135,7 +132,9 @@ static void (*packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t si
|
||||
|
||||
static int hci_transport_link_actions;
|
||||
|
||||
const btstack_uart_block_t * btstack_uart;
|
||||
// UART Driver + Config
|
||||
static const btstack_uart_block_t * btstack_uart;
|
||||
static btstack_uart_config_t uart_config;
|
||||
|
||||
static int uart_write_active;
|
||||
|
||||
@ -583,15 +582,14 @@ static void hci_transport_h5_posix_init(const void * transport_config){
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: move btstack_uart_block_t into hci_transport_config_uart
|
||||
|
||||
// use fixed uart block posix implementation for now
|
||||
btstack_uart = btstack_uart_block_posix_instance();
|
||||
|
||||
btstack_uart->init((hci_transport_config_uart_t*) transport_config);
|
||||
|
||||
hci_transport_config_uart = (hci_transport_config_uart_t*) transport_config;
|
||||
// extract UART config from transport config
|
||||
hci_transport_config_uart_t * hci_transport_config_uart = (hci_transport_config_uart_t*) transport_config;
|
||||
uart_config.baudrate = hci_transport_config_uart->baudrate_init;
|
||||
uart_config.flowcontrol = hci_transport_config_uart->flowcontrol;
|
||||
uart_config.device_name = hci_transport_config_uart->device_name;
|
||||
|
||||
// setup UART driver
|
||||
btstack_uart->init(&uart_config);
|
||||
btstack_uart->set_block_received(&hci_transport_h5_block_received);
|
||||
btstack_uart->set_block_sent(&hci_transport_h5_block_sent);
|
||||
}
|
||||
@ -603,7 +601,7 @@ static int hci_transport_h5_posix_open(void){
|
||||
}
|
||||
|
||||
// setup resend timeout
|
||||
hci_transport_link_update_resend_timeout(hci_transport_config_uart->baudrate_init);
|
||||
hci_transport_link_update_resend_timeout(uart_config.baudrate);
|
||||
|
||||
// init slip parser state machine
|
||||
hci_transport_slip_init();
|
||||
@ -677,7 +675,7 @@ static void hci_transport_h5_posix_reset_link(void){
|
||||
}
|
||||
|
||||
// get h5 singleton
|
||||
const hci_transport_t * hci_transport_h5_instance(void) {
|
||||
const hci_transport_t * hci_transport_h5_instance(const btstack_uart_block_t * uart_driver) {
|
||||
if (hci_transport_h5 == NULL) {
|
||||
hci_transport_h5 = (hci_transport_t*) malloc(sizeof(hci_transport_t));
|
||||
memset(hci_transport_h5, 0, sizeof(hci_transport_t));
|
||||
@ -691,5 +689,6 @@ const hci_transport_t * hci_transport_h5_instance(void) {
|
||||
hci_transport_h5->set_baudrate = &hci_transport_h5_posix_set_baudrate;
|
||||
hci_transport_h5->reset_link = &hci_transport_h5_posix_reset_link;
|
||||
}
|
||||
btstack_uart = uart_driver;
|
||||
return (const hci_transport_t *) hci_transport_h5;
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ void BTstackManager::setup(void){
|
||||
btstack_memory_init();
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
const hci_transport_t * transport = hci_transport_h4_instance(btstack_uart_block_embedded_instance());
|
||||
hci_init(transport, NULL);
|
||||
hci_set_chipset(btstack_chipset_em9301_instance());
|
||||
|
||||
|
@ -9,12 +9,12 @@ VERSION=`sed -n -e 's/^.*BTSTACK_VERSION \"\(.*\)\"/\1/p' ${BTSTACK_ROOT}/platfo
|
||||
BTSTACK_PACKAGE=/tmp/btstack
|
||||
ARCHIVE=btstack-arduino-${VERSION}.zip
|
||||
|
||||
SRC_FILES = btstack_memory.c btstack_linked_list.c btstack_memory_pool.c btstack_run_loop.c
|
||||
SRC_FILES = btstack_memory.c btstack_linked_list.c btstack_memory_pool.c btstack_run_loop.c
|
||||
SRC_FILES += hci_dump.c hci.c hci_cmd.c btstack_util.c l2cap.c
|
||||
BLE_FILES = ad_parser.c att_db.c att_server.c att_dispatch.c att_db_util.c le_device_db_memory.c gatt_client.c
|
||||
BLE_FILES += sm.c ancs_client.h ancs_client.c
|
||||
PORT_FILES = btstack_config.h bsp_arduino_em9301.cpp BTstack.cpp BTstack.h
|
||||
EMBEDDED_FILES = btstack_run_loop_embedded.c hci_transport_h4_embedded.c
|
||||
EMBEDDED_FILES = btstack_run_loop_embedded.c hci_transport_h4_embedded.c btstack_uart_block_embedded.c
|
||||
|
||||
PATHS = $(addprefix ${BTSTACK_ROOT}/src/, ${SRC_FILES})
|
||||
PATHS += $(wildcard ${BTSTACK_ROOT}/src/*.h)
|
||||
|
@ -50,12 +50,13 @@ CORE = \
|
||||
btstack_util.c \
|
||||
|
||||
COMMON = \
|
||||
hal_uart_dma.c \
|
||||
btstack_chipset_cc256x.c \
|
||||
hci.c \
|
||||
hci_cmd.c \
|
||||
hal_uart_dma.c \
|
||||
btstack_chipset_cc256x.c \
|
||||
hci.c \
|
||||
hci_cmd.c \
|
||||
hci_transport_h4_ehcill_embedded.c \
|
||||
btstack_link_key_db_memory.c \
|
||||
btstack_uart_block_embedded.c \
|
||||
btstack_link_key_db_memory.c \
|
||||
|
||||
SPP = \
|
||||
l2cap.c \
|
||||
|
@ -107,7 +107,7 @@ int main(void)
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// init HCI
|
||||
hci_init(hci_transport_h4_instance(), &config);
|
||||
hci_init(hci_transport_h4_instance(btstack_uart_block_embedded_instance()), &config);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance());
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
|
@ -43,6 +43,7 @@ BTdaemon_FILES = \
|
||||
daemon.c \
|
||||
hci.c \
|
||||
hci_transport_h4_iphone.c \
|
||||
btstack_uart_block_posix.c \
|
||||
l2cap.c \
|
||||
l2cap_signaling.c \
|
||||
platform_iphone.m \
|
||||
|
@ -384,7 +384,7 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||
}
|
||||
|
||||
// get h4 singleton
|
||||
const hci_transport_t * hci_transport_h4_instance(void) {
|
||||
const hci_transport_t * hci_transport_h4_instance(const btstack_uart_block_t * uart_driver) {
|
||||
if (hci_transport_h4 == NULL) {
|
||||
hci_transport_h4 = (hci_transport_h4_t*)malloc( sizeof(hci_transport_h4_t));
|
||||
memset(hci_transport_h4, 0, sizeof(hci_transport_h4_t));
|
||||
|
@ -54,6 +54,7 @@ COMMON = \
|
||||
btstack_chipset_cc256x.c \
|
||||
hci.c \
|
||||
hci_cmd.c \
|
||||
btstack_uart_block_embedded.c \
|
||||
hci_transport_h4_ehcill_embedded.c \
|
||||
btstack_link_key_db_memory.c \
|
||||
|
||||
|
@ -378,7 +378,7 @@ int main(void){
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
const hci_transport_t * transport = hci_transport_h4_instance(btstack_uart_block_embedded_instance());
|
||||
btstack_link_key_db_t * link_key_db = btstack_link_key_db_memory_instance();
|
||||
hci_init(transport, &config);
|
||||
hci_set_link_key_db(link_key_db);
|
||||
|
@ -107,7 +107,7 @@ static void btstack_setup(void){
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// init HCI
|
||||
hci_init(hci_transport_h4_instance(), &config);
|
||||
hci_init(hci_transport_h4_instance(btstack_uart_block_embedded_instance()), &config);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance());
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
|
@ -56,6 +56,7 @@ COMMON = \
|
||||
btstack_chipset_cc256x.c \
|
||||
hci.c \
|
||||
hci_cmd.c \
|
||||
btstack_uart_block_embedded.c \
|
||||
hci_transport_h4_ehcill_embedded.c \
|
||||
btstack_link_key_db_memory.c \
|
||||
|
||||
|
@ -114,7 +114,7 @@ static void btstack_setup(void){
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// init HCI
|
||||
hci_init(hci_transport_h4_instance(), &config);
|
||||
hci_init(hci_transport_h4_instance(btstack_uart_block_embedded_instance()), &config);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance());
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
|
@ -237,7 +237,7 @@ void BTSTACK_Initialize ( void )
|
||||
|
||||
hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
const hci_transport_t * transport = hci_transport_h4_instance(btstack_uart_block_embedded_instance);
|
||||
hci_init(transport, &config);
|
||||
hci_set_chipset(btstack_chipset_csr_instance());
|
||||
|
||||
|
@ -172,7 +172,8 @@ int main(int argc, const char * argv[]){
|
||||
config.device_name = "/dev/tty.usbserial-A900K0VK";
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
const btstack_uart_block_t * uart_driver = btstack_uart_block_posix_instance();
|
||||
const hci_transport_t * transport = hci_transport_h4_instance(uart_driver);
|
||||
const btstack_link_key_db_t * link_key_db = btstack_link_key_db_fs_instance();
|
||||
hci_init(transport, (void*) &config);
|
||||
hci_set_link_key_db(link_key_db);
|
||||
|
@ -33,6 +33,7 @@ COMMON = \
|
||||
hci.c \
|
||||
hci_cmd.c \
|
||||
hci_dump.c \
|
||||
btstack_uart_block_embedded.c \
|
||||
hci_transport_h4_ehcill_embedded.c \
|
||||
l2cap.c \
|
||||
l2cap_signaling.c \
|
||||
@ -69,6 +70,8 @@ include ${BTSTACK_ROOT}/chipset/cc256x/Makefile.inc
|
||||
|
||||
clean:
|
||||
rm -f *.map *.o *.d *.out *.elf *.bin *.hex
|
||||
|
||||
distclean: clean
|
||||
make -C libopencm3 clean
|
||||
|
||||
# git clone and compile libopencm3
|
||||
|
@ -434,7 +434,7 @@ int main(void)
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// init HCI
|
||||
hci_init(hci_transport_h4_instance(), (void*) &config);
|
||||
hci_init(hci_transport_h4_instance(btstack_uart_block_embedded_instance()), (void*) &config);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance());
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
|
@ -330,7 +330,7 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||
}
|
||||
|
||||
// get h4 singleton
|
||||
const hci_transport_t * hci_transport_h4_instance(void) {
|
||||
const hci_transport_t * hci_transport_h4_instance(const btstack_uart_block_t * uart_driver) {
|
||||
if (hci_transport_h4 == NULL) {
|
||||
hci_transport_h4 = (hci_transport_h4_t*)malloc( sizeof(hci_transport_h4_t));
|
||||
memset(hci_transport_h4, 0, sizeof(hci_transport_h4_t));
|
||||
|
@ -82,7 +82,7 @@ void application_start(void){
|
||||
// hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||
|
||||
// init HCI
|
||||
hci_init(hci_transport_h4_instance(), (void*) &hci_transport_config_uart);
|
||||
hci_init(hci_transport_h4_instance(btstack_uart_block_embedded_instance()), (void*) &hci_transport_config_uart);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance());
|
||||
hci_set_chipset(btstack_chipset_bcm_instance());
|
||||
|
||||
|
@ -37,8 +37,9 @@ $(NAME)_SOURCES += \
|
||||
|
||||
# WICED port incl. support for Broadcom chipset
|
||||
$(NAME)_SOURCES += \
|
||||
main.c \
|
||||
btstack_run_loop_wiced.c \
|
||||
hci_transport_h4_wiced.c \
|
||||
main.c \
|
||||
btstack_run_loop_wiced.c \
|
||||
btstack_uart_block_embedded.c \
|
||||
hci_transport_h4_wiced.c \
|
||||
../../chipset/bcm/btstack_chipset_bcm.c \
|
||||
../../../drivers/bluetooth/firmware/$(BT_CHIP)$(BT_CHIP_REVISION)/bt_firmware_image.c \
|
||||
|
@ -46,14 +46,19 @@
|
||||
#define __BTSTACK_UART_BLOCK_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "hci_transport.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t baudrate;
|
||||
int flowcontrol;
|
||||
const char *device_name;
|
||||
} btstack_uart_config_t;
|
||||
|
||||
typedef struct {
|
||||
/**
|
||||
* init transport
|
||||
* @param transport_config
|
||||
* @param uart_config
|
||||
*/
|
||||
int (*init)(const hci_transport_config_uart_t * config);
|
||||
int (*init)(const btstack_uart_config_t * uart_config);
|
||||
|
||||
/**
|
||||
* open transport connection
|
||||
@ -102,5 +107,6 @@ typedef struct {
|
||||
|
||||
// common implementations
|
||||
const btstack_uart_block_t * btstack_uart_block_posix_instance(void);
|
||||
const btstack_uart_block_t * btstack_uart_block_embedded_instance(void);
|
||||
|
||||
#endif
|
||||
|
@ -47,6 +47,7 @@
|
||||
#define __HCI_TRANSPORT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btstack_uart_block.h"
|
||||
#include "btstack_run_loop.h"
|
||||
|
||||
#if defined __cplusplus
|
||||
@ -126,14 +127,16 @@ typedef struct {
|
||||
// inline various hci_transport_X.h files
|
||||
|
||||
/*
|
||||
* @brief
|
||||
* @brief Setup H4 instance with uart_driver
|
||||
* @param uart_driver to use
|
||||
*/
|
||||
extern const hci_transport_t * hci_transport_h4_instance(void);
|
||||
extern const hci_transport_t * hci_transport_h4_instance(const btstack_uart_block_t * uart_driver);
|
||||
|
||||
/*
|
||||
* @brief
|
||||
* @brief Setup H5 instance with uart_driver
|
||||
* @param uart_driver to use
|
||||
*/
|
||||
extern const hci_transport_t * hci_transport_h5_instance(void);
|
||||
extern const hci_transport_t * hci_transport_h5_instance(const btstack_uart_block_t * uart_driver);
|
||||
|
||||
/*
|
||||
* @brief
|
||||
|
Loading…
x
Reference in New Issue
Block a user