diff --git a/App/Src/anemometer_dev.c b/App/Src/anemometer_dev.c index 061b6fd..f911ebe 100644 --- a/App/Src/anemometer_dev.c +++ b/App/Src/anemometer_dev.c @@ -883,12 +883,12 @@ void my_update_mcs_param(float new_wind_speed, float new_wind_dirction) win_10min.speed_data[win_10min.index] = g_stMcs_Para.instantaneous_wind_speed; //添加新数据 win_10min.direction_data[win_10min.index] = g_stMcs_Para.instantaneous_wind_direction; - if(win_10min.count < g_usrConfigInfo.speed_average_time /*AVE_TIME*/) + if(win_10min.count < g_usrConfigInfo.speed_average_time) { win_10min.count++; } - if(win_10min.count > g_usrConfigInfo.speed_average_time/*AVE_TIME*/){win_10min.count = /*AVE_TIME*/g_usrConfigInfo.speed_average_time;} + if(win_10min.count > g_usrConfigInfo.speed_average_time){win_10min.count = g_usrConfigInfo.speed_average_time;} //计算10min风速滑动平均值 win_10min.ave_speed_data[win_10min.index] = sum(win_10min.speed_data, win_10min.count) / win_10min.count; //计算10min风向滑动平均值,风向滑动平均值需要过零算法 @@ -966,7 +966,7 @@ void my_update_mcs_param(float new_wind_speed, float new_wind_dirction) g_stMcs_Para.trough_wind_direction = temp_trough_min_direction; g_stMcs_Para.peak_wind_direction = temp_peak_max_direction; - win_10min.index = (win_10min.index + 1) % /*AVE_TIME*/g_usrConfigInfo.speed_average_time;//更新索引 + win_10min.index = (win_10min.index + 1) % g_usrConfigInfo.speed_average_time;//更新索引 } void tem_hum_update_task(void const * argument) diff --git a/Core/Inc/FreeRTOSConfig.h b/Core/Inc/FreeRTOSConfig.h index 30b0ea4..43bdffa 100644 --- a/Core/Inc/FreeRTOSConfig.h +++ b/Core/Inc/FreeRTOSConfig.h @@ -64,7 +64,7 @@ #define configTICK_RATE_HZ ((TickType_t)40) #define configMAX_PRIORITIES ( 7 ) #define configMINIMAL_STACK_SIZE ((uint16_t)128) -#define configTOTAL_HEAP_SIZE ((size_t)20*1024) +#define configTOTAL_HEAP_SIZE ((size_t)30*1024) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_16_BIT_TICKS 0 #define configUSE_MUTEXES 1 diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 81245f2..0067694 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -115,14 +115,14 @@ void MX_FREERTOS_Init(void) { /* Create the thread(s) */ /* definition and creation of defaultTask */ - osThreadDef(defaultTask, StartDefaultTask, osPriorityRealtime, 0, 2048);//ͨѶ + osThreadDef(defaultTask, StartDefaultTask, osPriorityRealtime, 0, 2*1024);//ͨѶ defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); osThreadDef(ledTask, LEDTask, osPriorityIdle, 0, 128);//LED ledTaskHandle = osThreadCreate(osThread(ledTask), NULL); /* USER CODE BEGIN RTOS_THREADS */ - osThreadDef(anemometer, wind_task, osPriorityHigh, 0, 2048);// ٷ + osThreadDef(anemometer, wind_task, osPriorityHigh, 0, 2*1024);// ٷ anemometerHandle = osThreadCreate(osThread(anemometer), NULL); osThreadDef(temhum_update_task, tem_hum_update_task, osPriorityAboveNormal, 0, 512);//ʪȣѹ diff --git a/Drivers/HP203B/hp203b.c b/Drivers/HP203B/hp203b.c index b79aa85..880a2f0 100644 --- a/Drivers/HP203B/hp203b.c +++ b/Drivers/HP203B/hp203b.c @@ -100,17 +100,18 @@ BOOL get_HP203_data(float* tempdata, float* press) } osDelay(1); } - + if(press_error_time >= COLLECT_HB203_DATA_NUM) + { + goto error_return; + } U_DataType tmp_press = filter_middle(collect_pressure, COLLECT_HB203_DATA_NUM - press_error_time, FILTER_DATA_TYPE_FLOAT); if(tmp_press.fValue < 300) { - tmp_press.fValue = 300; // return FALSE; goto error_return; } if(tmp_press.fValue > 1200) { - tmp_press.fValue = 1200; // return FALSE; goto error_return; } @@ -125,17 +126,18 @@ BOOL get_HP203_data(float* tempdata, float* press) } osDelay(1); } - + if(temp_error_time >= COLLECT_HB203_DATA_NUM) + { + goto error_return; + } U_DataType tmp_tempture = filter_middle(collect_tempture, COLLECT_HB203_DATA_NUM - temp_error_time, FILTER_DATA_TYPE_FLOAT); if(tmp_tempture.fValue < -40) { - tmp_tempture.fValue = -40; // return FALSE; goto error_return; } if(tmp_tempture.fValue > 85) { - tmp_tempture.fValue = 85; // return FALSE; goto error_return; }