NEW: sync the code of DJI Payload-SDK version 2.2.1 released on January 20 2021.
Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
186
sample/platform/rtos_freertos/stm32f4_eval/application/FreeRTOSConfig.h
Executable file
186
sample/platform/rtos_freertos/stm32f4_eval/application/FreeRTOSConfig.h
Executable file
@ -0,0 +1,186 @@
|
||||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
/* Section where include file can be added */
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Ensure stdint is only used by the compiler, and not the assembler. */
|
||||
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern uint32_t SystemCoreClock;
|
||||
#endif
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configSUPPORT_STATIC_ALLOCATION 0
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||
#define configTICK_RATE_HZ ((TickType_t)1000)
|
||||
#define configMAX_PRIORITIES ( 7 )
|
||||
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
|
||||
#define configTOTAL_HEAP_SIZE ((size_t)61440)
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 8
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configUSE_MALLOC_FAILED_HOOK 0
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#define configGENERATE_RUN_TIME_STATS 1
|
||||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 0
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
|
||||
/* Cortex-M specific definitions. */
|
||||
#ifdef __NVIC_PRIO_BITS
|
||||
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
||||
#define configPRIO_BITS __NVIC_PRIO_BITS
|
||||
#else
|
||||
#define configPRIO_BITS 4
|
||||
#endif
|
||||
|
||||
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
||||
function. */
|
||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
|
||||
|
||||
/* The highest interrupt priority that can be used by any interrupt service
|
||||
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
|
||||
|
||||
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
||||
to all Cortex-M ports, and do not rely on any particular library functions. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
|
||||
/* Normal assert() semantics without relying on the provision of an assert.h
|
||||
header file. */
|
||||
/* USER CODE BEGIN 1 */
|
||||
#define configASSERT(x) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
|
||||
standard names. */
|
||||
#define vPortSVCHandler SVC_Handler
|
||||
#define xPortPendSVHandler PendSV_Handler
|
||||
|
||||
/* IMPORTANT: This define MUST be commented when used with STM32Cube firmware,
|
||||
to prevent overwriting SysTick_Handler defined within STM32Cube HAL */
|
||||
/* #define xPortSysTickHandler SysTick_Handler */
|
||||
|
||||
/* USER CODE BEGIN Defines */
|
||||
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
|
||||
|
||||
//define for freertos cli
|
||||
#define configCOMMAND_INT_MAX_OUTPUT_SIZE 128
|
||||
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() xTaskGetTickCount()
|
||||
|
||||
/* USER CODE END Defines */
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
57
sample/platform/rtos_freertos/stm32f4_eval/application/app_info.h
Executable file
57
sample/platform/rtos_freertos/stm32f4_eval/application/app_info.h
Executable file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file app_info.h
|
||||
* @version V2.0.0
|
||||
* @date 2019/07/01
|
||||
* @brief This is the header file for "app_info.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2018-2019 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 APP_INFO_H
|
||||
#define APP_INFO_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
// ATTENTION: User must goto developer.dji.com to create your own payload sdk application, get payload sdk application
|
||||
// information then fill in the application information here.
|
||||
#define USER_APP_NAME "your_app_name"
|
||||
#define USER_APP_ID "your_app_id"
|
||||
#define USER_APP_KEY "your_app_key"
|
||||
#define USER_DEVELOPER_ACCOUNT "your_developer_account"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //APP_INFO_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
477
sample/platform/rtos_freertos/stm32f4_eval/application/application.c
Executable file
477
sample/platform/rtos_freertos/stm32f4_eval/application/application.c
Executable file
@ -0,0 +1,477 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file application.c
|
||||
* @version V2.0.0
|
||||
* @date 2019/8/23
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2018-2019 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.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <upgrade/test_upgrade_platform_opt.h>
|
||||
#include <upgrade_platform_opt_stm32.h>
|
||||
#include <upgrade/test_upgrade.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "task.h"
|
||||
#include "uart.h"
|
||||
#include "apply_high_power.h"
|
||||
#include "pps.h"
|
||||
#include "application.h"
|
||||
#include "app_info.h"
|
||||
#include "psdk_config.h"
|
||||
#include "psdk_core.h"
|
||||
#include "psdk_logger.h"
|
||||
#include "psdk_platform.h"
|
||||
#include "hal/hal_uart.h"
|
||||
#include "osal/osal.h"
|
||||
#include "psdk_aircraft_info.h"
|
||||
#include "camera_emu/test_payload_cam_emu.h"
|
||||
#include "positioning/test_positioning.h"
|
||||
#include "power_management/test_power_management.h"
|
||||
#include "psdk_power_management.h"
|
||||
#include "utils/util_misc.h"
|
||||
#include "data_transmission/test_data_transmission.h"
|
||||
#include "data_subscription/test_data_subscription.h"
|
||||
#include "widget/test_widget.h"
|
||||
#include "payload_collaboration/test_payload_collaboration.h"
|
||||
#include "gimbal_emu/test_payload_gimbal_emu.h"
|
||||
#include "xport/test_xport.h"
|
||||
#include "utils/util_misc.h"
|
||||
#include "psdk_product_info.h"
|
||||
#include "time_synchronization/test_time_sync.h"
|
||||
#include "data_channel/test_data_channel.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define PSDK_CONSOLE_UART_NUM UART_NUM_2
|
||||
#define PSDK_CONSOLE_UART_BAUD 921600
|
||||
|
||||
#define PSDK_COMM_WITH_LINUX_UART_NUM UART_NUM_1
|
||||
#define PSDK_COMM_WITH_LINUX_UART_BAUD 115200
|
||||
#define PSDK_NETWORK_INFO_CMD_MAX_SIZE 64
|
||||
|
||||
#define RUN_INDICATE_TASK_FREQ_1HZ 1
|
||||
#define RUN_INDICATE_TASK_FREQ_0D1HZ 0.1f
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
static char s_networkLocalIpAddress[PSDK_IP_ADDR_STR_SIZE_MAX] = {0};
|
||||
static char s_networkConfigMask[PSDK_IP_ADDR_STR_SIZE_MAX] = {0};
|
||||
static bool s_psdkInitFinished = false;
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_PsdkReturnCode PsdkUser_FillInUserInfo(T_PsdkUserInfo *userInfo);
|
||||
static T_PsdkReturnCode PsdkUser_Console(const uint8_t *data, uint16_t dataLen);
|
||||
static T_PsdkReturnCode PsdkUser_NetWorkConfig(const char *ipAddr, const char *netMask);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
void PsdkUser_StartTask(void const *argument)
|
||||
{
|
||||
T_PsdkUserInfo userInfo;
|
||||
const T_PsdkDataChannelBandwidthProportionOfHighspeedChannel bandwidthProportionOfHighspeedChannel =
|
||||
{40, 60, 0};
|
||||
T_PsdkLoggerConsole printConsole = {
|
||||
.consoleLevel = PSDK_LOGGER_CONSOLE_LOG_LEVEL_INFO,
|
||||
.func = PsdkUser_Console,
|
||||
};
|
||||
|
||||
T_PsdkHalUartHandler halUartHandler = {
|
||||
.UartInit = Hal_UartInit,
|
||||
.UartWriteData = Hal_UartSendData,
|
||||
.UartReadData = Hal_UartReadData,
|
||||
};
|
||||
|
||||
T_PsdkOsalHandler osalHandler = {
|
||||
.TaskCreate = Osal_TaskCreate,
|
||||
.TaskDestroy = Osal_TaskDestroy,
|
||||
.TaskSleepMs = Osal_TaskSleepMs,
|
||||
.MutexCreate = Osal_MutexCreate,
|
||||
.MutexDestroy = Osal_MutexDestroy,
|
||||
.MutexLock = Osal_MutexLock,
|
||||
.MutexUnlock = Osal_MutexUnlock,
|
||||
.SemaphoreCreate = Osal_SemaphoreCreate,
|
||||
.SemaphoreDestroy = Osal_SemaphoreDestroy,
|
||||
.SemaphoreWait = Osal_SemaphoreWait,
|
||||
.SemaphoreTimedWait = Osal_SemaphoreTimedWait,
|
||||
.SemaphorePost = Osal_SemaphorePost,
|
||||
.GetTimeMs = Osal_GetTimeMs,
|
||||
.Malloc = Osal_Malloc,
|
||||
.Free = Osal_Free,
|
||||
};
|
||||
|
||||
T_PsdkHalNetWorkHandler networkHandler = {
|
||||
.NetWorkConfig = PsdkUser_NetWorkConfig,
|
||||
};
|
||||
|
||||
#ifdef PSDK_USING_POWER_MANAGEMENT
|
||||
T_PsdkTestApplyHighPowerHandler applyHighPowerHandler = {
|
||||
.pinInit = PsdkTest_HighPowerApplyPinInit,
|
||||
.pinWrite = PsdkTest_WriteHighPowerApplyPin,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_TIME_SYNC
|
||||
T_PsdkTestTimeSyncHandler timeSyncHandler = {
|
||||
.PpsSignalResponseInit = PsdkTest_PpsSignalResponseInit,
|
||||
.GetNewestPpsTriggerLocalTimeUs = PsdkTest_GetNewestPpsTriggerLocalTimeUs,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_UPGRADE
|
||||
T_PsdkTestUpgradePlatformOpt stm32UpgradePlatformOpt = {
|
||||
.rebootSystem = PsdkUpgradePlatformStm32_RebootSystem,
|
||||
.cleanUpgradeProgramFileStoreArea = PsdkUpgradePlatformStm32_CleanUpgradeProgramFileStoreArea,
|
||||
.createUpgradeProgramFile = PsdkUpgradePlatformStm32_CreateUpgradeProgramFile,
|
||||
.writeUpgradeProgramFile = PsdkUpgradePlatformStm32_WriteUpgradeProgramFile,
|
||||
.readUpgradeProgramFile = PsdkUpgradePlatformStm32_ReadUpgradeProgramFile,
|
||||
.closeUpgradeProgramFile = PsdkUpgradePlatformStm32_CloseUpgradeProgramFile,
|
||||
.replaceOldProgram = PsdkUpgradePlatformStm32_ReplaceOldProgram,
|
||||
.setUpgradeRebootState = PsdkUpgradePlatformStm32_SetUpgradeRebootState,
|
||||
.getUpgradeRebootState = PsdkUpgradePlatformStm32_GetUpgradeRebootState,
|
||||
.cleanUpgradeRebootState = PsdkUpgradePlatformStm32_CleanUpgradeRebootState,
|
||||
};
|
||||
#endif
|
||||
|
||||
T_PsdkAircraftInfoBaseInfo aircraftBaseInfo = {0};
|
||||
|
||||
USER_UTIL_UNUSED(argument);
|
||||
|
||||
UART_Init(PSDK_CONSOLE_UART_NUM, PSDK_CONSOLE_UART_BAUD);
|
||||
UART_Init(PSDK_COMM_WITH_LINUX_UART_NUM, PSDK_COMM_WITH_LINUX_UART_BAUD);
|
||||
|
||||
if (PsdkPlatform_RegHalUartHandler(&halUartHandler) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
goto out;
|
||||
|
||||
if (PsdkPlatform_RegOsalHandler(&osalHandler) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
goto out;
|
||||
|
||||
if (PsdkPlatform_RegHalNetworkHandler(&networkHandler) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
goto out;
|
||||
|
||||
if (PsdkLogger_AddConsole(&printConsole) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
goto out;
|
||||
|
||||
if (PsdkUser_FillInUserInfo(&userInfo) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk fill in user info error");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (PsdkCore_Init(&userInfo) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk instance init error");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (PsdkProductInfo_SetAlias("PSDK_APPALIAS") != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("set product alias error.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (PsdkAircraftInfo_GetBaseInfo(&aircraftBaseInfo) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("get aircraft information error.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (PsdkTest_DataChannelSetBandwidthProportionForHighspeedChannel(
|
||||
bandwidthProportionOfHighspeedChannel) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("set bandwidth distribution for high-speed channel error");
|
||||
}
|
||||
|
||||
#ifdef PSDK_USING_POWER_MANAGEMENT
|
||||
if (PsdkTest_RegApplyHighPowerHandler(&applyHighPowerHandler) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("regsiter apply high power handler error");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (PsdkTest_PowerManagementInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("power management init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_CAMERA_EMU
|
||||
if (PsdkTest_CameraInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk camera init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_DATA_TRANSMISSION
|
||||
if (PsdkTest_DataTransmissionInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk data transmission init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_DATA_SUBSCRIPTION
|
||||
if (PsdkTest_DataSubscriptionInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk data subscription init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_WIDGET
|
||||
if (PsdkTest_WidgetInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk widget init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_TIME_SYNC
|
||||
if (aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M210RTK_V2 ||
|
||||
aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M300_RTK) {
|
||||
if (PsdkTest_TimeSyncRegHandler(&timeSyncHandler) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("regsiter time sync handler error");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (PsdkTest_TimeSyncInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk time sync init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_POSITIONING
|
||||
if (aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M210RTK_V2 ||
|
||||
aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M300_RTK) {
|
||||
if (PsdkTest_PositioningInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk positioning init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_PAYLOAD_COLLABORATION
|
||||
if (((aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M200_V2 ||
|
||||
aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M210_V2 ||
|
||||
aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M210RTK_V2) &&
|
||||
aircraftBaseInfo.payloadMountPosition == PSDK_AIRCRAFT_INFO_PAYLOAD_MOUNT_POSITION_NO2) ||
|
||||
aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M300_RTK) {
|
||||
if (PsdkTest_PayloadCollaborationInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk payload collaboration init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_GIMBAL_EMU
|
||||
if (aircraftBaseInfo.psdkAdapterType == PSDK_AIRCRAFT_INFO_PSDK_ADAPTER_TYPE_SKYPORT_V2) {
|
||||
if (PsdkTest_GimbalInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk gimbal init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_XPORT
|
||||
if (aircraftBaseInfo.psdkAdapterType == PSDK_AIRCRAFT_INFO_PSDK_ADAPTER_TYPE_XPORT) {
|
||||
if (PsdkTest_XPortInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk XPort init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PSDK_USING_UPGRADE
|
||||
if (PsdkTest_UpgradeInit(&stm32UpgradePlatformOpt) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk upgrade init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (PsdkCore_ApplicationStart() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("psdk application start error");
|
||||
}
|
||||
|
||||
PsdkLogger_UserLogInfo("psdk init ok");
|
||||
s_psdkInitFinished = true;
|
||||
|
||||
out:
|
||||
vTaskDelete(xTaskGetCurrentTaskHandle());
|
||||
}
|
||||
|
||||
#ifndef __CC_ARM
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
|
||||
#pragma GCC diagnostic ignored "-Wreturn-type"
|
||||
#endif
|
||||
|
||||
void PsdkUser_RunIndicateTask(void const *argument)
|
||||
{
|
||||
int32_t i = 0;
|
||||
int32_t j = 0;
|
||||
static uint32_t runIndicateTaskStep = 0;
|
||||
T_UartBufferState readBufferState = {0};
|
||||
T_UartBufferState writeBufferState = {0};
|
||||
TaskStatus_t *lastTaskStatusArray = NULL;
|
||||
TaskStatus_t *currentTaskStatusArray = NULL;
|
||||
uint8_t lastTaskStatusArraySize = 0;
|
||||
uint8_t currentTaskStatusArraySize = 0;
|
||||
uint8_t cpuOccupyPercentage = 0;
|
||||
|
||||
char networkInfoCmd[PSDK_NETWORK_INFO_CMD_MAX_SIZE] = {0};
|
||||
T_PsdkReturnCode returnCode;
|
||||
char ipAddr[PSDK_IP_ADDR_STR_SIZE_MAX] = {0};
|
||||
uint16_t port = 0;
|
||||
|
||||
USER_UTIL_UNUSED(argument);
|
||||
USER_UTIL_UNUSED(readBufferState);
|
||||
USER_UTIL_UNUSED(writeBufferState);
|
||||
|
||||
while (1) {
|
||||
Osal_TaskSleepMs(1000 / RUN_INDICATE_TASK_FREQ_1HZ);
|
||||
|
||||
// report UART buffer state
|
||||
#ifdef USING_UART_PORT_1
|
||||
UART_GetBufferState(UART_NUM_1, &readBufferState, &writeBufferState);
|
||||
PsdkLogger_UserLogDebug("Uart1 read buffer state: countOfLostData %d, maxUsedCapacityOfBuffer %d.",
|
||||
readBufferState.countOfLostData, readBufferState.maxUsedCapacityOfBuffer);
|
||||
PsdkLogger_UserLogDebug("Uart1 write buffer state: countOfLostData %d, maxUsedCapacityOfBuffer %d.",
|
||||
writeBufferState.countOfLostData, writeBufferState.maxUsedCapacityOfBuffer);
|
||||
#endif
|
||||
|
||||
#ifdef USING_UART_PORT_2
|
||||
UART_GetBufferState(UART_NUM_2, &readBufferState, &writeBufferState);
|
||||
PsdkLogger_UserLogDebug("Uart2 read buffer state: countOfLostData %d, maxUsedCapacityOfBuffer %d.",
|
||||
readBufferState.countOfLostData, readBufferState.maxUsedCapacityOfBuffer);
|
||||
PsdkLogger_UserLogDebug("Uart2 write buffer state: countOfLostData %d, maxUsedCapacityOfBuffer %d.",
|
||||
writeBufferState.countOfLostData, writeBufferState.maxUsedCapacityOfBuffer);
|
||||
#endif
|
||||
|
||||
#ifdef USING_UART_PORT_3
|
||||
UART_GetBufferState(UART_NUM_3, &readBufferState, &writeBufferState);
|
||||
PsdkLogger_UserLogDebug("Uart3 read buffer state: countOfLostData %d, maxUsedCapacityOfBuffer %d.",
|
||||
readBufferState.countOfLostData, readBufferState.maxUsedCapacityOfBuffer);
|
||||
PsdkLogger_UserLogDebug("Uart3 write buffer state: countOfLostData %d, maxUsedCapacityOfBuffer %d.",
|
||||
writeBufferState.countOfLostData, writeBufferState.maxUsedCapacityOfBuffer);
|
||||
#endif
|
||||
|
||||
// report system performance information.
|
||||
// Attention: report system performance part is not intended for normal application runtime use but as a debug aid.
|
||||
if (USER_UTIL_IS_WORK_TURN(runIndicateTaskStep++, RUN_INDICATE_TASK_FREQ_0D1HZ, RUN_INDICATE_TASK_FREQ_1HZ)) {
|
||||
#if (configUSE_TRACE_FACILITY == 1)
|
||||
currentTaskStatusArraySize = uxTaskGetNumberOfTasks();
|
||||
currentTaskStatusArray = PsdkOsal_Malloc(currentTaskStatusArraySize * sizeof(TaskStatus_t));
|
||||
if (currentTaskStatusArray == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
currentTaskStatusArraySize = uxTaskGetSystemState(currentTaskStatusArray, currentTaskStatusArraySize,
|
||||
NULL);
|
||||
PsdkLogger_UserLogDebug("task information:");
|
||||
PsdkLogger_UserLogDebug("task name\trun time (%%)\tstack left (byte)\tnumber");
|
||||
for (i = 0; i < currentTaskStatusArraySize; i++) {
|
||||
cpuOccupyPercentage = 0;
|
||||
for (j = 0; j < lastTaskStatusArraySize; ++j) {
|
||||
if (currentTaskStatusArray[i].xTaskNumber == lastTaskStatusArray[j].xTaskNumber) {
|
||||
cpuOccupyPercentage =
|
||||
(currentTaskStatusArray[i].ulRunTimeCounter - lastTaskStatusArray[j].ulRunTimeCounter) /
|
||||
configTICK_RATE_HZ / RUN_INDICATE_TASK_FREQ_0D1HZ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
PsdkLogger_UserLogDebug("%s\t%u\t%u\t%u", currentTaskStatusArray[i].pcTaskName, cpuOccupyPercentage,
|
||||
(unsigned int) currentTaskStatusArray[i].usStackHighWaterMark *
|
||||
sizeof(StackType_t), (unsigned int) currentTaskStatusArray[i].xTaskNumber);
|
||||
}
|
||||
PsdkOsal_Free(lastTaskStatusArray);
|
||||
lastTaskStatusArray = currentTaskStatusArray;
|
||||
lastTaskStatusArraySize = currentTaskStatusArraySize;
|
||||
#endif
|
||||
|
||||
PsdkLogger_UserLogDebug("used heap size: %d.", configTOTAL_HEAP_SIZE - xPortGetFreeHeapSize());
|
||||
}
|
||||
// Attention: notify another device the network info by uart message, then the device can config network
|
||||
// and send video/data stream by these info.
|
||||
if (s_psdkInitFinished != true) {
|
||||
continue;
|
||||
}
|
||||
sprintf(networkInfoCmd, "[network_config] [ip] %s [mask] %s\r\n", s_networkLocalIpAddress,
|
||||
s_networkConfigMask);
|
||||
UART_Write(PSDK_COMM_WITH_LINUX_UART_NUM, (uint8_t *) networkInfoCmd, strlen(networkInfoCmd));
|
||||
|
||||
returnCode = PsdkPayloadCamera_GetVideoStreamRemoteAddress(ipAddr, &port);
|
||||
if (returnCode == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogDebug("get video stream remote address:%s_%d", ipAddr, port);
|
||||
} else {
|
||||
PsdkLogger_UserLogError("get video stream remote address error.");
|
||||
continue;
|
||||
}
|
||||
sprintf(networkInfoCmd, "[video_stream] [ip] %s [port] %d\r\n", ipAddr, port);
|
||||
UART_Write(PSDK_COMM_WITH_LINUX_UART_NUM, (uint8_t *) networkInfoCmd, strlen(networkInfoCmd));
|
||||
|
||||
returnCode = PsdkDataTransmission_GetDataStreamRemoteAddress(ipAddr, &port);
|
||||
if (returnCode == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogDebug("get data stream remote address: %s_%d", ipAddr, port);
|
||||
} else {
|
||||
PsdkLogger_UserLogError("get data stream remote address error.");
|
||||
continue;
|
||||
}
|
||||
sprintf(networkInfoCmd, "[data_stream] [ip] %s [port] %d\r\n", ipAddr, port);
|
||||
UART_Write(PSDK_COMM_WITH_LINUX_UART_NUM, (uint8_t *) networkInfoCmd, strlen(networkInfoCmd));
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __CC_ARM
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_PsdkReturnCode PsdkUser_FillInUserInfo(T_PsdkUserInfo *userInfo)
|
||||
{
|
||||
memset(userInfo->appName, 0, sizeof(userInfo->appName));
|
||||
memset(userInfo->appId, 0, sizeof(userInfo->appId));
|
||||
memset(userInfo->appKey, 0, sizeof(userInfo->appKey));
|
||||
memset(userInfo->developerAccount, 0, sizeof(userInfo->developerAccount));
|
||||
|
||||
if (strlen(USER_APP_NAME) >= sizeof(userInfo->appName) ||
|
||||
strlen(USER_APP_ID) > sizeof(userInfo->appId) ||
|
||||
strlen(USER_APP_KEY) > sizeof(userInfo->appKey) ||
|
||||
strlen(USER_DEVELOPER_ACCOUNT) >= sizeof(userInfo->developerAccount)) {
|
||||
PsdkLogger_UserLogError("Length of user information string is beyond limit. Please check.");
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!strcmp(USER_APP_NAME, "your_app_name") ||
|
||||
!strcmp(USER_APP_ID, "your_app_id") ||
|
||||
!strcmp(USER_APP_KEY, "your_app_key") ||
|
||||
!strcmp(USER_DEVELOPER_ACCOUNT, "your_developer_account")) {
|
||||
PsdkLogger_UserLogError("Please fill in correct user information to psdk_app_info.h file.");
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
strncpy(userInfo->appName, USER_APP_NAME, sizeof(userInfo->appName) - 1);
|
||||
memcpy(userInfo->appId, USER_APP_ID, USER_UTIL_MIN(sizeof(userInfo->appId), strlen(USER_APP_ID)));
|
||||
memcpy(userInfo->appKey, USER_APP_KEY, USER_UTIL_MIN(sizeof(userInfo->appKey), strlen(USER_APP_KEY)));
|
||||
strncpy(userInfo->developerAccount, USER_DEVELOPER_ACCOUNT, sizeof(userInfo->developerAccount) - 1);
|
||||
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_PsdkReturnCode PsdkUser_Console(const uint8_t *data, uint16_t dataLen)
|
||||
{
|
||||
UART_Write(PSDK_CONSOLE_UART_NUM, (uint8_t *) data, dataLen);
|
||||
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_PsdkReturnCode PsdkUser_NetWorkConfig(const char *ipAddr, const char *netMask)
|
||||
{
|
||||
PsdkLogger_UserLogInfo("Network of payload need config to ipAddr:%s netMask:%s", ipAddr, netMask);
|
||||
strncpy(s_networkLocalIpAddress, ipAddr, sizeof(s_networkLocalIpAddress));
|
||||
strncpy(s_networkConfigMask, netMask, sizeof(s_networkLocalIpAddress));
|
||||
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
52
sample/platform/rtos_freertos/stm32f4_eval/application/application.h
Executable file
52
sample/platform/rtos_freertos/stm32f4_eval/application/application.h
Executable file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file application.h
|
||||
* @version V2.0.0
|
||||
* @date 2019/8/23
|
||||
* @brief This is the header file for "application.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2018-2019 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 APPLICATION_H
|
||||
#define APPLICATION_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "psdk_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
void PsdkUser_StartTask(void const *argument);
|
||||
void PsdkUser_RunIndicateTask(void const *argument);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // APPLICATION_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
151
sample/platform/rtos_freertos/stm32f4_eval/application/main.c
Executable file
151
sample/platform/rtos_freertos/stm32f4_eval/application/main.c
Executable file
@ -0,0 +1,151 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file main.c
|
||||
* @version V2.0.0
|
||||
* @date 2019/8/23
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2018-2019 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.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "application.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "psdk_platform.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define USER_START_TASK_STACK_SIZE 512
|
||||
#define USER_START_TASK_PRIORITY 0
|
||||
#define USER_RUN_INDICATE_TASK_STACK_SIZE 256
|
||||
#define USER_RUN_INDICATE_TASK_PRIORITY 0
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
static TaskHandle_t startTask;
|
||||
static TaskHandle_t runIndicateTask;
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static void SystemClock_Config(void);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
#ifndef __CC_ARM
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
|
||||
#pragma GCC diagnostic ignored "-Wreturn-type"
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* STM32F4xx HAL library initialization:
|
||||
- Configure the Flash prefetch, instruction and Data caches
|
||||
- Configure the Systick to generate an interrupt each 1 msec
|
||||
- Set NVIC Group Priority to 4
|
||||
- Global MSP (MCU Support Package) initialization
|
||||
*/
|
||||
HAL_Init();
|
||||
|
||||
/* Configure the system clock to 168 MHz */
|
||||
SystemClock_Config();
|
||||
|
||||
/* Create start task */
|
||||
xTaskCreate((TaskFunction_t) PsdkUser_StartTask, "start_task", USER_START_TASK_STACK_SIZE,
|
||||
NULL, USER_START_TASK_PRIORITY, startTask);
|
||||
|
||||
/* Create runIndicate task */
|
||||
xTaskCreate((TaskFunction_t) PsdkUser_RunIndicateTask, "run_indicate_task", USER_RUN_INDICATE_TASK_STACK_SIZE,
|
||||
NULL, USER_RUN_INDICATE_TASK_PRIORITY, runIndicateTask);
|
||||
|
||||
/* Start scheduler */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/*Taken by the scheduler */
|
||||
for (;;);
|
||||
}
|
||||
|
||||
#ifndef __CC_ARM
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
/**
|
||||
* @brief System Clock Configuration
|
||||
* The system Clock is configured as follow :
|
||||
* System Clock source = PLL (HSE)
|
||||
* SYSCLK(Hz) = 168000000
|
||||
* HCLK(Hz) = 168000000
|
||||
* AHB Prescaler = 1
|
||||
* APB1 Prescaler = 4
|
||||
* APB2 Prescaler = 2
|
||||
* HSE Frequency(Hz) = HSE_VALUE
|
||||
* PLL_M = HSE_VALUE/1000000
|
||||
* PLL_N = 336
|
||||
* PLL_P = 2
|
||||
* PLL_Q = 7
|
||||
* VDD(V) = 3.3
|
||||
* Main regulator output voltage = Scale1 mode
|
||||
* Flash Latency(WS) = 5
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void SystemClock_Config(void)
|
||||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
|
||||
/* Enable Power Control clock */
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||
|
||||
/* Enable HSE Oscillator and activate PLL with HSE as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = HSE_VALUE / 1000000;
|
||||
RCC_OscInitStruct.PLL.PLLN = 336;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 7;
|
||||
HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
||||
|
||||
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
|
||||
clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 |
|
||||
RCC_CLOCKTYPE_PCLK2);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
|
||||
|
||||
/* STM32F405x/407x/415x/417x Revision Z devices: prefetch is supported */
|
||||
if (HAL_GetREVID() == 0x1001) {
|
||||
/* Enable the Flash prefetch */
|
||||
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
|
||||
}
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
72
sample/platform/rtos_freertos/stm32f4_eval/application/psdk_config.h
Executable file
72
sample/platform/rtos_freertos/stm32f4_eval/application/psdk_config.h
Executable file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file psdk_config.h
|
||||
* @version V2.0.0
|
||||
* @date 2019/9/11
|
||||
* @brief This is the header file for "psdk_config.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2018-2019 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_CONFIG_H
|
||||
#define PSDK_CONFIG_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define PSDK_USING_POWER_MANAGEMENT
|
||||
|
||||
#define PSDK_USING_CAMERA_EMU
|
||||
|
||||
#define PSDK_USING_DATA_TRANSMISSION
|
||||
|
||||
#define PSDK_USING_DATA_SUBSCRIPTION
|
||||
|
||||
#define PSDK_USING_PAYLOAD_COLLABORATION
|
||||
|
||||
#define PSDK_USING_WIDGET
|
||||
|
||||
#define PSDK_USING_TIME_SYNC
|
||||
|
||||
#define PSDK_USING_POSITIONING
|
||||
|
||||
#define PSDK_USING_GIMBAL_EMU
|
||||
|
||||
#define PSDK_USING_XPORT
|
||||
|
||||
#ifdef USE_BOOTLOADER
|
||||
#define PSDK_USING_UPGRADE
|
||||
#endif
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PSDK_CONFIG_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
Reference in New Issue
Block a user