增大了实时系统的栈空间,修复视觉通信函数临时变量导致内存泄漏的问题

This commit is contained in:
NeoZng
2023-04-20 09:54:04 +08:00
parent 1818edf117
commit 0f55fed9d6
4 changed files with 22 additions and 14 deletions

View File

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

View File

@@ -52,6 +52,12 @@
/* USER CODE END Variables */
osThreadId defaultTaskHandle;
osThreadId insTaskHandle;
osThreadId ledTaskHandle;
osThreadId robotTaskHandle;
osThreadId motorTaskHandle;
osThreadId daemonTaskHandle;
osThreadId uiTaskHandle;
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */
@@ -119,16 +125,16 @@ void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
osThreadDef(instask, StartINSTASK, osPriorityNormal, 0, 1024);
defaultTaskHandle = osThreadCreate(osThread(instask), NULL);
insTaskHandle = osThreadCreate(osThread(instask), NULL);
osThreadDef(motortask, StartMOTORTASK, osPriorityNormal, 0, 256);
defaultTaskHandle = osThreadCreate(osThread(motortask), NULL);
osThreadDef(motortask, StartMOTORTASK, osPriorityNormal, 0, 512);
motorTaskHandle = osThreadCreate(osThread(motortask), NULL);
osThreadDef(daemontask, StartDAEMONTASK, osPriorityNormal, 0, 512);
defaultTaskHandle = osThreadCreate(osThread(daemontask), NULL);
osThreadDef(daemontask, StartDAEMONTASK, osPriorityNormal, 0, 128);
daemonTaskHandle = osThreadCreate(osThread(daemontask), NULL);
osThreadDef(robottask, StartROBOTTASK, osPriorityNormal, 0, 1024);
defaultTaskHandle = osThreadCreate(osThread(robottask), NULL);
robotTaskHandle = osThreadCreate(osThread(robottask), NULL);
/* USER CODE END RTOS_THREADS */
}
@@ -191,7 +197,7 @@ void StartROBOTTASK(void const * argument)
{
// 200Hz
RobotTask();
osDelay(10);//syh此处暂时将时间改<E997B4><EFBFBD>?10ms原因在于未使用缓冲区发送<EFBC8C>?<3F>时延时5ms
osDelay(5);//syh此处暂时将时间改<E997B4>?10ms原因在于未使用缓冲区发送<EFBC8C>?<3F>时延时5ms
}
}
/* USER CODE END Application */

View File

@@ -53,8 +53,8 @@ void GimbalInit()
.cali_mode = BMI088_CALIBRATE_ONLINE_MODE,
.work_mode = BMI088_BLOCK_PERIODIC_MODE,
};
imu = BMI088Register(&imu_config);
// gimba_IMU_data = INS_Init(); // IMU先初始化,获取姿态数据指针赋给yaw电机的其他数据来源
// imu = BMI088Register(&imu_config);
gimba_IMU_data = INS_Init(); // IMU先初始化,获取姿态数据指针赋给yaw电机的其他数据来源
// YAW
Motor_Init_Config_s yaw_config = {
.can_init_config = {

View File

@@ -78,11 +78,13 @@ Vision_Recv_s *VisionInit(UART_HandleTypeDef *_handle)
*/
void VisionSend(Vision_Send_s *send)
{
uint16_t flag_register;
uint8_t send_buff[VISION_SEND_SIZE];
uint16_t tx_len;
// buff和txlen必须为static,才能保证在函数退出后不被释放,使得DMA正确完成发送
// 析构后的陷阱需要特别注意!
static uint16_t flag_register;
static uint8_t send_buff[VISION_SEND_SIZE];
static uint16_t tx_len;
// TODO: code to set flag_register
flag_register = 30<<8|0b00000001;
flag_register = 30 << 8 | 0b00000001;
// 将数据转化为seasky协议的数据包
get_protocol_send_data(0x02, flag_register, &send->yaw, 3, send_buff, &tx_len);
USARTSend(vision_usart_instance, send_buff, tx_len, USART_TRANSFER_DMA); // 和视觉通信使用IT,防止和接收使用的DMA冲突