FIX: fixed the problem that the rtos sample can not run normally on M300 RTK extension port

Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
DJI-Martin
2023-03-12 17:14:41 +08:00
parent 2eae721530
commit 46c4619ea5
23 changed files with 49 additions and 49 deletions

View File

@ -37,7 +37,7 @@ extern "C" {
#define DJI_VERSION_MINOR 3 /*!< DJI SDK minor version num, when add functionality in a backwards compatible manner changes. Range from 0 to 99. */ #define DJI_VERSION_MINOR 3 /*!< DJI SDK minor version num, when add functionality in a backwards compatible manner changes. Range from 0 to 99. */
#define DJI_VERSION_MODIFY 0 /*!< DJI SDK modify version num, when have backwards compatible bug fixes changes. Range from 0 to 99. */ #define DJI_VERSION_MODIFY 0 /*!< DJI SDK modify version num, when have backwards compatible bug fixes changes. Range from 0 to 99. */
#define DJI_VERSION_BETA 0 /*!< DJI SDK version beta info, release version will be 0, when beta version release changes. Range from 0 to 255. */ #define DJI_VERSION_BETA 0 /*!< DJI SDK version beta info, release version will be 0, when beta version release changes. Range from 0 to 255. */
#define DJI_VERSION_BUILD 1697 /*!< DJI SDK version build info, when jenkins trigger build changes. Range from 0 to 65535. */ #define DJI_VERSION_BUILD 1702 /*!< DJI SDK version build info, when jenkins trigger build changes. Range from 0 to 65535. */
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/

View File

@ -64,7 +64,7 @@
#define configTICK_RATE_HZ ((TickType_t)1000) #define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 7 ) #define configMAX_PRIORITIES ( 7 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)64000) #define configTOTAL_HEAP_SIZE ((size_t)75000)
#define configMAX_TASK_NAME_LEN ( 16 ) #define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
#define configUSE_MUTEXES 1 #define configUSE_MUTEXES 1

View File

@ -62,11 +62,11 @@
#define RUN_INDICATE_TASK_FREQ_0D1HZ 0.1f #define RUN_INDICATE_TASK_FREQ_0D1HZ 0.1f
#define DJI_USE_WIDGET_INTERACTION 0 #define DJI_USE_WIDGET_INTERACTION 0
#define DJI_EXTENSION_PORT_SUPPORT 0
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private values -------------------------------------------------------------*/ /* Private values -------------------------------------------------------------*/
static bool s_isApplicationStart = false;
/* Private functions declaration ---------------------------------------------*/ /* Private functions declaration ---------------------------------------------*/
static T_DjiReturnCode DjiUser_PrintConsole(const uint8_t *data, uint16_t dataLen); static T_DjiReturnCode DjiUser_PrintConsole(const uint8_t *data, uint16_t dataLen);
@ -113,8 +113,8 @@ void DjiUser_StartTask(void const *argument)
UART_Init(DJI_CONSOLE_UART_NUM, DJI_CONSOLE_UART_BAUD); UART_Init(DJI_CONSOLE_UART_NUM, DJI_CONSOLE_UART_BAUD);
Led_Init(LED3); Led_Init(LED3);
//Attention: if you want to run payload sdk on extension port, please define the macro DJI_EXTENSION_PORT_SUPPORT. //Attention: if you want to run payload sdk on extension port, please define the macro USE_USB_HOST_UART.
#if DJI_EXTENSION_PORT_SUPPORT #if USE_USB_HOST_UART
MX_USB_HOST_Init(); MX_USB_HOST_Init();
Osal_TaskSleepMs(2000); Osal_TaskSleepMs(2000);
#endif #endif
@ -169,7 +169,7 @@ void DjiUser_StartTask(void const *argument)
returnCode = DjiTest_RegApplyHighPowerHandler(&applyHighPowerHandler); returnCode = DjiTest_RegApplyHighPowerHandler(&applyHighPowerHandler);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("regsiter apply high power handler error"); USER_LOG_ERROR("register apply high power handler error");
} }
returnCode = DjiTest_PowerManagementStartService(); returnCode = DjiTest_PowerManagementStartService();
@ -178,27 +178,12 @@ void DjiUser_StartTask(void const *argument)
} }
#endif #endif
#ifdef CONFIG_MODULE_SAMPLE_CAMERA_ON
returnCode = DjiTest_CameraEmuBaseStartService();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("camera emu common init error");
goto out;
}
#endif
#ifdef CONFIG_MODULE_SAMPLE_WIDGET_ON #ifdef CONFIG_MODULE_SAMPLE_WIDGET_ON
#if DJI_USE_WIDGET_INTERACTION
returnCode = DjiTest_WidgetInteractionStartService();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("widget sample init error");
}
#else
returnCode = DjiTest_WidgetStartService(); returnCode = DjiTest_WidgetStartService();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("widget sample init error"); USER_LOG_ERROR("widget sample init error");
} }
#endif #endif
#endif
#ifdef CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON #ifdef CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON
returnCode = DjiTest_DataTransmissionStartService(); returnCode = DjiTest_DataTransmissionStartService();
@ -214,6 +199,15 @@ void DjiUser_StartTask(void const *argument)
} }
#endif #endif
#if !USE_USB_HOST_UART
#ifdef CONFIG_MODULE_SAMPLE_CAMERA_ON
returnCode = DjiTest_CameraEmuBaseStartService();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("camera emu common init error");
goto out;
}
#endif
#ifdef CONFIG_MODULE_SAMPLE_GIMBAL_EMU_ON #ifdef CONFIG_MODULE_SAMPLE_GIMBAL_EMU_ON
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 || if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_NONE) { aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_NONE) {
@ -287,6 +281,7 @@ void DjiUser_StartTask(void const *argument)
DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
printf("psdk upgrade init error"); printf("psdk upgrade init error");
} }
#endif
#endif #endif
returnCode = DjiCore_ApplicationStart(); returnCode = DjiCore_ApplicationStart();
@ -294,6 +289,8 @@ void DjiUser_StartTask(void const *argument)
USER_LOG_ERROR("start sdk application error"); USER_LOG_ERROR("start sdk application error");
} }
s_isApplicationStart = true;
while (1) { while (1) {
Osal_TaskSleepMs(500); Osal_TaskSleepMs(500);
Led_Trigger(LED3); Led_Trigger(LED3);
@ -325,8 +322,11 @@ void DjiUser_MonitorTask(void const *argument)
#endif #endif
while (1) { while (1) {
Osal_TaskSleepMs(1000 / RUN_INDICATE_TASK_FREQ_1HZ); Osal_TaskSleepMs(1000 / RUN_INDICATE_TASK_FREQ_0D1HZ);
if (s_isApplicationStart == false) {
continue;
}
// report UART buffer state // report UART buffer state
#ifdef USING_UART_PORT_1 #ifdef USING_UART_PORT_1
UART_GetBufferState(UART_NUM_1, &readBufferState, &writeBufferState); UART_GetBufferState(UART_NUM_1, &readBufferState, &writeBufferState);
@ -385,7 +385,7 @@ void DjiUser_MonitorTask(void const *argument)
lastTaskStatusArraySize = currentTaskStatusArraySize; lastTaskStatusArraySize = currentTaskStatusArraySize;
#endif #endif
} }
USER_LOG_DEBUG("used heap size: %d/%d.\r\n", configTOTAL_HEAP_SIZE - xPortGetFreeHeapSize(), USER_LOG_INFO("Used heap size: %d/%d.\r\n", configTOTAL_HEAP_SIZE - xPortGetFreeHeapSize(),
configTOTAL_HEAP_SIZE); configTOTAL_HEAP_SIZE);
} }
} }

