1# BTstack Port for POSIX Systems with Dialog Semiconductor DA14531 Controller 2 3This port allows to use the DA14531 connected via UART with BTstack running on a POSIX host system. 4 5Instead of storing the HCI firmware in the OTP, it first downloads the hci_531_active_uart_460800.hex firmware 6from the 6.0.16.1144 SDK, before BTstack starts up. 7 8After Power Cycle, please start one of the test applications and press the Reset button to trigger firmware download. 9 10Please note that it does not detect if the firmware has already been downloaded, so you need to Power Cycle 11the DA14531 before starting an example again. 12 13Alternatively, after running one of the examples once to upload the firmware, you can use the regular 'posix-h4' port 14and change the initial UART baud rate to 460800 as long as you don't power cycle the dev kit. 15 16For production use, the DA14531 could be power cycled from the main CPU during startup, e.g. after the call 17to btstack_chipset_da145xx_download_firmware_with_uart, or, the HCI firmware could be burned into the OTP. 18 19# Software Setup / Firmware 20 21On the [DA14531 USB Development Kit](https://www.dialog-semiconductor.com/products/bluetooth-low-energy/da14531-development-kit-usb), 22the UART is configured via DIP switched. By this, the mapping to the DA14531 GPIOs is fixed. In SDK 6.0.6.1144, the 23GPIO mapping of RTS and CTS is flipped. In order to be able to us the same HCI firmware on both dev kits, we've 24used the following configuration in `user_perip_setup.h` 25 26```C 27 #define UART1_TX_PORT GPIO_PORT_0 28 #define UART1_TX_PIN GPIO_PIN_0 29 30 #define UART1_RX_PORT GPIO_PORT_0 31 #define UART1_RX_PIN GPIO_PIN_1 32 33 #define UART1_RTSN_PORT GPIO_PORT_0 34 #define UART1_RTSN_PIN GPIO_PIN_4 35 36 #define UART1_CTSN_PORT GPIO_PORT_0 37 #define UART1_CTSN_PIN GPIO_PIN_3 38``` 39 40We also increased the UART baudrate to 460800 41 42```C 43#define UART1_BAUDRATE UART_BAUDRATE_460800 44``` 45 46We also disabled the SLEEP mode in user_config.h: 47 48```C 49static const sleep_state_t app_default_sleep_mode = ARCH_SLEEP_OFF; 50``` 51 52After compilation with Keil uVision 5, the generated .hex file is copied into btstack/chipset/da145xx as 53`hci_531_active_uart_460800.hex`, and then 54`convert_hex_files" is used to convert it into a C data array. 55 56 57# Hardware Setup - Dev Kit Pro 58 59To use the [DA14531 Dev Kit Pro](https://www.dialog-semiconductor.com/products/bluetooth-low-energy/da14530-and-da14531-development-kit-pro) 60with BTstack, please make the following modifications: 61- Follow Chapter 4.1 and Figure 4 in the [DA14531 Development Kit Pro Hardware User Manual 62 UM-B-114](https://www.dialog-semiconductor.com/sites/default/files/2021-06/UM-B-114_DA14531_Devkit_Pro_Hardware_User%20manual_1v5.pdf) 63 and set SW1 of the 14531 daughter board into position "BUCK" position marked with an "H" on the left side. 64- configure the dev kit for Full UART (4-wire) Configuration by adding jumper wires between J1 and J2 65 66# Hardware Setup - Dev Kit USB 67 68To use the [Dev Kit USB](https://www.dialog-semiconductor.com/products/bluetooth-low-energy/da14531-development-kit-usb#tab-field_tab_content_overview) 69with BTstack, please make the following modifications: 70- Follow Chapter 5.6 in the [DA14531 USB Development Kit Hardware UM-B-125](https://www.dialog-semiconductor.com/sites/default/files/um-b-125_da14531_usb_development_kit_hw_manual_1v1.pdf) 71 and set the DIP switches as described. 72 73 # Example Run 74 75``` 76$ ./gatt_counter 77Packet Log: /tmp/hci_dump.pklg 78Phase 1: Download firmware 79Phase 2: Main app 80BTstack counter 0001 81BTstack up and running on 80:EA:CA:70:00:08. 82``` 83