From 3250103aa0e98ab68aafefb20da8e2429ae9cfe9 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 23 Mar 2016 15:54:41 +0100 Subject: [PATCH] posix: support B300/B1200 mapped to 2mbps hack --- platform/posix/hci_transport_h4_posix.c | 16 ++++++++++++++++ port/posix-h4/main.c | 16 ++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/platform/posix/hci_transport_h4_posix.c b/platform/posix/hci_transport_h4_posix.c index 1920d4498..8684ca5a1 100644 --- a/platform/posix/hci_transport_h4_posix.c +++ b/platform/posix/hci_transport_h4_posix.c @@ -125,6 +125,22 @@ static int h4_set_baudrate(uint32_t baudrate){ #ifdef B921600 case 921600: brate=B921600; break; #endif +// Hacks to switch to 2/3 mbps on FTDI FT232 chipsets +// requires special config in Info.plist or Registry +#ifdef HAVE_B300_MAPPED_TO_2000000 + case 2000000: brate=B300; break; +#endif +#ifdef HAVE_B600_MAPPED_TO_3000000 + case 3000000: brate=B600; break; +#endif +#ifdef HAVE_B1200_MAPPED_TO_2000000 + case 2000000: brate=B1200; break; +#endif +#ifdef HAVE_B2400_MAPPED_TO_3000000 + case 3000000: brate=B2400; break; +#endif + default: + break; } cfsetospeed(&toptions, brate); cfsetispeed(&toptions, brate); diff --git a/port/posix-h4/main.c b/port/posix-h4/main.c index e2c314347..e6b9c358a 100644 --- a/port/posix-h4/main.c +++ b/port/posix-h4/main.c @@ -94,9 +94,17 @@ void hal_led_toggle(void){ led_state = 1 - led_state; printf("LED State %u\n", led_state); } -static void using_921600_baud(void){ +static void use_fast_uart(void){ +#if defined(HAVE_B1200_MAPPED_TO_3000000) || defined(HAVE_B300_MAPPED_TO_3000000) + printf("Using 3000000 baud.\n"); + config.baudrate_main = 3000000; +#elif defined(HAVE_B1200_MAPPED_TO_2000000) || defined(HAVE_B300_MAPPED_TO_2000000) + printf("Using 2000000 baud.\n"); + config.baudrate_main = 2000000; +#else printf("Using 921600 baud.\n"); config.baudrate_main = 921600; +#endif } static void local_version_information_callback(uint8_t * packet){ @@ -114,12 +122,12 @@ static void local_version_information_callback(uint8_t * packet){ switch (manufacturer){ case COMPANY_ID_CAMBRIDGE_SILICON_RADIO: printf("Cambridge Silicon Radio CSR chipset.\n"); - using_921600_baud(); + use_fast_uart(); hci_set_chipset(btstack_chipset_csr_instance()); break; case COMPANY_ID_TEXAS_INSTRUMENTS_INC: printf("Texas Instruments - CC256x compatible chipset.\n"); - using_921600_baud(); + use_fast_uart(); hci_set_chipset(btstack_chipset_cc256x_instance()); break; case COMPANY_ID_BROADCOM_CORPORATION: @@ -128,7 +136,7 @@ static void local_version_information_callback(uint8_t * packet){ break; case COMPANY_ID_ST_MICROELECTRONICS: printf("ST Microelectronics - using STLC2500d driver.\n"); - using_921600_baud(); + use_fast_uart(); hci_set_chipset(btstack_chipset_stlc2500d_instance()); break; case COMPANY_ID_EM_MICROELECTRONICS_MARIN: