• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************/
18 #ifndef LL_H_
19 #define LL_H_
20 
21 /**
22  * @brief	Telink defined LinkLayer Event Callback
23  */
24 typedef void (*blt_event_callback_t)(u8 e, u8 *p, int n);
25 
26 typedef enum {
27     BLT_EV_FLAG_ADV_DURATION_TIMEOUT = 0,
28     BLT_EV_FLAG_RX_DATA_ABANDOM,
29     BLT_EV_FLAG_GPIO_EARLY_WAKEUP,
30     BLT_EV_FLAG_SLEEP_ENTER,
31     BLT_EV_FLAG_SUSPEND_EXIT,
32     BLT_EV_FLAG_KEY_MISSING,
33     BLT_EV_MAX_NUM,
34 } blt_ev_flag_t;
35 
36 typedef enum {
37     LL_FEATURE_ENABLE = 1,
38     LL_FEATURE_DISABLE = 0,
39 } ll_feature_value_t;
40 
41 /**
42  * @brief	Telink defined LinkLayer Event callBack
43  * @param[in]	e - event number, must use element of "blt_ev_flag_t"
44  * @param[in]	p - callBack function
45  * @return	none
46  */
47 void blc_ll_registerTelinkControllerEventCallback(u8 e, blt_event_callback_t p);
48 
49 /**
50  * @brief	irq_handler for BLE stack, process system tick interrupt and RF interrupt
51  * @param	none
52  * @return	none
53  */
54 void blc_sdk_irq_handler(void);
55 
56 /**
57  * @brief   main_loop for BLE stack, process data and event
58  * @param	none
59  * @return	none
60  */
61 void blc_sdk_main_loop(void);
62 
63 /**
64  * @brief      for user to initialize MCU
65  * @param	   none
66  * @return     none
67  */
68 void blc_ll_initBasicMCU(void);
69 
70 /**
71  * @brief      for user to initialize link layer Standby state
72  * @param	   none
73  * @return     none
74  */
75 void blc_ll_initStandby_module(u8 *public_adr);
76 
77 /**
78  * @brief      this function is used to read MAC address
79  * @param[in]  *addr -  The address where the read value(MAC address) prepare to write.
80  * @return     status, 0x00:  succeed
81  * 					   other: failed
82  */
83 ble_sts_t blc_ll_readBDAddr(u8 *addr);
84 
85 /**
86  * @brief      this function is used to set the LE Random Device Address in the Controller
87  * @param[in]  *randomAddr -  Random Device Address
88  * @return     status, 0x00:  succeed
89  * 					   other: failed
90  */
91 ble_sts_t blc_ll_setRandomAddr(u8 *randomAddr);
92 
93 /**
94  * @brief      This function is used to check if the address's type is public
95  * @param[in]  *addr -  The address need to check.
96  * @return     bool, 0x00: no public, 0x01: Public
97  */
98 bool blc_ll_isValidPublicAddr(u8 *addr);
99 
100 /**
101  * @brief      This function is used to check if the address's type is random
102  * @param[in]  *addr -  The address need to check.
103  * @return     bool, 0x00: no random, 0x01: random
104  */
105 bool blc_ll_isValidRandomAddr(u8 *addr);
106 
107 /**
108  * @brief      This function is used to check if owner's address type is valid
109  * @param[in]  ownAddrType -  Owner address type.
110  * @param[in]  randomAddr -  If Owner's address type is Random, input Random address.
111  * @return     bool, 0x00: invalid, 0x01: valid
112  */
113 bool blc_ll_isValidOwnAddrByAddrType(u8 ownAddrType, u8 *randomAddr);
114 
115 /**
116  * @brief      this function is used by the Host to specify a channel classification based on its local information,
117  *             only the master role is valid.
118  * @param[in]  bit_number - Bit position in the FeatureSet.
119  * @param[in]  bit_value - refer to the struct "ll_feature_value_t".
120  * @return     status, 0x00:  succeed
121  * 			           other: failed
122  */
123 ble_sts_t blc_hci_le_setHostFeature(u8 bit_number, ll_feature_value_t bit_value);
124 
125 /**
126  * @brief      this function is used check if any controller buffer initialized by application incorrect.
127  * 			   attention: this function must be called at the end of BLE LinkLayer Initialization.
128  * @param	   none
129  * @return     status, 0x00:  succeed, no buffer error
130  * 					   other: buffer error code
131  */
132 ble_sts_t blc_controller_check_appBufferInitialization(void);
133 
134 /**
135  * @brief      this function is used by the Host to specify a channel classification based on its local information,
136  *             only the master role is valid.
137  * @param[in]  *map - channel map
138  * @return     status, 0x00:  succeed
139  * 			           other: failed
140  */
141 ble_sts_t blc_ll_setHostChannel(u8 *chnMap);
142 
143 /**
144  * @brief      this function is used to reset module of all.
145  * @param	   none
146  * @return     status, 0x00:  succeed, no buffer error
147  * 					   other: buffer error code
148  */
149 ble_sts_t blc_hci_reset(void);
150 ble_sts_t blc_hci_le_getRemoteSupportedFeatures(u16 connHandle);
151 ble_sts_t blc_hci_le_readChannelMap(u16 connHandle, u8 *returnChannelMap);
152 
153 /**
154  * @brief      this function checks whether the Bluetooth stack task is IDLE
155  * @param	   none
156  * @return     bool, 0:  task running
157  *                   1:  idle
158  */
159 bool blc_ll_isBleTaskIdle(void);
160 
161 #endif /* LL_H_ */
162