NEW: release DJI Payload-SDK version 3.5

Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
DJI-Martin
2023-05-18 21:30:44 +08:00
parent cae3123cda
commit caa15133cd
81 changed files with 558 additions and 176 deletions

View File

@ -28,6 +28,7 @@
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "stdlib.h"
/* Private constants ---------------------------------------------------------*/
#define SEM_MUTEX_WAIT_FOREVER 0xFFFFFFFF
@ -64,6 +65,10 @@ T_DjiReturnCode Osal_TaskCreate(const char *name, void *(*taskFunc)(void *), uin
T_DjiReturnCode Osal_TaskDestroy(T_DjiTaskHandle task)
{
if (task == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
vTaskDelete(task);
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -83,6 +88,10 @@ T_DjiReturnCode Osal_TaskSleepMs(uint32_t timeMs)
T_DjiReturnCode Osal_MutexCreate(T_DjiMutexHandle *mutex)
{
if (mutex == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
*mutex = xSemaphoreCreateMutex();
if (*mutex == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
@ -93,6 +102,10 @@ T_DjiReturnCode Osal_MutexCreate(T_DjiMutexHandle *mutex)
T_DjiReturnCode Osal_MutexDestroy(T_DjiMutexHandle mutex)
{
if (mutex == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
vQueueDelete((SemaphoreHandle_t) mutex);
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -117,6 +130,10 @@ T_DjiReturnCode Osal_MutexLock(T_DjiMutexHandle mutex)
T_DjiReturnCode Osal_MutexUnlock(T_DjiMutexHandle mutex)
{
if (mutex == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
if (xSemaphoreGive(mutex) != pdTRUE) {
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
@ -128,6 +145,10 @@ T_DjiReturnCode Osal_SemaphoreCreate(uint32_t initValue, T_DjiSemaHandle *semaph
{
uint32_t maxCount = UINT_MAX;
if (semaphore == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
*semaphore = xSemaphoreCreateCounting(maxCount, initValue);
if (*semaphore == NULL) {
@ -139,6 +160,10 @@ T_DjiReturnCode Osal_SemaphoreCreate(uint32_t initValue, T_DjiSemaHandle *semaph
T_DjiReturnCode Osal_SemaphoreDestroy(T_DjiSemaHandle semaphore)
{
if (semaphore == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
vSemaphoreDelete(semaphore);
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -177,6 +202,10 @@ T_DjiReturnCode Osal_SemaphoreWait(T_DjiSemaHandle semaphore)
T_DjiReturnCode Osal_SemaphorePost(T_DjiSemaHandle semaphore)
{
if (semaphore == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
if (xSemaphoreGive(semaphore) != pdTRUE) {
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
@ -186,6 +215,10 @@ T_DjiReturnCode Osal_SemaphorePost(T_DjiSemaHandle semaphore)
T_DjiReturnCode Osal_GetTimeMs(uint32_t *ms)
{
if (ms == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
*ms = xTaskGetTickCount();
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -193,11 +226,22 @@ T_DjiReturnCode Osal_GetTimeMs(uint32_t *ms)
T_DjiReturnCode Osal_GetTimeUs(uint64_t *us)
{
if (us == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
*us = xTaskGetTickCount() * 1000;
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
T_DjiReturnCode Osal_GetRandomNum(uint16_t *randomNum)
{
*randomNum = rand() % 65535;
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
void *Osal_Malloc(uint32_t size)
{
return pvPortMalloc(size);

View File

@ -43,35 +43,21 @@ extern "C" {
/* Exported functions --------------------------------------------------------*/
T_DjiReturnCode Osal_TaskCreate(const char *name, void *(*taskFunc)(void *), uint32_t stackSize,
void *arg, T_DjiTaskHandle *task);
T_DjiReturnCode Osal_TaskDestroy(T_DjiTaskHandle task);
T_DjiReturnCode Osal_TaskSleepMs(uint32_t timeMs);
T_DjiReturnCode Osal_MutexCreate(T_DjiMutexHandle *mutex);
T_DjiReturnCode Osal_MutexDestroy(T_DjiMutexHandle mutex);
T_DjiReturnCode Osal_MutexLock(T_DjiMutexHandle mutex);
T_DjiReturnCode Osal_MutexUnlock(T_DjiMutexHandle mutex);
T_DjiReturnCode Osal_SemaphoreCreate(uint32_t initValue, T_DjiSemaHandle *semaphore);
T_DjiReturnCode Osal_SemaphoreDestroy(T_DjiSemaHandle semaphore);
T_DjiReturnCode Osal_SemaphoreTimedWait(T_DjiSemaHandle semaphore, uint32_t waitTimeMs);
T_DjiReturnCode Osal_SemaphoreWait(T_DjiSemaHandle semaphore);
T_DjiReturnCode Osal_SemaphorePost(T_DjiSemaHandle semaphore);
T_DjiReturnCode Osal_GetTimeMs(uint32_t *ms);
T_DjiReturnCode Osal_GetTimeUs(uint64_t *us);
T_DjiReturnCode Osal_GetRandomNum(uint16_t *randomNum);
void *Osal_Malloc(uint32_t size);
void Osal_Free(void *ptr);
#ifdef __cplusplus