View File

@ -36,19 +36,19 @@ extern "C" {
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/
#define CONFIG_MODULE_SAMPLE_POWER_MANAGEMENT_ON #define CONFIG_MODULE_SAMPLE_POWER_MANAGEMENT_ON
#define CONFIG_MODULE_SAMPLE_WIDGET_ON
#define CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON #define CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON
#define CONFIG_MODULE_SAMPLE_WIDGET_ON #define CONFIG_MODULE_SAMPLE_FC_SUBSCRIPTION_ON
#define CONFIG_MODULE_SAMPLE_GIMBAL_EMU_ON #define CONFIG_MODULE_SAMPLE_GIMBAL_EMU_ON
#define CONFIG_MODULE_SAMPLE_CAMERA_ON #define CONFIG_MODULE_SAMPLE_CAMERA_ON
#define CONFIG_MODULE_SAMPLE_FC_SUBSCRIPTION_ON
#define CONFIG_MODULE_SAMPLE_XPORT_ON #define CONFIG_MODULE_SAMPLE_XPORT_ON
//#define CONFIG_MODULE_SAMPLE_UPGRADE_ON #define CONFIG_MODULE_SAMPLE_UPGRADE_ON
/*!< Attention: Please uncomment it in gps environment. /*!< Attention: Please uncomment it in gps environment.
* */ * */

View File

@ -29,7 +29,7 @@
#include "task.h" #include "task.h"
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
#define USER_START_TASK_STACK_SIZE 1024 #define USER_START_TASK_STACK_SIZE 2048
#define USER_START_TASK_PRIORITY 0 #define USER_START_TASK_PRIORITY 0
#define USER_RUN_INDICATE_TASK_STACK_SIZE 256 #define USER_RUN_INDICATE_TASK_STACK_SIZE 256
#define USER_RUN_INDICATE_TASK_PRIORITY 0 #define USER_RUN_INDICATE_TASK_PRIORITY 0

View File

@ -34,19 +34,17 @@
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/
//uart uart buffer size define //uart uart buffer size define
#define UART1_READ_BUF_SIZE 1024 #define UART1_READ_BUF_SIZE 64
#define UART1_WRITE_BUF_SIZE 4096 #define UART1_WRITE_BUF_SIZE 64
#define UART2_READ_BUF_SIZE 2048 #define UART2_READ_BUF_SIZE 64
#define UART2_WRITE_BUF_SIZE 2048 #define UART2_WRITE_BUF_SIZE 2048
#define UART3_READ_BUF_SIZE 1024 #define UART3_READ_BUF_SIZE 4096
#define UART3_WRITE_BUF_SIZE 1024 #define UART3_WRITE_BUF_SIZE 2048
/* Private macro -------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
#ifdef USING_UART_PORT_1 #ifdef USING_UART_PORT_1
//UART1 read ring buffer structure //UART1 read ring buffer structure
@ -58,9 +56,9 @@ static T_RingBuffer s_uart1WriteRingBuffer;
//USART1 write buffer state //USART1 write buffer state
static T_UartBufferState s_uart1WriteBufferState; static T_UartBufferState s_uart1WriteBufferState;
//UART1 read buffer //UART1 read buffer
static uint8_t s_uart1ReadBuf[UART1_READ_BUF_SIZE]; CCMRAM static uint8_t s_uart1ReadBuf[UART1_READ_BUF_SIZE];
//UART1 write buffer //UART1 write buffer
static uint8_t s_uart1WriteBuf[UART1_WRITE_BUF_SIZE]; CCMRAM static uint8_t s_uart1WriteBuf[UART1_WRITE_BUF_SIZE];
//UART1 mutex //UART1 mutex
static T_DjiMutexHandle s_uart1Mutex; static T_DjiMutexHandle s_uart1Mutex;
@ -73,8 +71,8 @@ static T_RingBuffer s_uart2ReadRingBuffer;
static T_UartBufferState s_uart2ReadBufferState; static T_UartBufferState s_uart2ReadBufferState;
static T_RingBuffer s_uart2WriteRingBuffer; static T_RingBuffer s_uart2WriteRingBuffer;
static T_UartBufferState s_uart2WriteBufferState; static T_UartBufferState s_uart2WriteBufferState;
static uint8_t s_uart2ReadBuf[UART2_READ_BUF_SIZE]; CCMRAM static uint8_t s_uart2ReadBuf[UART2_READ_BUF_SIZE];
static uint8_t s_uart2WriteBuf[UART2_WRITE_BUF_SIZE]; CCMRAM static uint8_t s_uart2WriteBuf[UART2_WRITE_BUF_SIZE];
static T_DjiMutexHandle s_uart2Mutex; static T_DjiMutexHandle s_uart2Mutex;
static UART_HandleTypeDef s_uart2Handle; static UART_HandleTypeDef s_uart2Handle;
@ -85,8 +83,8 @@ static T_RingBuffer s_uart3ReadRingBuffer;
static T_UartBufferState s_uart3ReadBufferState; static T_UartBufferState s_uart3ReadBufferState;
static T_RingBuffer s_uart3WriteRingBuffer; static T_RingBuffer s_uart3WriteRingBuffer;
static T_UartBufferState s_uart3WriteBufferState; static T_UartBufferState s_uart3WriteBufferState;
static uint8_t s_uart3ReadBuf[UART3_READ_BUF_SIZE]; CCMRAM static uint8_t s_uart3ReadBuf[UART3_READ_BUF_SIZE];
static uint8_t s_uart3WriteBuf[UART3_WRITE_BUF_SIZE]; CCMRAM static uint8_t s_uart3WriteBuf[UART3_WRITE_BUF_SIZE];
static T_DjiMutexHandle s_uart3Mutex; static T_DjiMutexHandle s_uart3Mutex;
static UART_HandleTypeDef s_uart3Handle; static UART_HandleTypeDef s_uart3Handle;

View File

@ -280,6 +280,8 @@ void HAL_DisableMemorySwappingBank(void);
* @} * @}
*/ */
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
#define CCMRAM __attribute__((section(".ccmram")))
/* Private functions ---------------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/
/** /**
* @} * @}

View File

@ -146,8 +146,8 @@ USBH_ClassTypeDef CDC_Class =
QueueHandle_t ACMDataRecvQueue; QueueHandle_t ACMDataRecvQueue;
QueueHandle_t ACMDataSendQueue; QueueHandle_t ACMDataSendQueue;
#if DJI_EXTENSION_PORT_SUPPORT #if USE_USB_HOST_UART
static uint8_t cdcBuff[1024]; CCMRAM static uint8_t cdcBuff[1024];
#endif #endif
void USBH_CDC_DataQueueInit(void) void USBH_CDC_DataQueueInit(void)
@ -372,7 +372,7 @@ static USBH_StatusTypeDef USBH_CDC_Process(USBH_HandleTypeDef *phost)
CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef *) phost->pActiveClass->pData; CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef *) phost->pActiveClass->pData;
if (CDC_Handle->data_rx_state == CDC_IDLE) { if (CDC_Handle->data_rx_state == CDC_IDLE) {
#if DJI_EXTENSION_PORT_SUPPORT #if USE_USB_HOST_UART
USBH_CDC_Receive(phost, cdcBuff, sizeof(cdcBuff)); USBH_CDC_Receive(phost, cdcBuff, sizeof(cdcBuff));
#endif #endif
} }

View File

@ -1,9 +1,9 @@
# This is an STM32F4 discovery board with a single STM32F407VGT6 chip. # This is an STM32F4 discovery board with a single STM32F407VGT6 chip.
# http://www.st.com/internet/evalboard/product/252419.jsp # http://www.st.com/internet/evalboard/product/252419.jsp
source [find interface/stlink-v2-1.cfg] source [find interface/jlink.cfg]
transport select hla_swd transport select swd
# increase working area to 64KB # increase working area to 64KB
set WORKAREASIZE 0x10000 set WORKAREASIZE 0x10000