diff --git a/port/wiced/create_examples.py b/port/wiced/create_examples.py index 6eb32f0a0..0bd4bd6d8 100755 --- a/port/wiced/create_examples.py +++ b/port/wiced/create_examples.py @@ -20,6 +20,7 @@ GLOBAL_INCLUDES += . $(NAME)_SOURCES := ../../../libraries/btstack/example/EXAMPLE.c $(NAME)_COMPONENTS += btstack/port/wiced +$(NAME)_CFLAGS += ADDITIONAL_CFLAGS ''' gatt_update_template = '''#!/bin/sh @@ -45,7 +46,14 @@ if not "WICED Version" in wiced_version: sys.exit(1) # show WICED version -print("Found %s" % wiced_version) +wiced_version = wiced_version.split()[2] +print("Found WICED SDK version: %s" % wiced_version) + +additional_cflags = "" +if wiced_version < "3.4.0": + print("Adding WICED_UART_READ_DOES_NOT_RETURN_BYTES_READ for SDK < 3.4.0") + additional_cflags = "-DWICED_UART_READ_DOES_NOT_RETURN_BYTES_READ" + # path to examples examples_embedded = script_path + "/../../example/" @@ -68,7 +76,7 @@ for file in os.listdir(examples_embedded): # create .mk file with open(apps_folder + example + ".mk", "wt") as fout: - fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("DATE",time.strftime("%c"))) + fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("ADDITIONAL_CFLAGS", additional_cflags).replace("DATE",time.strftime("%c"))) # create update_gatt.sh if .gatt file is present gatt_path = examples_embedded + example + ".gatt" diff --git a/port/wiced/hci_transport_h4_wiced.c b/port/wiced/hci_transport_h4_wiced.c index f7804f5a8..445261812 100644 --- a/port/wiced/hci_transport_h4_wiced.c +++ b/port/wiced/hci_transport_h4_wiced.c @@ -121,10 +121,22 @@ static wiced_result_t h4_main_notify_packet_send(void *arg){ } // executed on rx worker thread + static void h4_rx_worker_receive_bytes(int bytes_to_read){ + +#ifdef WICED_UART_READ_DOES_NOT_RETURN_BYTES_READ + // older API passes in number of bytes to read (checked in 3.3.1 and 3.4.0) platform_uart_receive_bytes(wiced_bt_uart_driver, &hci_packet[rx_worker_read_pos], bytes_to_read, WICED_NEVER_TIMEOUT); +#else + // newer API uses pointer to return number of read bytes + uint32_t bytes = bytes_to_read; + platform_uart_receive_bytes(wiced_bt_uart_driver, &hci_packet[rx_worker_read_pos], &bytes, WICED_NEVER_TIMEOUT); + // assumption: bytes = bytes_to_rad as timeout is never +#endif rx_worker_read_pos += bytes_to_read; + } + static wiced_result_t h4_rx_worker_receive_packet(void * arg){ #ifdef WICED_BT_UART_MANUAL_CTS_RTS diff --git a/port/wiced/readme.md b/port/wiced/readme.md index 00ad89afd..4dcb51d6d 100644 --- a/port/wiced/readme.md +++ b/port/wiced/readme.md @@ -1,6 +1,6 @@ # BTstack port for WICED platform -WICED SDK 3.5.2 or higher required. With RedBear Duo, please follow their installation guide for WICED SDK first. +Only tested on Redbear Duo platform. Please install [RedBear WICED Add-On](https://github.com/redbear/WICED-SDK) first. To integrate BTstack into the WICED SDK, please move the BTstack project into WICED-SDK-3.5.2/libraries. Then create projects for BTstack examples in WICED/apps/btstack by running: @@ -15,8 +15,6 @@ to build the SPP-and-LE-Counter example. See WICED documentation about how to install it. -Only tested on Redbear Duo platform. - It should work with all WICED platforms that contain a Broadcom Bluetooth chipset. The maximal baud rate is limited to 3 mbps. diff --git a/port/wiced/wiced.mk b/port/wiced/wiced.mk index 8bcc1e077..59b7c293e 100644 --- a/port/wiced/wiced.mk +++ b/port/wiced/wiced.mk @@ -42,4 +42,9 @@ $(NAME)_SOURCES += \ btstack_run_loop_wiced.c \ hci_transport_h4_wiced.c \ ../../chipset/bcm/btstack_chipset_bcm.c \ - ../../../drivers/bluetooth/firmware/$(BT_CHIP)$(BT_CHIP_REVISION)/$(BT_CHIP_XTAL_FREQUENCY)/bt_firmware_image.c \ + +ifeq ($(BT_CHIP_XTAL_FREQUENCY),) +$(NAME)_SOURCES := ../../../drivers/bluetooth/firmware/$(BT_CHIP)$(BT_CHIP_REVISION)/bt_firmware_image.c +else +$(NAME)_SOURCES := ../../../drivers/bluetooth/firmware/$(BT_CHIP)$(BT_CHIP_REVISION)/$(BT_CHIP_XTAL_FREQUENCY)/bt_firmware_image.c +endif