• 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 #pragma once
19 
20 #include "config.h"
21 
22 //////////// product  Infomation  //////////////////////////////
23 #ifndef ID_VENDOR
24 #define ID_VENDOR 0x248a  // for report
25 #endif
26 #ifndef ID_PRODUCT_BASE
27 #define ID_PRODUCT_BASE 0x8800
28 #endif
29 #ifndef STRING_VENDOR
30 #define STRING_VENDOR L"Telink"
31 #endif
32 #ifndef STRING_PRODUCT
33 #define STRING_PRODUCT L"BLE 5.0"
34 #endif
35 
36 #ifndef STRING_SERIAL
37 #define STRING_SERIAL L"TLSR9518"
38 #endif
39 
40 #ifndef PM_DEEPSLEEP_RETENTION_ENABLE
41 #define PM_DEEPSLEEP_RETENTION_ENABLE 0
42 #endif
43 
44 #if (PM_DEEPSLEEP_RETENTION_ENABLE)
45 #define BLC_PM_EN                     1
46 #define BLC_PM_DEEP_RETENTION_MODE_EN 1
47 #endif
48 
49 #ifndef BLC_PM_EN
50 #define BLC_PM_EN 0
51 #endif
52 
53 #ifndef BLC_PM_DEEP_RETENTION_MODE_EN
54 #define BLC_PM_DEEP_RETENTION_MODE_EN 0
55 #endif
56 
57 #if (APPLICATION_DONGLE)
58 #ifndef MODULE_MOUSE_ENABLE
59 #define MODULE_MOUSE_ENABLE 0
60 #endif
61 #ifndef MODULE_KEYBOARD_ENABLE
62 #define MODULE_KEYBOARD_ENABLE 0
63 #endif
64 #ifndef MODULE_MIC_ENABLE
65 #define MODULE_MIC_ENABLE 0
66 #endif
67 #ifndef MODULE_SPEAKER_ENABLE
68 #define MODULE_SPEAKER_ENABLE 0  // device , not dongle
69 #endif
70 #ifndef MODULE_USB_ENABLE
71 #define MODULE_USB_ENABLE 1
72 #endif
73 #else
74 #ifndef MODULE_MOUSE_ENABLE
75 #define MODULE_MOUSE_ENABLE 1
76 #endif
77 #ifndef MODULE_KEYBOARD_ENABLE
78 #define MODULE_KEYBOARD_ENABLE 1
79 #endif
80 
81 #ifndef MODULE_MIC_ENABLE
82 #define MODULE_MIC_ENABLE 0
83 #endif
84 #ifndef MODULE_SPEAKER_ENABLE
85 #define MODULE_SPEAKER_ENABLE 0  // device , not dongle
86 #endif
87 
88 #ifndef MODULE_USB_ENABLE
89 #define MODULE_USB_ENABLE 0
90 #endif
91 #endif
92 
93 ///////////////////  USB   /////////////////////////////////
94 #ifndef IRQ_USB_PWDN_ENABLE
95 #define IRQ_USB_PWDN_ENABLE 0
96 #endif
97 
98 #ifndef USB_PRINTER_ENABLE
99 #define USB_PRINTER_ENABLE 0
100 #endif
101 #ifndef USB_SPEAKER_ENABLE
102 #define USB_SPEAKER_ENABLE 0
103 #endif
104 #ifndef USB_MIC_ENABLE
105 #define USB_MIC_ENABLE 0
106 #endif
107 #ifndef USB_MOUSE_ENABLE
108 #define USB_MOUSE_ENABLE 0
109 #endif
110 #ifndef USB_KEYBOARD_ENABLE
111 #define USB_KEYBOARD_ENABLE 0
112 #endif
113 #ifndef USB_SOMATIC_ENABLE
114 #define USB_SOMATIC_ENABLE 0
115 #endif
116 #ifndef USB_CUSTOM_HID_REPORT
117 #define USB_CUSTOM_HID_REPORT 0
118 #endif
119 #ifndef USB_AUDIO_441K_ENABLE
120 #define USB_AUDIO_441K_ENABLE 0
121 #endif
122 #ifndef USB_MASS_STORAGE_ENABLE
123 #define USB_MASS_STORAGE_ENABLE 0
124 #endif
125 #ifndef MIC_CHANNEL_COUNT
126 #define MIC_CHANNEL_COUNT 2
127 #endif
128 
129 #ifndef USB_DESCRIPTER_CONFIGURATION_FOR_KM_DONGLE
130 #define USB_DESCRIPTER_CONFIGURATION_FOR_KM_DONGLE 0
131 #endif
132 
133 #ifndef USB_ID_AND_STRING_CUSTOM
134 #define USB_ID_AND_STRING_CUSTOM 0
135 #endif
136 
137 #define KEYBOARD_RESENT_MAX_CNT    3
138 #define KEYBOARD_REPEAT_CHECK_TIME 300000  // in us
139 #define KEYBOARD_REPEAT_INTERVAL   100000  // in us
140 #define KEYBOARD_SCAN_INTERVAL     16000   // in us
141 #define MOUSE_SCAN_INTERVAL        8000    // in us
142 #define SOMATIC_SCAN_INTERVAL      8000
143 
144 #define USB_KEYBOARD_POLL_INTERVAL                                                                                    \
145     10  // in ms	USB_KEYBOARD_POLL_INTERVAL < KEYBOARD_SCAN_INTERVAL to ensure PC no missing key
146 #define USB_MOUSE_POLL_INTERVAL   4  // in ms
147 #define USB_SOMATIC_POLL_INTERVAL 8  // in ms
148 
149 #define USB_KEYBOARD_RELEASE_TIMEOUT (450000)  // in us
150 #define USB_MOUSE_RELEASE_TIMEOUT    (200000)  // in us
151 #define USB_SOMATIC_RELEASE_TIMEOUT  (200000)  // in us
152 
153 /*
154  * Default Link Layer Module Configuration
155  */
156 
157 #ifndef LL_MODULE_LEGACY_ADVERTISING_ENABLE
158 #define LL_MODULE_LEGACY_ADVERTISING_ENABLE 0
159 #endif
160 
161 #ifndef LL_MODULE_LEGACY_SCANNING_ENABLE
162 #define LL_MODULE_LEGACY_SCANNING_ENABLE 0
163 #endif
164 
165 #ifndef LL_MODULE_LEGACY_INITIATING_ENABLE
166 #define LL_MODULE_LEGACY_ADVERTISING_ENABLE 0
167 #endif
168 
169 #ifndef LL_MODULE_EXTENDED_ADVERTISING_ENABLE
170 #define LL_MODULE_EXTENDED_ADVERTISING_ENABLE 0
171 #endif
172 
173 #ifndef LL_MODULE_EXTENDED_SCANNING_ENABLE
174 #define LL_MODULE_EXTENDED_SCANNING_ENABLE 0
175 #endif
176 
177 #ifndef LL_MODULE_EXTENDED_INITIATING_ENABLE
178 #define LL_MODULE_EXTENDED_INITIATING_ENABLE 0
179 #endif
180 
181 #ifndef LL_MODULE_PERIODIC_ADVERTISING_ENABLE
182 #define LL_MODULE_PERIODIC_ADVERTISING_ENABLE 0
183 #endif
184 
185 #ifndef LL_MODULE_ACL_CONNECTION_ENABLE
186 #define LL_MODULE_ACL_CONNECTION_ENABLE 0
187 #endif
188 
189 #ifndef LL_MODULE_ACL_MASTER_ROLE_ENABLE
190 #define LL_MODULE_ACL_MASTER_ROLE_ENABLE 0
191 #endif
192 
193 #ifndef LL_MODULE_ACL_SLAVE_ROLE_ENABLE
194 #define LL_MODULE_ACL_SLAVE_ROLE_ENABLE 0
195 #endif
196 
197 #ifndef LL_MODULE_CIS_MASTER_ROLE_ENABLE
198 #define LL_MODULE_CIS_MASTER_ROLE_ENABLE 0
199 #endif
200 
201 #ifndef LL_MODULE_CIS_SLAVE_ROLE_ENABLE
202 #define LL_MODULE_CIS_SLAVE_ROLE_ENABLE 0
203 #endif
204 
205 #ifndef DEBUG_GPIO_ENABLE
206 #define DEBUG_GPIO_ENABLE 0
207 #endif
208 
209 #if (DEBUG_GPIO_ENABLE)
210 #ifdef GPIO_CHN0
211 #define DBG_CHN0_LOW    gpio_write(GPIO_CHN0, 0)
212 #define DBG_CHN0_HIGH   gpio_write(GPIO_CHN0, 1)
213 #define DBG_CHN0_TOGGLE gpio_toggle(GPIO_CHN0)
214 #else
215 #define DBG_CHN0_LOW
216 #define DBG_CHN0_HIGH
217 #define DBG_CHN0_TOGGLE
218 #endif
219 
220 #ifdef GPIO_CHN1
221 #define DBG_CHN1_LOW    gpio_write(GPIO_CHN1, 0)
222 #define DBG_CHN1_HIGH   gpio_write(GPIO_CHN1, 1)
223 #define DBG_CHN1_TOGGLE gpio_toggle(GPIO_CHN1)
224 #else
225 #define DBG_CHN1_LOW
226 #define DBG_CHN1_HIGH
227 #define DBG_CHN1_TOGGLE
228 #endif
229 
230 #ifdef GPIO_CHN2
231 #define DBG_CHN2_LOW    gpio_write(GPIO_CHN2, 0)
232 #define DBG_CHN2_HIGH   gpio_write(GPIO_CHN2, 1)
233 #define DBG_CHN2_TOGGLE gpio_toggle(GPIO_CHN2)
234 #else
235 #define DBG_CHN2_LOW
236 #define DBG_CHN2_HIGH
237 #define DBG_CHN2_TOGGLE
238 #endif
239 
240 #ifdef GPIO_CHN3
241 #define DBG_CHN3_LOW    gpio_write(GPIO_CHN3, 0)
242 #define DBG_CHN3_HIGH   gpio_write(GPIO_CHN3, 1)
243 #define DBG_CHN3_TOGGLE gpio_toggle(GPIO_CHN3)
244 #else
245 #define DBG_CHN3_LOW
246 #define DBG_CHN3_HIGH
247 #define DBG_CHN3_TOGGLE
248 #endif
249 
250 #ifdef GPIO_CHN4
251 #define DBG_CHN4_LOW    gpio_write(GPIO_CHN4, 0)
252 #define DBG_CHN4_HIGH   gpio_write(GPIO_CHN4, 1)
253 #define DBG_CHN4_TOGGLE gpio_toggle(GPIO_CHN4)
254 #else
255 #define DBG_CHN4_LOW
256 #define DBG_CHN4_HIGH
257 #define DBG_CHN4_TOGGLE
258 #endif
259 
260 #ifdef GPIO_CHN5
261 #define DBG_CHN5_LOW    gpio_write(GPIO_CHN5, 0)
262 #define DBG_CHN5_HIGH   gpio_write(GPIO_CHN5, 1)
263 #define DBG_CHN5_TOGGLE gpio_toggle(GPIO_CHN5)
264 #else
265 #define DBG_CHN5_LOW
266 #define DBG_CHN5_HIGH
267 #define DBG_CHN5_TOGGLE
268 #endif
269 
270 #ifdef GPIO_CHN6
271 #define DBG_CHN6_LOW    gpio_write(GPIO_CHN6, 0)
272 #define DBG_CHN6_HIGH   gpio_write(GPIO_CHN6, 1)
273 #define DBG_CHN6_TOGGLE gpio_toggle(GPIO_CHN6)
274 #else
275 #define DBG_CHN6_LOW
276 #define DBG_CHN6_HIGH
277 #define DBG_CHN6_TOGGLE
278 #endif
279 
280 #ifdef GPIO_CHN7
281 #define DBG_CHN7_LOW    gpio_write(GPIO_CHN7, 0)
282 #define DBG_CHN7_HIGH   gpio_write(GPIO_CHN7, 1)
283 #define DBG_CHN7_TOGGLE gpio_toggle(GPIO_CHN7)
284 #else
285 #define DBG_CHN7_LOW
286 #define DBG_CHN7_HIGH
287 #define DBG_CHN7_TOGGLE
288 #endif
289 
290 #ifdef GPIO_CHN8
291 #define DBG_CHN8_LOW    gpio_write(GPIO_CHN8, 0)
292 #define DBG_CHN8_HIGH   gpio_write(GPIO_CHN8, 1)
293 #define DBG_CHN8_TOGGLE gpio_toggle(GPIO_CHN8)
294 #else
295 #define DBG_CHN8_LOW
296 #define DBG_CHN8_HIGH
297 #define DBG_CHN8_TOGGLE
298 #endif
299 
300 #ifdef GPIO_CHN9
301 #define DBG_CHN9_LOW    gpio_write(GPIO_CHN9, 0)
302 #define DBG_CHN9_HIGH   gpio_write(GPIO_CHN9, 1)
303 #define DBG_CHN9_TOGGLE gpio_toggle(GPIO_CHN9)
304 #else
305 #define DBG_CHN9_LOW
306 #define DBG_CHN9_HIGH
307 #define DBG_CHN9_TOGGLE
308 #endif
309 
310 #ifdef GPIO_CHN10
311 #define DBG_CHN10_LOW    gpio_write(GPIO_CHN10, 0)
312 #define DBG_CHN10_HIGH   gpio_write(GPIO_CHN10, 1)
313 #define DBG_CHN10_TOGGLE gpio_toggle(GPIO_CHN10)
314 #else
315 #define DBG_CHN10_LOW
316 #define DBG_CHN10_HIGH
317 #define DBG_CHN10_TOGGLE
318 #endif
319 
320 #ifdef GPIO_CHN11
321 #define DBG_CHN11_LOW    gpio_write(GPIO_CHN11, 0)
322 #define DBG_CHN11_HIGH   gpio_write(GPIO_CHN11, 1)
323 #define DBG_CHN11_TOGGLE gpio_toggle(GPIO_CHN11)
324 #else
325 #define DBG_CHN11_LOW
326 #define DBG_CHN11_HIGH
327 #define DBG_CHN11_TOGGLE
328 #endif
329 
330 #ifdef GPIO_CHN12
331 #define DBG_CHN12_LOW    gpio_write(GPIO_CHN12, 0)
332 #define DBG_CHN12_HIGH   gpio_write(GPIO_CHN12, 1)
333 #define DBG_CHN12_TOGGLE gpio_toggle(GPIO_CHN12)
334 #else
335 #define DBG_CHN12_LOW
336 #define DBG_CHN12_HIGH
337 #define DBG_CHN12_TOGGLE
338 #endif
339 
340 #ifdef GPIO_CHN13
341 #define DBG_CHN13_LOW    gpio_write(GPIO_CHN13, 0)
342 #define DBG_CHN13_HIGH   gpio_write(GPIO_CHN13, 1)
343 #define DBG_CHN13_TOGGLE gpio_toggle(GPIO_CHN13)
344 #else
345 #define DBG_CHN13_LOW
346 #define DBG_CHN13_HIGH
347 #define DBG_CHN13_TOGGLE
348 #endif
349 
350 #ifdef GPIO_CHN14
351 #define DBG_CHN14_LOW    gpio_write(GPIO_CHN14, 0)
352 #define DBG_CHN14_HIGH   gpio_write(GPIO_CHN14, 1)
353 #define DBG_CHN14_TOGGLE gpio_toggle(GPIO_CHN14)
354 #else
355 #define DBG_CHN14_LOW
356 #define DBG_CHN14_HIGH
357 #define DBG_CHN14_TOGGLE
358 #endif
359 
360 #ifdef GPIO_CHN15
361 #define DBG_CHN15_LOW    gpio_write(GPIO_CHN15, 0)
362 #define DBG_CHN15_HIGH   gpio_write(GPIO_CHN15, 1)
363 #define DBG_CHN15_TOGGLE gpio_toggle(GPIO_CHN15)
364 #else
365 #define DBG_CHN15_LOW
366 #define DBG_CHN15_HIGH
367 #define DBG_CHN15_TOGGLE
368 #endif
369 #else
370 #define DBG_CHN0_LOW
371 #define DBG_CHN0_HIGH
372 #define DBG_CHN0_TOGGLE
373 #define DBG_CHN1_LOW
374 #define DBG_CHN1_HIGH
375 #define DBG_CHN1_TOGGLE
376 #define DBG_CHN2_LOW
377 #define DBG_CHN2_HIGH
378 #define DBG_CHN2_TOGGLE
379 #define DBG_CHN3_LOW
380 #define DBG_CHN3_HIGH
381 #define DBG_CHN3_TOGGLE
382 #define DBG_CHN4_LOW
383 #define DBG_CHN4_HIGH
384 #define DBG_CHN4_TOGGLE
385 #define DBG_CHN5_LOW
386 #define DBG_CHN5_HIGH
387 #define DBG_CHN5_TOGGLE
388 #define DBG_CHN6_LOW
389 #define DBG_CHN6_HIGH
390 #define DBG_CHN6_TOGGLE
391 #define DBG_CHN7_LOW
392 #define DBG_CHN7_HIGH
393 #define DBG_CHN7_TOGGLE
394 #define DBG_CHN8_LOW
395 #define DBG_CHN8_HIGH
396 #define DBG_CHN8_TOGGLE
397 #define DBG_CHN9_LOW
398 #define DBG_CHN9_HIGH
399 #define DBG_CHN9_TOGGLE
400 #define DBG_CHN10_LOW
401 #define DBG_CHN10_HIGH
402 #define DBG_CHN10_TOGGLE
403 #define DBG_CHN11_LOW
404 #define DBG_CHN11_HIGH
405 #define DBG_CHN11_TOGGLE
406 #define DBG_CHN12_LOW
407 #define DBG_CHN12_HIGH
408 #define DBG_CHN12_TOGGLE
409 #define DBG_CHN13_LOW
410 #define DBG_CHN13_HIGH
411 #define DBG_CHN13_TOGGLE
412 #define DBG_CHN14_LOW
413 #define DBG_CHN14_HIGH
414 #define DBG_CHN14_TOGGLE
415 #define DBG_CHN15_LOW
416 #define DBG_CHN15_HIGH
417 #define DBG_CHN15_TOGGLE
418 #endif
419