• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
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 #ifndef _BLE_KE_MSG_TYPE_H
16 #define _BLE_KE_MSG_TYPE_H
17 
18 // Task State
19 typedef uint8_t ke_state_t;
20 
21 // Task Identifier. Composed by the task type and the task index.
22 typedef uint16_t ke_task_id_t;
23 
24 // Builds the task identifier from the type and the index of that task.
25 #define KE_BUILD_ID(type, index) ( (ke_task_id_t)(((index) << 8)|(type)) )
26 
27 // Retrieves task type from task id.
28 #define KE_TYPE_GET(ke_task_id) ((ke_task_id) & 0xFF)
29 
30 // Retrieves task index number from task id.
31 #define KE_IDX_GET(ke_task_id) (((ke_task_id) >> 8) & 0xFF)
32 
33 
34 // Message Identifier. The number of messages is limited to 0xFFFF.
35 // The message ID is divided in two parts:
36 // bits[15~8]: task index (no more than 255 tasks support)
37 // bits[7~0]: message index(no more than 255 messages per task)
38 typedef uint16_t ke_msg_id_t;
39 
40 #define KE_MSG_ALLOC(id, dest, src, param_str) \
41     (struct param_str*) ke_msg_alloc(id, dest, src, sizeof(struct param_str))
42 
43 #define KE_MSG_FREE(param_ptr) ke_msg_free(ke_param2msg((param_ptr)))
44 
45 #define KE_MSG_ALLOC_DYN(id, dest, src, param_str,length)  (struct param_str*)ke_msg_alloc(id, dest, src, \
46     (sizeof(struct param_str) + (length)));
47 
48 #endif // _BLE_KE_MSG_TYPE_H
49