Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / EFR32 / freertos_bluetooth.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2020 Google LLC.
5  *    All rights reserved.
6  *
7  *    Licensed under the Apache License, Version 2.0 (the "License");
8  *    you may not use this file except in compliance with the License.
9  *    You may obtain a copy of the License at
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *    Unless required by applicable law or agreed to in writing, software
14  *    distributed under the License is distributed on an "AS IS" BASIS,
15  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *    See the License for the specific language governing permissions and
17  *    limitations under the License.
18  */
19
20 #pragma once
21
22 #if __cplusplus
23 extern "C" {
24 #endif
25
26 #include "FreeRTOS.h"
27 #include "event_groups.h"
28 #include "semphr.h"
29 #include "task.h"
30 #include "timers.h"
31
32 #include "sl_bt_api.h"
33
34 #define BLE_STACK_TASK_NAME "BLE_STACK"
35 #define BLE_LINK_TASK_NAME "BLE_LINK"
36
37 // Bluetooth event flag group
38 extern EventGroupHandle_t bluetooth_event_flags;
39 // Bluetooth event flag definitions
40 #define BLUETOOTH_EVENT_FLAG_STACK (0x01u)       // Bluetooth task needs an update
41 #define BLUETOOTH_EVENT_FLAG_LL (0x02u)          // Linklayer task needs an update
42 #define BLUETOOTH_EVENT_FLAG_CMD_WAITING (0x04u) // BGAPI command is waiting to be processed
43 #define BLUETOOTH_EVENT_FLAG_RSP_WAITING (0x08u) // BGAPI response is waiting to be processed
44 #define BLUETOOTH_EVENT_FLAG_EVT_WAITING (0x10u) // BGAPI event is waiting to be processed
45 #define BLUETOOTH_EVENT_FLAG_EVT_HANDLED (0x20u) // BGAPI event is handled
46
47 // Bluetooth event data pointer
48 extern volatile sl_bt_msg_t * bluetooth_evt;
49
50 // Function prototype for initializing Bluetooth stack.
51 typedef sl_status_t (*bluetooth_stack_init_func)();
52
53 /**
54  * Start Bluetooth tasks. The given Bluetooth stack initialization function
55  * will be called at a proper time. Application should not initialize
56  * Bluetooth stack anywhere else.
57  *
58  * @param ll_priority link layer task priority
59  * @param stack_priority Bluetooth stack task priority
60  * @param initialize_bluetooth_stack The function for initializing Bluetooth stack
61  */
62 sl_status_t bluetooth_start(UBaseType_t ll_priority, UBaseType_t stack_priority,
63                             bluetooth_stack_init_func initialize_bluetooth_stack);
64
65 // Set the callback for wakeup, Bluetooth task will call this when it has a new event
66 // It must only used to wake up application task, for example by posting task semaphore
67 typedef void (*wakeupCallback)(void);
68 void BluetoothSetWakeupCallback(wakeupCallback cb);
69 // Bluetooth stack needs an update
70 extern void BluetoothUpdate(void);
71 // Linklayer is updated
72 extern void BluetoothLLCallback(void);
73
74 // Mutex functions for using Bluetooth from multiple tasks
75 void BluetoothPend(void);
76 void BluetoothPost(void);
77
78 void vRaiseEventFlagBasedOnContext(EventGroupHandle_t xEventGroup, EventBits_t uxBitsToWaitFor);
79 BaseType_t vSendToQueueBasedOnContext(QueueHandle_t xQueue, void * xItemToQueue, TickType_t xTicksToWait,
80                                       BaseType_t * pxHigherPriorityTaskWoken);
81
82 #if __cplusplus
83 }
84 #endif