From 7fe5c1bdd36fe54749dc309d5262fddc90f0dc6e Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 17 Jan 2016 22:12:19 +0100 Subject: [PATCH] cleanup after merge, add port/posix-csr --- chipset-bcm/bt_control_bcm.c | 131 ------------------ chipset-bcm/bt_control_bcm.h | 59 -------- chipset/csr/bt_control_csr.c | 2 +- .../tc3556x}/bt_control_tc3566x.c | 0 .../tc3556x}/bt_control_tc3566x.h | 0 {platforms => port}/posix-csr/.gitignore | 0 {platforms => port}/posix-csr/Makefile | 11 +- .../posix-csr/btstack-config.h | 0 {platforms => port}/posix-csr/main.c | 25 ++-- {platforms => port}/posix-tc35661/.gitignore | 0 {platforms => port}/posix-tc35661/Makefile | 0 .../posix-tc35661/btstack-config.h | 0 {platforms => port}/posix-tc35661/main.c | 0 13 files changed, 20 insertions(+), 208 deletions(-) delete mode 100644 chipset-bcm/bt_control_bcm.c delete mode 100644 chipset-bcm/bt_control_bcm.h rename {chipset-tc3566x => chipset/tc3556x}/bt_control_tc3566x.c (100%) rename {chipset-tc3566x => chipset/tc3556x}/bt_control_tc3566x.h (100%) rename {platforms => port}/posix-csr/.gitignore (100%) rename {platforms => port}/posix-csr/Makefile (76%) rename {platforms => port}/posix-csr/btstack-config.h (100%) rename {platforms => port}/posix-csr/main.c (88%) rename {platforms => port}/posix-tc35661/.gitignore (100%) rename {platforms => port}/posix-tc35661/Makefile (100%) rename {platforms => port}/posix-tc35661/btstack-config.h (100%) rename {platforms => port}/posix-tc35661/main.c (100%) diff --git a/chipset-bcm/bt_control_bcm.c b/chipset-bcm/bt_control_bcm.c deleted file mode 100644 index 8f21f53ec..000000000 --- a/chipset-bcm/bt_control_bcm.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2009-2012 by Matthias Ringwald - * - * 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 MATTHIAS RINGWALD 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 btstack@ringwald.ch - * - */ - -/* - * bt_control_bcm.c - * - * Adapter to use Broadcom-based chipsets with BTstack - */ - - -#include "btstack-config.h" -#include "bt_control_bcm.h" - -#include /* NULL */ -#include -#include /* memcpy */ - -#include "bt_control.h" -#include "debug.h" - -// actual init script provided by separate bt_firmware_image.c from WICED SDK -extern const uint8_t brcm_patchram_buf[]; -extern const int brcm_patch_ram_length; -extern const char brcm_patch_version[]; - -// -static uint32_t init_script_offset; -static int send_download_command; - -static int bt_control_bcm_on(void *config){ - log_info("Broadcom init script %s, len %u", brcm_patch_version, brcm_patch_ram_length); - init_script_offset = 0; - send_download_command = 1; - return 0; -} - -// @note: Broadcom chips require higher UART clock for baud rate > 3000000 -> limit baud rate in hci.c -static int bcm_baudrate_cmd(void * config, uint32_t baudrate, uint8_t *hci_cmd_buffer){ - hci_cmd_buffer[0] = 0x18; - hci_cmd_buffer[1] = 0xfc; - hci_cmd_buffer[2] = 0x06; - hci_cmd_buffer[3] = 0x00; - hci_cmd_buffer[4] = 0x00; - bt_store_32(hci_cmd_buffer, 5, baudrate); - return 0; -} - -// @note: bd addr has to be set after sending init script (it might just get re-set) -static int bt_control_bcm_set_bd_addr_cmd(void * config, bd_addr_t addr, uint8_t *hci_cmd_buffer){ - hci_cmd_buffer[0] = 0x01; - hci_cmd_buffer[1] = 0xfc; - hci_cmd_buffer[2] = 0x06; - bt_flip_addr(&hci_cmd_buffer[3], addr); - return 0; -} - -static int bt_control_bcm_next_cmd(void *config, uint8_t *hci_cmd_buffer){ - - // send download firmware command - if (send_download_command){ - send_download_command = 0; - hci_cmd_buffer[0] = 0x2e; - hci_cmd_buffer[1] = 0xfc; - hci_cmd_buffer[2] = 0x00; - return 1; - } - - if (init_script_offset >= brcm_patch_ram_length) { - return 0; - } - - // use memcpy with pointer - int cmd_len = 3 + brcm_patchram_buf[init_script_offset+2]; - memcpy(&hci_cmd_buffer[0], &brcm_patchram_buf[init_script_offset], cmd_len); - init_script_offset += cmd_len; - return 1; -} - -// MARK: const structs - -static const bt_control_t bt_control_bcm = { - bt_control_bcm_on, // on - NULL, // off - NULL, // sleep - NULL, // wake - NULL, // valid - NULL, // name - bcm_baudrate_cmd, // baudrate_cmd - bt_control_bcm_next_cmd, // next_cmd - NULL, // register_for_power_notifications - NULL, // hw_error - bt_control_bcm_set_bd_addr_cmd, // set_bd_addr_cmd -}; - -// MARK: public API -bt_control_t * bt_control_bcm_instance(void){ - return (bt_control_t*) &bt_control_bcm; -} diff --git a/chipset-bcm/bt_control_bcm.h b/chipset-bcm/bt_control_bcm.h deleted file mode 100644 index 6de9f3370..000000000 --- a/chipset-bcm/bt_control_bcm.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2009-2012 by Matthias Ringwald - * - * 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 MATTHIAS RINGWALD 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 btstack@ringwald.ch - * - */ - -/* - * bt_control_bcm.h - * - * Adapter to use Broadcom-based chipsets with BTstack - */ - -#ifndef __BT_CONTROL_BCM_H -#define __BT_CONTROL_BCM_H - -#if defined __cplusplus -extern "C" { -#endif - -#include -#include "bt_control.h" - -bt_control_t * bt_control_bcm_instance(void); - -#if defined __cplusplus -} -#endif - -#endif // __BT_CONTROL_BCM_H diff --git a/chipset/csr/bt_control_csr.c b/chipset/csr/bt_control_csr.c index 1fd79d824..f7aa4f7e2 100644 --- a/chipset/csr/bt_control_csr.c +++ b/chipset/csr/bt_control_csr.c @@ -82,7 +82,7 @@ static void bt_control_csr_update_command(void *config, uint8_t *hci_cmd_buffer) // check for hci_transport_config_uart_t if (!config) return; - if (((hci_transport_config_t*))->type != HCI_TRANSPORT_CONFIG_UART) return; + if (((hci_transport_config_t*)config)->type != HCI_TRANSPORT_CONFIG_UART) return; hci_transport_config_uart_t * hci_transport_config_uart = (hci_transport_config_uart_t*) config; uint32_t baudrate = hci_transport_config_uart->baudrate_main; diff --git a/chipset-tc3566x/bt_control_tc3566x.c b/chipset/tc3556x/bt_control_tc3566x.c similarity index 100% rename from chipset-tc3566x/bt_control_tc3566x.c rename to chipset/tc3556x/bt_control_tc3566x.c diff --git a/chipset-tc3566x/bt_control_tc3566x.h b/chipset/tc3556x/bt_control_tc3566x.h similarity index 100% rename from chipset-tc3566x/bt_control_tc3566x.h rename to chipset/tc3556x/bt_control_tc3566x.h diff --git a/platforms/posix-csr/.gitignore b/port/posix-csr/.gitignore similarity index 100% rename from platforms/posix-csr/.gitignore rename to port/posix-csr/.gitignore diff --git a/platforms/posix-csr/Makefile b/port/posix-csr/Makefile similarity index 76% rename from platforms/posix-csr/Makefile rename to port/posix-csr/Makefile index de26f1dd9..f23c378c0 100644 --- a/platforms/posix-csr/Makefile +++ b/port/posix-csr/Makefile @@ -1,6 +1,6 @@ # Makefile for libusb based examples BTSTACK_ROOT = ../.. -POSIX_ROOT= ${BTSTACK_ROOT}/platforms/posix +POSIX_ROOT= ${BTSTACK_ROOT}/platform/posix CORE += main.c stdin_support.c bt_control_csr.c @@ -8,15 +8,16 @@ COMMON += hci_transport_h4.c run_loop_posix.c remote_device_db_fs.c include ${BTSTACK_ROOT}/example/embedded/Makefile.inc -CFLAGS += -I$(BTSTACK_ROOT)/chipset-csr +CFLAGS += -I$(BTSTACK_ROOT)/chipset/csr \ + -I$(BTSTACK_ROOT)/platform/embedded CFLAGS += -g -Wall # # CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Werror -VPATH += ${BTSTACK_ROOT}/platforms/posix/src -VPATH += ${BTSTACK_ROOT}/chipset-csr +VPATH += ${BTSTACK_ROOT}/platform/posix/src +VPATH += ${BTSTACK_ROOT}/chipset/csr ifeq ($(OS),Windows_NT) LDFLAGS += -lws2_32 @@ -35,4 +36,4 @@ EXAMPLES += ${EXAMPLES_CLI} CFLAGS += -I${POSIX_ROOT}/src endif -all: ${BTSTACK_ROOT}/include/btstack/version.h ${EXAMPLES} +all: ${BTSTACK_ROOT}/src/version.h ${EXAMPLES} diff --git a/platforms/posix-csr/btstack-config.h b/port/posix-csr/btstack-config.h similarity index 100% rename from platforms/posix-csr/btstack-config.h rename to port/posix-csr/btstack-config.h diff --git a/platforms/posix-csr/main.c b/port/posix-csr/main.c similarity index 88% rename from platforms/posix-csr/main.c rename to port/posix-csr/main.c index d19f8412a..beb178466 100644 --- a/platforms/posix-csr/main.c +++ b/port/posix-csr/main.c @@ -49,22 +49,23 @@ #include "btstack-config.h" -#include - -#include "debug.h" #include "btstack_memory.h" +#include "debug.h" #include "hci.h" #include "hci_dump.h" +#include "run_loop.h" +#include "run_loop_posix.h" #include "stdin_support.h" -#include #include "bt_control_csr.h" int btstack_main(int argc, const char * argv[]); -static hci_uart_config_t hci_uart_config_cc256x = { - NULL, +static hci_transport_config_uart_t config = { + HCI_TRANSPORT_CONFIG_UART, 115200, - 921600 + 0, // main baudrate + 1, // flow control + NULL, }; static void sigint_handler(int param){ @@ -91,7 +92,7 @@ int main(int argc, const char * argv[]){ /// GET STARTED with BTstack /// btstack_memory_init(); - run_loop_init(RUN_LOOP_POSIX); + run_loop_init(run_loop_posix_get_instance()); #if 0 // Ubuntu @@ -100,7 +101,7 @@ int main(int argc, const char * argv[]){ hci_dump_open("hci_dump.pklg", HCI_DUMP_PACKETLOGGER); // pick serial port - hci_uart_config_cc256x.device_name = "/dev/ttyUSB0"; + config.device_name = "/dev/ttyUSB0"; #else // OS X @@ -108,15 +109,15 @@ int main(int argc, const char * argv[]){ hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER); // pick serial port - hci_uart_config_cc256x.device_name = "/dev/tty.usbserial-A900K0VK"; + config.device_name = "/dev/tty.usbserial-A900K0VK"; #endif // init HCI - hci_transport_t * transport = hci_transport_h4_instance(); + hci_transport_t * transport = hci_transport_h4_posix_instance(); bt_control_t * control = bt_control_csr_instance(); remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs; - hci_init(transport, (void*) &hci_uart_config_cc256x, control, remote_db); + hci_init(transport, (void*) &config, control, remote_db); // handle CTRL-c signal(SIGINT, sigint_handler); diff --git a/platforms/posix-tc35661/.gitignore b/port/posix-tc35661/.gitignore similarity index 100% rename from platforms/posix-tc35661/.gitignore rename to port/posix-tc35661/.gitignore diff --git a/platforms/posix-tc35661/Makefile b/port/posix-tc35661/Makefile similarity index 100% rename from platforms/posix-tc35661/Makefile rename to port/posix-tc35661/Makefile diff --git a/platforms/posix-tc35661/btstack-config.h b/port/posix-tc35661/btstack-config.h similarity index 100% rename from platforms/posix-tc35661/btstack-config.h rename to port/posix-tc35661/btstack-config.h diff --git a/platforms/posix-tc35661/main.c b/port/posix-tc35661/main.c similarity index 100% rename from platforms/posix-tc35661/main.c rename to port/posix-tc35661/main.c