psdk_platform.h
8.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/**
********************************************************************
* @file psdk_platform.h
* @brief This is the header file for define PSDK platform interfaces.
*
* @copyright (c) 2021 DJI. All rights reserved.
*
* All information contained herein is, and remains, the property of DJI.
* The intellectual and technical concepts contained herein are proprietary
* to DJI and may be covered by U.S. and foreign patents, patents in process,
* and protected by trade secret or copyright law. Dissemination of this
* information, including but not limited to data and other proprietary
* material(s) incorporated within the information, in any form, is strictly
* prohibited without the express written consent of DJI.
*
* If you receive this source code without DJI’s authorization, you may not
* further disseminate the information, and you must immediately remove the
* source code and notify DJI of its removal. DJI reserves the right to pursue
* legal actions against you for any loss(es) or damage(s) caused by your
* failure to do so.
*
*********************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef PSDK_PLATFORM_H
#define PSDK_PLATFORM_H
/* Includes ------------------------------------------------------------------*/
#include "legacy_psdk2.x/psdk_typedef.h"
#include "dji_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Exported constants --------------------------------------------------------*/
/**
* @brief Platform handle of thread task operation.
*/
typedef T_DjiTaskHandle T_PsdkTaskHandle;
/**
* @brief Platform handle of mutex operation.
*/
typedef T_DjiMutexHandle T_PsdkMutexHandle;
/**
* @brief Platform handle of semaphore operation.
*/
typedef T_DjiSemaHandle T_PsdkSemHandle;
/* Exported types ------------------------------------------------------------*/
typedef T_DjiHalUartHandler T_PsdkHalUartHandler;
typedef T_DjiHalNetworkHandler T_PsdkHalNetWorkHandler;
typedef T_DjiOsalHandler T_PsdkOsalHandler;
/* Exported functions --------------------------------------------------------*/
/**
* @brief Register the handler for hal uart interfaces by your platform.
* @note It should be noted that the interface in hal is written and tested well. Users need to implement all the
* interfaces. Otherwise, the user interface cannot be successfully registered, and then the user interface is registered
* through the interface. If the registration fails, it needs to be based on the return code. To judge the problem. Make
* sure that the feature is available after a successful registration. The interface needs to be called at the beginning of
* the application for registration, otherwise, the subsequent functions will not work properly.
* @param halUartHandler: pointer to the handler for hal uart interfaces by your platform.
* @return Execution result.
*/
T_PsdkReturnCode PsdkPlatform_RegHalUartHandler(const T_PsdkHalUartHandler *halUartHandler);
/**
* @brief Register the handler for osal interfaces by your platform.
* @note It should be noted that the interface in osal is written and tested well. Users need to implement all the
* interfaces. Otherwise, the user interface cannot be successfully registered, and then the user interface is registered
* through the interface. If the registration fails, it needs to be based on the return code. To judge the problem. Make
* sure that the feature is available after a successful registration. The interface needs to be called at the beginning of
* the application for registration, otherwise, the subsequent functions will not work properly.
* @param osalHandler: pointer to the handler for osal interfaces by your platform.
* @return Execution result.
*/
T_PsdkReturnCode PsdkPlatform_RegOsalHandler(const T_PsdkOsalHandler *osalHandler);
/**
* @brief Register the handler for hal network interfaces by your platform.
* @note It should be noted that the interface in hal is written and tested well. Users need to implement all the
* interfaces. Otherwise, the user interface cannot be successfully registered, and then the user interface is registered
* through the interface. If the registration fails, it needs to be based on the return code. To judge the problem. Make
* sure that the feature is available after a successful registration.
* @attention The interface needs to be called at the beginning of the application for registration, otherwise, the
* subsequent functions will not work properly.
* @param osalHandler: pointer to the handler for network handler interfaces by your platform.
* @return Execution result.
*/
T_PsdkReturnCode PsdkPlatform_RegHalNetworkHandler(const T_PsdkHalNetWorkHandler *halNetWorkHandler);
/**
* @brief Declare the task container, initialize the task, and create task ID.
* @param task: pointer to the created task ID.
* @param taskFunc: pointer to the created task function.
* @param name: pointer to task name string, end with '\0'. If user do not specify name for task, fill in NULL.
* @param stackSize: value of task stack size, unit: byte.
* @param arg: pointer to the user defined data.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_TaskCreate(T_PsdkTaskHandle *task, void *(*taskFunc)(void *), const char *name,
uint32_t stackSize, void *arg);
/**
* @brief Destroy the created task.
* @param task: pointer to the created task ID.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_TaskDestroy(T_PsdkTaskHandle task);
/**
* @brief Let task into a sleep state in a set time, uint:ms.
* @param timeMs: value of time ms for task sleeping.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_TaskSleepMs(uint32_t timeMs);
/**
* @brief Declare the mutex container, initialize the mutex, and create mutex ID.
* @param mutex: pointer to the created mutex ID.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_MutexCreate(T_PsdkMutexHandle *mutex);
/**
* @brief Destroy the created mutex.
* @param mutex: pointer to the created mutex ID.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_MutexDestroy(T_PsdkMutexHandle mutex);
/**
* @brief Acquire and lock the mutex when peripheral access is required.
* @param mutex: pointer to the created mutex ID.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_MutexLock(T_PsdkMutexHandle mutex);
/**
* @brief Unlock and release the mutex when done with the peripheral access.
* @param mutex: pointer to the created mutex ID.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_MutexUnlock(T_PsdkMutexHandle mutex);
/**
* @brief Declare the semaphore container, initialize the semaphore, and create semaphore ID.
* @param semaphore: pointer to the created semaphore ID.
* @param initValue: init value of semaphore for the created semaphore.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_SemaphoreCreate(T_PsdkSemHandle *semaphore, uint32_t initValue);
/**
* @brief Destroy the created semaphore.
* @param semaphore: pointer to the created semaphore ID.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_SemaphoreDestroy(T_PsdkSemHandle semaphore);
/**
* @brief Wait the created semaphore forever.
* @param semaphore: pointer to the created semaphore ID.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_SemaphoreWait(T_PsdkSemHandle semaphore);
/**
* @brief Wait the created semaphore and set the value of timeout.
* @param semaphore: pointer to the created semaphore ID.
* @param waitTimeMs: value of timeout for waiting created semaphore.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_SemaphoreTimedWait(T_PsdkSemHandle semaphore, uint32_t waitTimeMs);
/**
* @brief Post the created semaphore.
* @param semaphore: pointer to the created semaphore ID.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_SemaphorePost(T_PsdkSemHandle semaphore);
/**
* @brief Get the system millisecond time, uint:ms.
* @param ms: pointer to the got time ms.
* @return Execution result.
*/
T_PsdkReturnCode PsdkOsal_GetTimeMs(uint32_t *ms);
/**
* @brief Allocate size bytes of memory.
* @note Users need to apply for memory according to the actual situation of the platform and application. If you do not
* use the memory after applying for it, please call #PsdkOsal_Free to release the memory.
* @param size: uint32_t size that needs allocate.
* @return a void pointer to the allocated memory, if equal to NULL, please do related processing to avoid null pointer crash.
*/
void *PsdkOsal_Malloc(uint32_t size);
/**
* @brief Release allocated memory.
* @note After calling the #PsdkOsal_Malloc interface, if you do not use memory, please remember to use this interface
* to release the memory.
* @param ptr: pointer to the need allocated memory.
*/
void PsdkOsal_Free(void *ptr);
#ifdef __cplusplus
}
#endif
#endif // PSDK_PLATFORM_H
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/