xref: /btstack/src/btstack_uart_slip_wrapper.h (revision 9e104a3cf63fdbd212d138642b65a6147054c37b)
1dd90474bSMatthias Ringwald /*
2dd90474bSMatthias Ringwald  * Copyright (C) 2021 BlueKitchen GmbH
3dd90474bSMatthias Ringwald  *
4dd90474bSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5dd90474bSMatthias Ringwald  * modification, are permitted provided that the following conditions
6dd90474bSMatthias Ringwald  * are met:
7dd90474bSMatthias Ringwald  *
8dd90474bSMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9dd90474bSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10dd90474bSMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11dd90474bSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12dd90474bSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13dd90474bSMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14dd90474bSMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15dd90474bSMatthias Ringwald  *    from this software without specific prior written permission.
16dd90474bSMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17dd90474bSMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18dd90474bSMatthias Ringwald  *    monetary gain.
19dd90474bSMatthias Ringwald  *
20dd90474bSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21dd90474bSMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22dd90474bSMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
232fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
242fca4dadSMilanka Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25dd90474bSMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26dd90474bSMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27dd90474bSMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28dd90474bSMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29dd90474bSMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30dd90474bSMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31dd90474bSMatthias Ringwald  * SUCH DAMAGE.
32dd90474bSMatthias Ringwald  *
33dd90474bSMatthias Ringwald  * Please inquire about commercial licensing options at
34dd90474bSMatthias Ringwald  * [email protected]
35dd90474bSMatthias Ringwald  *
36dd90474bSMatthias Ringwald  */
37dd90474bSMatthias Ringwald 
38fe5a6c4eSMilanka Ringwald /**
39fe5a6c4eSMilanka Ringwald  * @title UART SLIP Wrapper
40dd90474bSMatthias Ringwald  *
41fe5a6c4eSMilanka Ringwald  * Compatibility layer to use new H5 implementation with btstack_uart.h implementations without SLIP support.
42fe5a6c4eSMilanka Ringwald  * Using this compatibility layer caused increased processing as it uses single byte UART reads.
43dd90474bSMatthias Ringwald  *
44fe5a6c4eSMilanka Ringwald  * If you're using H5, please consider implement the H5/SLIP functions in your btstack_uart.h or hal_uart_dma.h implementation.
45fe5a6c4eSMilanka Ringwald  *
46dd90474bSMatthias Ringwald  */
47dd90474bSMatthias Ringwald 
48dd90474bSMatthias Ringwald #ifndef BTSTACK_UART_SLIP_WRAPPER_H
49dd90474bSMatthias Ringwald #define BTSTACK_UART_SLIP_WRAPPER_H
50dd90474bSMatthias Ringwald 
51dd90474bSMatthias Ringwald #include <stdint.h>
52dd90474bSMatthias Ringwald #include "btstack_uart.h"
53dd90474bSMatthias Ringwald 
54*9e104a3cSpengyiqiang #if defined __cplusplus
55*9e104a3cSpengyiqiang extern "C" {
56*9e104a3cSpengyiqiang #endif
57*9e104a3cSpengyiqiang 
58fe5a6c4eSMilanka Ringwald /* API_START */
59fe5a6c4eSMilanka Ringwald 
60dd90474bSMatthias Ringwald /**
61dd90474bSMatthias Ringwald  * @brief Initialize SLIP wrapper for existing btstack_uart_block_t instance without SLIP support
62dd90474bSMatthias Ringwald  * @param uart_block_without_slip
636b65794dSMilanka Ringwald  * @return btstack_uart_t instance with SLIP support for use with hci_trasnport_h5
64dd90474bSMatthias Ringwald  */
65dd90474bSMatthias Ringwald const btstack_uart_t * btstack_uart_slip_wrapper_instance(const btstack_uart_t * uart_without_slip);
66dd90474bSMatthias Ringwald 
67fe5a6c4eSMilanka Ringwald /* API_END */
68fe5a6c4eSMilanka Ringwald 
69*9e104a3cSpengyiqiang #if defined __cplusplus
70*9e104a3cSpengyiqiang }
71*9e104a3cSpengyiqiang #endif
72*9e104a3cSpengyiqiang 
73dd90474bSMatthias Ringwald #endif
74