From e96230cbd37fc3f7a1f0babd2499cb578a6be94a Mon Sep 17 00:00:00 2001 From: 95384 <664090429@qq.com> Date: Sat, 23 Nov 2024 12:05:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=B0=94=E5=8E=8B=E4=BC=A0=E6=84=9F?= =?UTF-8?q?=E5=99=A8=EF=BC=88HP203B=EF=BC=89=E7=9A=84=E6=B8=A9=E5=BA=A6?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E5=A4=87=E7=94=A8=E6=B8=A9=E5=BA=A6=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=B8=A9=E5=BA=A6=E4=B8=8E=E6=B0=94?= =?UTF-8?q?=E5=8E=8B=E4=BC=A0=E6=84=9F=E5=99=A8=E9=94=99=E8=AF=AF=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- App/Inc/anemometer_dev.h | 4 +- App/Src/anemometer_dev.c | 34 +- Drivers/HP203B/hp203b.c | 86 +- Drivers/HP203B/hp203b.h | 4 +- Drivers/Sht3x/sht30.c | 24 +- EWARM/micro_climate.ewd | 1611 ++++++++++++++++++++++++++++++++++++++ EWARM/micro_climate.ewp | 1113 +++++++++++++++++++++++++- README.md | 4 +- 9 files changed, 2847 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index a57a797..eb90281 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ EWARM/micro_climate/ +EWARM/REMOTE_UPDATE/ EWARM/settings/ -frt_protocol.c 软件框架图.vsdx 软件流程图.vsdx 赛联-微气象传感器软件设计说明书.docx diff --git a/App/Inc/anemometer_dev.h b/App/Inc/anemometer_dev.h index b71bd05..83e66d2 100644 --- a/App/Inc/anemometer_dev.h +++ b/App/Inc/anemometer_dev.h @@ -125,8 +125,8 @@ extern mcs_para g_stMcs_Para; typedef struct _error_log{ uint16_t tof_error_NS:1; /* 接受南北信号(tofy,tofx<0)很小 */ uint16_t tof_error_WE:1; /* 接受东西信号(tofy,tofx<0)很小 */ - uint16_t error_2:1; /* 保留 */ - uint16_t error_3:1; /* 保留 */ + uint16_t temp_error_SHT30:1; /* SHT30错误日志(温湿度) */ + uint16_t temp_error_HP203B:1; /* HP203B错误日志(大气压) */ uint16_t error_4:1; /* 保留 */ uint16_t error_5:1; /* 保留 */ uint16_t error_6:1; /* 保留 */ diff --git a/App/Src/anemometer_dev.c b/App/Src/anemometer_dev.c index d353f3d..cb236f4 100644 --- a/App/Src/anemometer_dev.c +++ b/App/Src/anemometer_dev.c @@ -858,26 +858,50 @@ void tem_hum_update_task(void const * argument) int time_s_temp_humi = 0; uint32_t time_s_1Day = 0; + float backupTemperature; get_temp_humi_data(&g_stMcs_Para.temperature, &g_stMcs_Para.humidity);//开机先采集一次 while(1) { osDelay(1000); time_s_temp_humi ++; time_s_1Day ++; - - if (time_s_temp_humi >= g_stConfigInfo.temp_hum_update_time) +// 温湿度大气压更新 + if (time_s_temp_humi >= 1/*g_stConfigInfo.temp_hum_update_time*/) { - get_temp_humi_data(&g_stMcs_Para.temperature, &g_stMcs_Para.humidity); +// 采集HP203B传感器数据(大气压) + if(get_HP203_data(&backupTemperature, &g_stMcs_Para.pressure) == FALSE) + { + g_error_log.temp_error_HP203B = 1; +/// 错误处理 + } + else + { + // 没出问题清除错误日志 + g_error_log.temp_error_HP203B = 0; + } +// 采集SHT30传感器数据(温湿度) + if(get_temp_humi_data(&g_stMcs_Para.temperature, &g_stMcs_Para.humidity) == FALSE) + { + g_error_log.temp_error_SHT30 = 1; +/// 错误处理 + g_stMcs_Para.temperature = backupTemperature; + } + else + { + // 没出问题清除错误日志 + g_error_log.temp_error_SHT30 = 0; + } +// 计时重置 time_s_temp_humi = 0; } +// 一天重启 if (time_s_1Day >= 86400) { __iar_builtin_set_FAULTMASK(1); NVIC_SystemReset(); } +// 风速风向更新 my_update_mcs_param(av_speed, av_angle); - //采集HP203B数据(大气压) - get_press_data(); } } diff --git a/Drivers/HP203B/hp203b.c b/Drivers/HP203B/hp203b.c index 1ef4dde..5efdcf5 100644 --- a/Drivers/HP203B/hp203b.c +++ b/Drivers/HP203B/hp203b.c @@ -3,7 +3,6 @@ #include "filter.h" #include "anemometer_dev.h" - /**************************** *ƣset_mode *ܣôӻģʽͨ @@ -22,10 +21,10 @@ void hp203_set_mode() /**************************** *ƣHp203bReadPressure *ܣȡѹ -*Press--ѹֵ +* * * -*أ +*أѹ *****************************/ float Hp203bReadPressure(void) { @@ -49,35 +48,94 @@ float Hp203bReadPressure(void) } /**************************** -*ƣget_press_data -*ܣȡѹ -*Press--ѹֵ +*ƣHp203bReadTempture +*ܣȡ¶ +* * * +*أ¶ +*****************************/ +float Hp203bReadTempture(void) +{ + float ret = 0.0; + long Hp203b_tempture = 0; + uint8_t Hp203bPressure_Temp[3] = {0}; + uint8_t read_command[1] = {0x32}; + + HAL_I2C_Master_Transmit(&hi2c3, HP20X_ADDRESSCMD, read_command, 1, 0xff); + HAL_I2C_Master_Receive(&hi2c3, HP20X_ADDRESSCMD, Hp203bPressure_Temp, 3, 0xff); + + Hp203b_tempture = Hp203bPressure_Temp[0]; + Hp203b_tempture <<= 8; + Hp203b_tempture |= Hp203bPressure_Temp[1]; + Hp203b_tempture <<= 8; + Hp203b_tempture |= Hp203bPressure_Temp[2]; + + Hp203b_tempture = Hp203b_tempture / 100; + ret = Hp203b_tempture; + return ret; +} + +/**************************** +*ƣget_press_data +*ܣȡѹ뱸¶ +*Press--ѹֵ +* +* *أ *****************************/ -#define COLLECT_PRESS_DATA_NUM 10 -BOOL get_press_data(void) +#define COLLECT_HB203_DATA_NUM 10 +BOOL get_HP203_data(float* tempdata, float* press) { - U_DataType collect_pressure[30]={0x00}; +// ѹǿ + U_DataType collect_pressure[COLLECT_HB203_DATA_NUM]={0x00}; - for(int i=0; i 1200) { tmp_press.fValue = 1200; - return FALSE; +// return FALSE; + goto error_return; + } +// ¶ + U_DataType collect_tempture[COLLECT_HB203_DATA_NUM]={0x00}; + + for(int i=0; i 85) + { + tmp_tempture.fValue = 85; +// return FALSE; + goto error_return; + } + + *tempdata = tmp_tempture.fValue; + *press = tmp_press.fValue; return TRUE; + +error_return: + *tempdata = 0; + *press = 0; + return FALSE; } \ No newline at end of file diff --git a/Drivers/HP203B/hp203b.h b/Drivers/HP203B/hp203b.h index 8e77275..2823166 100644 --- a/Drivers/HP203B/hp203b.h +++ b/Drivers/HP203B/hp203b.h @@ -25,9 +25,7 @@ extern "C" { #define HP20X_CONVERT_OSR1024 0x48 void hp203_set_mode(); -float Hp203bReadPressure(void); -BOOL get_press_data(void); - +BOOL get_HP203_data(float* tempdata, float* press); #ifdef __cplusplus } diff --git a/Drivers/Sht3x/sht30.c b/Drivers/Sht3x/sht30.c index f1e1a18..6d81822 100644 --- a/Drivers/Sht3x/sht30.c +++ b/Drivers/Sht3x/sht30.c @@ -127,15 +127,16 @@ u_int8_t sht30_collect_data(stTempHumiSensor stSensorDev, float *temp, float *hu #define COLLECT_DATA_NUM 10 BOOL get_temp_humi_data(float* temdata, float* humidata) { - U_DataType collect_temdata[30]={0x00}; - U_DataType collect_humidata[30]={0x00}; + U_DataType collect_temdata[COLLECT_DATA_NUM]={0x00}; + U_DataType collect_humidata[COLLECT_DATA_NUM]={0x00}; U_DataType tmp_temdata,tmp_humidata; for(int i=0; i 125) { tmp_temdata.fValue = 125; // term_printf("sht30¶ֵУʧ"); - return FALSE; +// return FALSE; + goto error_return; } if(tmp_humidata.fValue < 0) { tmp_humidata.fValue = 0; // term_printf("sht30ʪֵУʧ"); - return FALSE; +// return FALSE; + goto error_return; } if(tmp_humidata.fValue > 100) { tmp_humidata.fValue = 100; // term_printf("sht3ʪֵУʧ"); - return FALSE; +// return FALSE; + goto error_return; } *temdata = tmp_temdata.fValue; @@ -176,6 +181,11 @@ BOOL get_temp_humi_data(float* temdata, float* humidata) //g_stTempHumiData.temp = tmp_temdata.fValue; //g_stTempHumiData.humi = tmp_humidata.fValue; return TRUE; + +error_return: + *temdata = 0; + *humidata = 0; + return FALSE; } #if 0 diff --git a/EWARM/micro_climate.ewd b/EWARM/micro_climate.ewd index 5b5b0b7..c567dea 100644 --- a/EWARM/micro_climate.ewd +++ b/EWARM/micro_climate.ewd @@ -1612,4 +1612,1615 @@ + + REMOTE_UPDATE + + ARM + + 1 + + C-SPY + 2 + + 33 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 1 + + + + + + + + CADI_ID + 2 + + 0 + 1 + 1 + + + + + + + + + CMSISDAP_ID + 2 + + 4 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + E2_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + + IJET_ID + 2 + + 9 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JLINK_ID + 2 + + 16 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 3 + 1 + 1 + + + + + + + + + + + + + NULINK_ID + 2 + + 0 + 1 + 1 + + + + + + + PEMICRO_ID + 2 + + 3 + 1 + 1 + + + + + + + + STLINK_ID + 2 + + 8 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 1 + + + + + + + + TIFET_ID + 2 + + 1 + 1 + 1 + + + + + + + + + + + + + + + + + + + XDS100_ID + 2 + + 9 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\FreeRtos\FreeRtosArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin2.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9a.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin + 0 + + + diff --git a/EWARM/micro_climate.ewp b/EWARM/micro_climate.ewp index 39e17c8..64b1be5 100644 --- a/EWARM/micro_climate.ewp +++ b/EWARM/micro_climate.ewp @@ -701,7 +701,7 @@ - 232 + 1 inputOutputBased @@ -1111,6 +1111,1117 @@ + + REMOTE_UPDATE + + ARM + + 1 + + General + 3 + + 36 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 38 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 12 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + 1 + inputOutputBased + + + + ILINK + 0 + + 27 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BUILDACTION + 2 + + + + Coder + 0 + + + Application diff --git a/README.md b/README.md index 8fbff00..8d79961 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ | :-: | :------------------: | | 0 | 南北方向探头遮挡 | | 1 | 东西方向探头遮挡 | -| 1 | | -| 3 | | +| 1 | SHT30报错(温湿度传感器) | +| 3 | HP203B报错(大气压传感器) | | 4 | | | 5 | | | 6 | |