• 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 _RTOS_OHOS_DEF_H
16 #define _RTOS_OHOS_DEF_H
17 
18 /*
19  * INCLUDE FILES
20  ****************************************************************************************
21  */
22 #include "cmsis_os2.h"
23 #include "los_swtmr.h"
24 #include "los_tick.h"
25 #include "los_memory.h"
26 #include "los_task.h"
27 
28 /*
29  * DEFINITIONS
30  ****************************************************************************************
31  */
32 typedef long BaseType_t;
33 typedef unsigned long UBaseType_t;
34 typedef uint32_t TickType_t;
35 
36 #define pdFALSE    ( ( BaseType_t ) 0 )
37 #define pdTRUE     ( ( BaseType_t ) 1 )
38 /// RTOS task handle
39 //typedef TaskHandle_t   rtos_task_handle;
40 typedef osThreadId_t rtos_task_handle;
41 
42 /// RTOS priority
43 //typedef UBaseType_t         rtos_prio;
44 typedef osPriority_t   rtos_prio;
45 
46 /// RTOS task function
47 //typedef TaskFunction_t      rtos_task_fct;
48 typedef osThreadFunc_t  rtos_task_fct;
49 
50 /// RTOS queue
51 //typedef QueueHandle_t       rtos_queue;
52 typedef osMessageQueueId_t  rtos_queue;
53 
54 /// RTOS semaphore
55 //typedef SemaphoreHandle_t   rtos_semaphore;
56 typedef osSemaphoreId_t rtos_semaphore;
57 
58 /// RTOS mutex
59 //typedef SemaphoreHandle_t   rtos_mutex;
60 typedef osMutexId_t rtos_mutex;
61 
62 /// RTOS event group
63 //typedef EventGroupHandle_t  rtos_event_group;
64 
65 /// RTOS scheduler state
66 typedef BaseType_t  rtos_sched_state;
67 
68 typedef osTimerId_t TimerHandle_t;
69 
70 typedef void (*TimerCallbackFunction_t)(TimerHandle_t xTimer);
71 /*
72  * MACROS
73  ****************************************************************************************
74  */
75 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
76 
77 /// Macro building the prototype of a RTOS task function
78 #define RTOS_TASK_FCT(name)        portTASK_FUNCTION(name, env)
79 
80 /// Macro building a task priority as an offset of the IDLE task priority
81 #define RTOS_TASK_PRIORITY(prio)  (osPriorityNormal + (prio))
82 
83 /// Macro defining a null RTOS task handle
84 #define RTOS_TASK_NULL     NULL
85 #define configTICK_RATE_HZ ((TickType_t)1000)
86 #define portMAX_DELAY      osWaitForever
87 
88 #define pdMS_TO_TICKS LOS_MS2Tick
89 
90 
91 #endif // _RTOS_OHOS_DEF_H
92