1*b52fe020SMatthias Ringwald /* 2*b52fe020SMatthias Ringwald * Copyright (C) 2016 BlueKitchen GmbH 3*b52fe020SMatthias Ringwald * 4*b52fe020SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5*b52fe020SMatthias Ringwald * modification, are permitted provided that the following conditions 6*b52fe020SMatthias Ringwald * are met: 7*b52fe020SMatthias Ringwald * 8*b52fe020SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9*b52fe020SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10*b52fe020SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11*b52fe020SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12*b52fe020SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13*b52fe020SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14*b52fe020SMatthias Ringwald * contributors may be used to endorse or promote products derived 15*b52fe020SMatthias Ringwald * from this software without specific prior written permission. 16*b52fe020SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17*b52fe020SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18*b52fe020SMatthias Ringwald * monetary gain. 19*b52fe020SMatthias Ringwald * 20*b52fe020SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21*b52fe020SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*b52fe020SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*b52fe020SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24*b52fe020SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25*b52fe020SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26*b52fe020SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27*b52fe020SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28*b52fe020SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29*b52fe020SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30*b52fe020SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*b52fe020SMatthias Ringwald * SUCH DAMAGE. 32*b52fe020SMatthias Ringwald * 33*b52fe020SMatthias Ringwald * Please inquire about commercial licensing options at 34*b52fe020SMatthias Ringwald * [email protected] 35*b52fe020SMatthias Ringwald * 36*b52fe020SMatthias Ringwald */ 37*b52fe020SMatthias Ringwald 38*b52fe020SMatthias Ringwald /* 39*b52fe020SMatthias Ringwald * btstack_uart_block.h 40*b52fe020SMatthias Ringwald * 41*b52fe020SMatthias Ringwald * Common code to access serial port via asynchronous block read/write commands 42*b52fe020SMatthias Ringwald * 43*b52fe020SMatthias Ringwald */ 44*b52fe020SMatthias Ringwald 45*b52fe020SMatthias Ringwald #ifndef __BTSTACK_UART_BLOCK_H 46*b52fe020SMatthias Ringwald #define __BTSTACK_UART_BLOCK_H 47*b52fe020SMatthias Ringwald 48*b52fe020SMatthias Ringwald #include <stdint.h> 49*b52fe020SMatthias Ringwald #include "hci_transport.h" 50*b52fe020SMatthias Ringwald 51*b52fe020SMatthias Ringwald typedef struct { 52*b52fe020SMatthias Ringwald /** 53*b52fe020SMatthias Ringwald * init transport 54*b52fe020SMatthias Ringwald * @param transport_config 55*b52fe020SMatthias Ringwald */ 56*b52fe020SMatthias Ringwald int (*init)(const hci_transport_config_uart_t * config); 57*b52fe020SMatthias Ringwald 58*b52fe020SMatthias Ringwald /** 59*b52fe020SMatthias Ringwald * open transport connection 60*b52fe020SMatthias Ringwald */ 61*b52fe020SMatthias Ringwald int (*open)(void); 62*b52fe020SMatthias Ringwald 63*b52fe020SMatthias Ringwald /** 64*b52fe020SMatthias Ringwald * close transport connection 65*b52fe020SMatthias Ringwald */ 66*b52fe020SMatthias Ringwald int (*close)(void); 67*b52fe020SMatthias Ringwald 68*b52fe020SMatthias Ringwald /** 69*b52fe020SMatthias Ringwald * set callback for block received 70*b52fe020SMatthias Ringwald */ 71*b52fe020SMatthias Ringwald void (*set_block_received)(void (*block_handler)(void)); 72*b52fe020SMatthias Ringwald 73*b52fe020SMatthias Ringwald /** 74*b52fe020SMatthias Ringwald * set callback for sent 75*b52fe020SMatthias Ringwald */ 76*b52fe020SMatthias Ringwald void (*set_block_sent)(void (*block_handler)(void)); 77*b52fe020SMatthias Ringwald 78*b52fe020SMatthias Ringwald /** 79*b52fe020SMatthias Ringwald * set baudrate 80*b52fe020SMatthias Ringwald */ 81*b52fe020SMatthias Ringwald int (*set_baudrate)(uint32_t baudrate); 82*b52fe020SMatthias Ringwald 83*b52fe020SMatthias Ringwald /** 84*b52fe020SMatthias Ringwald * set parity 85*b52fe020SMatthias Ringwald */ 86*b52fe020SMatthias Ringwald int (*set_parity)(int parity); 87*b52fe020SMatthias Ringwald 88*b52fe020SMatthias Ringwald /** 89*b52fe020SMatthias Ringwald * receive block 90*b52fe020SMatthias Ringwald */ 91*b52fe020SMatthias Ringwald void (*receive_block)(uint8_t *buffer, uint16_t len); 92*b52fe020SMatthias Ringwald 93*b52fe020SMatthias Ringwald /** 94*b52fe020SMatthias Ringwald * send block 95*b52fe020SMatthias Ringwald */ 96*b52fe020SMatthias Ringwald void (*send_block)(const uint8_t *buffer, uint16_t length); 97*b52fe020SMatthias Ringwald 98*b52fe020SMatthias Ringwald // void hal_uart_dma_set_sleep(uint8_t sleep); 99*b52fe020SMatthias Ringwald // void hal_uart_dma_set_csr_irq_handler( void (*csr_irq_handler)(void)); 100*b52fe020SMatthias Ringwald 101*b52fe020SMatthias Ringwald } btstack_uart_block_t; 102*b52fe020SMatthias Ringwald 103*b52fe020SMatthias Ringwald // common implementations 104*b52fe020SMatthias Ringwald const btstack_uart_block_t * btstack_uart_block_posix_instance(void); 105*b52fe020SMatthias Ringwald 106*b52fe020SMatthias Ringwald #endif 107