11f504dbdSmatthias.ringwald /* 2a0c35809S[email protected] * Copyright (C) 2014 BlueKitchen GmbH 31713bceaSmatthias.ringwald * 41713bceaSmatthias.ringwald * Redistribution and use in source and binary forms, with or without 51713bceaSmatthias.ringwald * modification, are permitted provided that the following conditions 61713bceaSmatthias.ringwald * are met: 71713bceaSmatthias.ringwald * 81713bceaSmatthias.ringwald * 1. Redistributions of source code must retain the above copyright 91713bceaSmatthias.ringwald * notice, this list of conditions and the following disclaimer. 101713bceaSmatthias.ringwald * 2. Redistributions in binary form must reproduce the above copyright 111713bceaSmatthias.ringwald * notice, this list of conditions and the following disclaimer in the 121713bceaSmatthias.ringwald * documentation and/or other materials provided with the distribution. 131713bceaSmatthias.ringwald * 3. Neither the name of the copyright holders nor the names of 141713bceaSmatthias.ringwald * contributors may be used to endorse or promote products derived 151713bceaSmatthias.ringwald * from this software without specific prior written permission. 166b64433eSmatthias.ringwald * 4. Any redistribution, use, or modification is done solely for 176b64433eSmatthias.ringwald * personal benefit and not for any commercial purpose or for 186b64433eSmatthias.ringwald * monetary gain. 191713bceaSmatthias.ringwald * 20a0c35809S[email protected] * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 211713bceaSmatthias.ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 221713bceaSmatthias.ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 251713bceaSmatthias.ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 261713bceaSmatthias.ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 271713bceaSmatthias.ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 281713bceaSmatthias.ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 291713bceaSmatthias.ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 301713bceaSmatthias.ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311713bceaSmatthias.ringwald * SUCH DAMAGE. 321713bceaSmatthias.ringwald * 33a0c35809S[email protected] * Please inquire about commercial licensing options at 34a0c35809S[email protected] * [email protected] 356b64433eSmatthias.ringwald * 361713bceaSmatthias.ringwald */ 371713bceaSmatthias.ringwald 38fe5a6c4eSMilanka Ringwald /** 39fe5a6c4eSMilanka Ringwald * @title HCI Transport 401f504dbdSmatthias.ringwald * 41fe5a6c4eSMilanka Ringwald * The API allows BTstack to use different transport interfaces. 421f504dbdSmatthias.ringwald * 431f504dbdSmatthias.ringwald */ 44fe5a6c4eSMilanka Ringwald 4580e33422SMatthias Ringwald #ifndef HCI_TRANSPORT_H 4680e33422SMatthias Ringwald #define HCI_TRANSPORT_H 471f504dbdSmatthias.ringwald 48c8dfe071SMatthias Ringwald #include "btstack_config.h" 49f1f3f303SMatthias Ringwald #include "btstack_defines.h" 502e36e02aSmatthias.ringwald 51c8dfe071SMatthias Ringwald #include <stdint.h> 52c8dfe071SMatthias Ringwald 53e3b6fe7eSmatthias.ringwald #if defined __cplusplus 54e3b6fe7eSmatthias.ringwald extern "C" { 55e3b6fe7eSmatthias.ringwald #endif 56e3b6fe7eSmatthias.ringwald 579c13b5caSMatthias Ringwald 5899e736a0SMilanka Ringwald /* API_START */ 5999e736a0SMilanka Ringwald 609bf70ccbSmatthias.ringwald /* HCI packet types */ 611f504dbdSmatthias.ringwald typedef struct { 6224b3c629SMatthias Ringwald /** 6324b3c629SMatthias Ringwald * transport name 6424b3c629SMatthias Ringwald */ 6524b3c629SMatthias Ringwald const char * name; 6624b3c629SMatthias Ringwald 6724b3c629SMatthias Ringwald /** 6824b3c629SMatthias Ringwald * init transport 6924b3c629SMatthias Ringwald * @param transport_config 7024b3c629SMatthias Ringwald */ 7124b3c629SMatthias Ringwald void (*init) (const void *transport_config); 7224b3c629SMatthias Ringwald 7324b3c629SMatthias Ringwald /** 7424b3c629SMatthias Ringwald * open transport connection 7524b3c629SMatthias Ringwald */ 7624b3c629SMatthias Ringwald int (*open)(void); 7724b3c629SMatthias Ringwald 7824b3c629SMatthias Ringwald /** 7924b3c629SMatthias Ringwald * close transport connection 8024b3c629SMatthias Ringwald */ 8124b3c629SMatthias Ringwald int (*close)(void); 8224b3c629SMatthias Ringwald 8324b3c629SMatthias Ringwald /** 8424b3c629SMatthias Ringwald * register packet handler for HCI packets: ACL, SCO, and Events 8524b3c629SMatthias Ringwald */ 8610e830c9Smatthias.ringwald void (*register_packet_handler)(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size)); 8724b3c629SMatthias Ringwald 8824b3c629SMatthias Ringwald /** 8924b3c629SMatthias Ringwald * support async transport layers, e.g. IRQ driven without buffers 9024b3c629SMatthias Ringwald */ 91912a5b0cSmatthias.ringwald int (*can_send_packet_now)(uint8_t packet_type); 9224b3c629SMatthias Ringwald 9324b3c629SMatthias Ringwald /** 9424b3c629SMatthias Ringwald * send packet 9524b3c629SMatthias Ringwald */ 9624b3c629SMatthias Ringwald int (*send_packet)(uint8_t packet_type, uint8_t *packet, int size); 9724b3c629SMatthias Ringwald 9824b3c629SMatthias Ringwald /** 9924b3c629SMatthias Ringwald * extension for UART transport implementations 10024b3c629SMatthias Ringwald */ 10124b3c629SMatthias Ringwald int (*set_baudrate)(uint32_t baudrate); 102200f5f4dSMatthias Ringwald 103200f5f4dSMatthias Ringwald /** 104200f5f4dSMatthias Ringwald * extension for UART H5 on CSR: reset BCSP/H5 Link 105200f5f4dSMatthias Ringwald */ 106200f5f4dSMatthias Ringwald void (*reset_link)(void); 10724b3c629SMatthias Ringwald 108ee752bb8SMatthias Ringwald /** 109ee752bb8SMatthias Ringwald * extension for USB transport implementations: config SCO connections 110ee752bb8SMatthias Ringwald */ 111ee752bb8SMatthias Ringwald void (*set_sco_config)(uint16_t voice_setting, int num_connections); 112ee752bb8SMatthias Ringwald 1131f504dbdSmatthias.ringwald } hci_transport_t; 1141f504dbdSmatthias.ringwald 1159796ebeaSMatthias Ringwald typedef enum { 1169796ebeaSMatthias Ringwald HCI_TRANSPORT_CONFIG_UART, 1179796ebeaSMatthias Ringwald HCI_TRANSPORT_CONFIG_USB 1189796ebeaSMatthias Ringwald } hci_transport_config_type_t; 1199796ebeaSMatthias Ringwald 1201f504dbdSmatthias.ringwald typedef struct { 1219796ebeaSMatthias Ringwald hci_transport_config_type_t type; 1229796ebeaSMatthias Ringwald } hci_transport_config_t; 1239796ebeaSMatthias Ringwald 1249796ebeaSMatthias Ringwald typedef struct { 1259796ebeaSMatthias Ringwald hci_transport_config_type_t type; // == HCI_TRANSPORT_CONFIG_UART 126ca3e27ccSmatthias.ringwald uint32_t baudrate_init; // initial baud rate 127ca3e27ccSmatthias.ringwald uint32_t baudrate_main; // = 0: same as initial baudrate 1281f504dbdSmatthias.ringwald int flowcontrol; // 1299796ebeaSMatthias Ringwald const char *device_name; 130e76f5dd4SMatthias Ringwald int parity; // see btstack_uart.h BTSTACK_UART_PARITY 1319796ebeaSMatthias Ringwald } hci_transport_config_uart_t; 1321f504dbdSmatthias.ringwald 13399e736a0SMilanka Ringwald /* API_END */ 13499e736a0SMilanka Ringwald 135e3b6fe7eSmatthias.ringwald #if defined __cplusplus 136e3b6fe7eSmatthias.ringwald } 137e3b6fe7eSmatthias.ringwald #endif 138c6448b67Smatthias.ringwald 13980e33422SMatthias Ringwald #endif // HCI_TRANSPORT_H 140