• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 GOODIX.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "ohos_init.h"
17 #include "cmsis_os2.h"
18 #include "gr55xx_sys.h"
19 #include "scatter_common.h"
20 #include "flash_scatter_config.h"
21 #include "user_app.h"
22 #include "app_callback.h"
23 
24 #define BLE_TASK_STACK_SIZE   4096
25 #define BLE_TASK_PRIO         25
26 #define MS_1000     1000
27 
28 /**@brief Stack global variables for Bluetooth protocol stack. */
29 STACK_HEAP_INIT(heaps_table);
30 
31 static app_callback_t s_app_ble_callback = {
32     .app_ble_init_cmp_callback  = ble_init_cmp_callback,
33     .app_gap_callbacks          = &app_gap_callbacks,
34     .app_gatt_common_callback   = &app_gatt_common_callback,
35     .app_gattc_callback         = &app_gattc_callback,
36     .app_sec_callback           = &app_sec_callback,
37 };
38 
BLE_Task(const char * arg)39 static void *BLE_Task(const char *arg)
40 {
41     (void)arg;
42 
43     printf("Initialize the BLE stack.\r\n");
44 
45     /* init ble stack */
46     ble_stack_init(&s_app_ble_callback, &heaps_table);
47 
48     while (1) {
49         osDelay(MS_1000);
50     }
51 }
52 
BLE_TaskEntry(void)53 void BLE_TaskEntry(void)
54 {
55     osThreadAttr_t attr;
56 
57     attr.name       = "BLE_Task";
58     attr.attr_bits  = 0U;
59     attr.cb_mem     = NULL;
60     attr.cb_size    = 0U;
61     attr.stack_mem  = NULL;
62     attr.stack_size = BLE_TASK_STACK_SIZE;
63     attr.priority   = BLE_TASK_PRIO;
64 
65     if (osThreadNew((osThreadFunc_t)BLE_Task, NULL, &attr) == NULL) {
66         printf("[HelloDemo] Falied to create HelloTask!\n");
67     }
68 }
69 
70 SYS_RUN(BLE_TaskEntry);
71