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

View File

@ -97,6 +97,7 @@ void DjiUser_StartTask(void const *argument)
.Free = Osal_Free,
.GetTimeMs = Osal_GetTimeMs,
.GetTimeUs = Osal_GetTimeUs,
.GetRandomNum = Osal_GetRandomNum,
};
T_DjiLoggerConsole printConsole = {
.func = DjiUser_PrintConsole,
@ -247,7 +248,8 @@ void DjiUser_StartTask(void const *argument)
#endif
#ifdef CONFIG_MODULE_SAMPLE_GIMBAL_EMU_ON
if (aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK
if ((aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M350_RTK)
&& aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_NONE) {
USER_LOG_WARN("Not support gimbal emu sample.");
} else {
@ -294,7 +296,8 @@ void DjiUser_StartTask(void const *argument)
#endif
#ifdef CONFIG_MODULE_SAMPLE_POSITIONING_ON
if (aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK
if ((aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M350_RTK)
&& aircraftInfoBaseInfo.mountPosition != DJI_MOUNT_POSITION_TYPE_EXTENSION_PORT) {
if (DjiTest_PositioningStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("psdk positioning init error");

View File

@ -40,7 +40,7 @@
#define UART1_WRITE_BUF_SIZE 64
#define UART2_READ_BUF_SIZE 64
#define UART2_WRITE_BUF_SIZE 2048
#define UART3_READ_BUF_SIZE 4096
#define UART3_READ_BUF_SIZE 8192
#define UART3_WRITE_BUF_SIZE 2048
/* Private macro -------------------------------------------------------------*/

View File

@ -81,11 +81,15 @@ T_DjiReturnCode DjiUpgradePlatformStm32_WriteUpgradeProgramFile(uint32_t offset,
{
uint32_t result;
__disable_irq();
result = FLASH_If_Write(APPLICATION_STORE_ADDRESS + offset, (uint8_t *) data, dataLen);
if (result != FLASHIF_OK) {
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
}
__enable_irq();
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}