1 /***************************************************************************//**
2 * @brief Bluetooth controller HCI API.
3 *
4 * This interface is for external use.
5 *******************************************************************************
6 * # License
7 * <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b>
8 *******************************************************************************
9 *
10 * SPDX-License-Identifier: Zlib
11 *
12 * The licensor of this software is Silicon Laboratories Inc.
13 *
14 * This software is provided 'as-is', without any express or implied
15 * warranty. In no event will the authors be held liable for any damages
16 * arising from the use of this software.
17 *
18 * Permission is granted to anyone to use this software for any purpose,
19 * including commercial applications, and to alter it and redistribute it
20 * freely, subject to the following restrictions:
21 *
22 * 1. The origin of this software must not be misrepresented; you must not
23 * claim that you wrote the original software. If you use this software
24 * in a product, an acknowledgment in the product documentation would be
25 * appreciated but is not required.
26 * 2. Altered source versions must be plainly marked as such, and must not be
27 * misrepresented as being the original software.
28 * 3. This notice may not be removed or altered from any source distribution.
29 *
30 ******************************************************************************/
31
32 #ifndef _SL_BTCTRL_HCI_H_
33 #define _SL_BTCTRL_HCI_H_
34
35 #include <stdint.h>
36 #include <stdbool.h>
37 #include "sl_status.h"
38
39 //Initialize Vendor Specific Extensions
40 void sl_bthci_init_vs(void);
41
42 void sl_bthci_init_upper(void);
43
44 void hci_enableVendorSpecificDebugging(void);
45
46 void hci_debugEnable(void);
47
48 sl_status_t hci_send_sleep_command_complete(void);
49
50 /**
51 * The Bluetooth controller receives a HCI message fragment from the host.
52 * The HCI transport can give the HCI message in fragments.
53 * @param[in] data Pointer to the received data.
54 * @param[in] len Length of the received data.
55 * @param[in] lastFragment Indicate whether this is the last
56 * fragment of an HCI message (true / false).
57 * @return 0 - success
58 * -1 - out of memory
59 * -2 - badly formatted message. */
60 int16_t sl_btctrl_hci_receive(uint8_t *data, int16_t len, bool lastFragment);
61
hci_common_transport_receive(uint8_t * data,int16_t len,bool lastFragment)62 static inline int16_t hci_common_transport_receive(uint8_t *data, int16_t len, bool lastFragment)
63 {
64 return sl_btctrl_hci_receive(data, len, lastFragment);
65 }
66
67 /**
68 * The HCI transport has transmitted a message.
69 * The HCI can transmit the next message after the transport
70 * has given this indication. */
71 void sl_btctrl_hci_transmit_complete(uint32_t status);
72
hci_common_transport_transmit_complete(uint32_t status)73 static inline void hci_common_transport_transmit_complete(uint32_t status)
74 {
75 sl_btctrl_hci_transmit_complete(status);
76 }
77
78 /**
79 * The HCI transport has been reconnected with the host.
80 * The HCI can transmit the next message after this function
81 * has been called. */
82 void sl_btctrl_hci_transmit_reconnected(void);
83
hci_common_transport_transmit_reconnected(void)84 static inline void hci_common_transport_transmit_reconnected(void)
85 {
86 sl_btctrl_hci_transmit_reconnected();
87 }
88
89 /**
90 * Host has sent HCI reset command callback handler.
91 * This is implemented as weak function and can be overridden by application to perform own activities before doing reset.
92 * It is also possible to call sl_btctrl_hard_reset to start hard reset procedure
93 *
94 * @return - true to progress with normal soft reset
95 * - false if normal reset procedure should be bypassed
96 */
97 bool sl_btctrl_reset_handler(void);
98
99 /**
100 * Hard reset device
101 * This is called from reset callback handler to implement hard reset
102 * If HCI packet is in middle of transmit to host, reset will be done after transmit is complete
103 */
104 void sl_btctrl_request_hard_reset(void);
105
106 void sl_btctrl_hci_parser_init_conn(void);
107
108 void sl_btctrl_hci_parser_init_subrate(void);
109
110 void sl_btctrl_hci_parser_init_adv(void);
111
112 void sl_btctrl_hci_parser_init_phy(void);
113
114 void sl_btctrl_hci_parser_init_past(void);
115
116 void sl_btctrl_hci_parser_init_privacy(void);
117
118 void sl_btctrl_hci_parser_init_cs(void);
119
120 void sl_btctrl_hci_parser_init_default(void);
121
122 void sl_btctrl_hci_parser_init_iso(void);
123
124 /**
125 * Create hardware error event and try to send it to the host.
126 * The created event shall be sent as high priority event.
127 * @param[in] errorCode Code describing the error. */
128 void sl_btctrl_hci_send_hardware_error_event(uint8_t errorCode);
129
130 #endif // _SL_BTCTRL_HCI_H_
131