Compare commits

...

4 Commits

14 changed files with 4198 additions and 108 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
EWARM/micro_climate/ EWARM/micro_climate/
EWARM/REMOTE_UPDATE/
EWARM/settings/ EWARM/settings/
frt_protocol.c
软件框架图.vsdx 软件框架图.vsdx
软件流程图.vsdx 软件流程图.vsdx
赛联-微气象传感器软件设计说明书.docx 赛联-微气象传感器软件设计说明书.docx

View File

@ -39,11 +39,12 @@
#define DRIVE_NUM 2 #define DRIVE_NUM 2
///已将DISTANCE写入配置文件在结构体g_stConfigInfo.transducer_distace中
// 传播距离 风速计算公式中的L参数 // 传播距离 风速计算公式中的L参数
//探头表面距离115.12mm(57.56mm*2)换能器探头到探头表面距离暂定2mm(1mm*2) //探头表面距离115.12mm(57.56mm*2)换能器探头到探头表面距离暂定2mm(1mm*2)
//#define DISTANCE ((float32_t)115120.0 + (float32_t)2000.0) //#define DISTANCE ((float32_t)115120.0 + (float32_t)2000.0)
//探头表面距离115.12mm(57.56mm*2)换能器内部2mm速度2000时间算2us减在tof上 //探头表面距离115.12mm(57.56mm*2)换能器内部2mm速度2000时间算2us减在tof上
#define DISTANCE ((float32_t)115120.0) //#define DISTANCE ((float32_t)115120.0)
// 传播距离 风速计算公式中的L参数 // 传播距离 风速计算公式中的L参数
//#define DISTANCE ((float32_t)120000.0) //#define DISTANCE ((float32_t)120000.0)
// 富奥通结构 L = 118946 // 富奥通结构 L = 118946
@ -125,8 +126,8 @@ extern mcs_para g_stMcs_Para;
typedef struct _error_log{ typedef struct _error_log{
uint16_t tof_error_NS:1; /* 接受南北信号tofytofx<0很小 */ uint16_t tof_error_NS:1; /* 接受南北信号tofytofx<0很小 */
uint16_t tof_error_WE:1; /* 接受东西信号tofytofx<0很小 */ uint16_t tof_error_WE:1; /* 接受东西信号tofytofx<0很小 */
uint16_t error_2:1; /* 保留 */ uint16_t temp_error_SHT30:1; /* SHT30错误日志温湿度 */
uint16_t error_3:1; /* 保留 */ uint16_t temp_error_HP203B:1; /* HP203B错误日志大气压 */
uint16_t error_4:1; /* 保留 */ uint16_t error_4:1; /* 保留 */
uint16_t error_5:1; /* 保留 */ uint16_t error_5:1; /* 保留 */
uint16_t error_6:1; /* 保留 */ uint16_t error_6:1; /* 保留 */

View File

@ -48,19 +48,20 @@ typedef enum
FRT_REGISTER_TRANSDUCER_CFG_4R5 = 31, /* 换能器参数 */ FRT_REGISTER_TRANSDUCER_CFG_4R5 = 31, /* 换能器参数 */
FRT_REGISTER_TRANSDUCER_CFG_8R0 = 32, /* 换能器参数 */ FRT_REGISTER_TRANSDUCER_CFG_8R0 = 32, /* 换能器参数 */
FRT_REGISTER_RSSI_RANGE = 33, /* RSSI有效范围 */ FRT_REGISTER_RSSI_RANGE = 33, /* RSSI有效范围 */
FRT_REGISTER_WAVE_DATA = 34, /* 波形数据 */ FRT_REGISTER_DISTANCE = 34, /* 换能器表面距离 */
FRT_REGISTER_ERROR_LOG = 35, /* 错误日志 */ FRT_REGISTER_ERROR_LOG = 35, /* 错误日志 */
FRT_REGISTER_LINEAR_POINT_X_1 = 36, /* 线性插值原始点1 */ FRT_REGISTER_WIND_C = 36, /* 计算得到的风速 */
FRT_REGISTER_LINEAR_POINT_X_2 = 37, /* 线性插值原始点2 */ FRT_REGISTER_LINEAR_POINT_X_1 = 37, /* 线性插值原始点1 */
FRT_REGISTER_LINEAR_POINT_X_3 = 38, /* 线性插值原始点3 */ FRT_REGISTER_LINEAR_POINT_X_2 = 38, /* 线性插值原始点2 */
FRT_REGISTER_LINEAR_POINT_X_4 = 39, /* 线性插值原始点4 */ FRT_REGISTER_LINEAR_POINT_X_3 = 39, /* 线性插值原始点3 */
FRT_REGISTER_LINEAR_POINT_X_5 = 40, /* 线性插值原始点5 */ FRT_REGISTER_LINEAR_POINT_X_4 = 40, /* 线性插值原始点4 */
FRT_REGISTER_LINEAR_POINT_Y_1 = 41, /* 线性插值校准点1 */ FRT_REGISTER_LINEAR_POINT_X_5 = 41, /* 线性插值原始点5 */
FRT_REGISTER_LINEAR_POINT_Y_2 = 42, /* 线性插值校准点2 */ FRT_REGISTER_LINEAR_POINT_Y_1 = 42, /* 线性插值校准点1 */
FRT_REGISTER_LINEAR_POINT_Y_3 = 43, /* 线性插值校准点3 */ FRT_REGISTER_LINEAR_POINT_Y_2 = 43, /* 线性插值校准点2 */
FRT_REGISTER_LINEAR_POINT_Y_4 = 44, /* 线性插值校准点4 */ FRT_REGISTER_LINEAR_POINT_Y_3 = 44, /* 线性插值校准点3 */
FRT_REGISTER_LINEAR_POINT_Y_5 = 45, /* 线性插值校准点5 */ FRT_REGISTER_LINEAR_POINT_Y_4 = 45, /* 线性插值校准点4 */
FRT_REGISTER_LINEAR_ENABLE = 46, /* 线性插值使能 */ FRT_REGISTER_LINEAR_POINT_Y_5 = 46, /* 线性插值校准点5 */
FRT_REGISTER_LINEAR_ENABLE = 47, /* 线性插值使能 */
}FRT_MsgRegister; }FRT_MsgRegister;
#pragma pack(push,1) #pragma pack(push,1)

View File

@ -27,6 +27,7 @@ typedef struct _config_info{
u_int16_t transducer_cfg_4R5; /* 换能器参数 */ u_int16_t transducer_cfg_4R5; /* 换能器参数 */
u_int16_t transducer_cfg_8R0; /* 换能器参数 */ u_int16_t transducer_cfg_8R0; /* 换能器参数 */
u_int16_t RSSI_range; /* RSSI有效范围 */ u_int16_t RSSI_range; /* RSSI有效范围 */
u_int16_t transducer_distace; /* 换能器表面距离 */
u_int16_t linear_point_1_x; /* 线性插值点1X */ u_int16_t linear_point_1_x; /* 线性插值点1X */
u_int16_t linear_point_1_y; /* 线性插值点1Y */ u_int16_t linear_point_1_y; /* 线性插值点1Y */
u_int16_t linear_point_2_x; /* 线性插值点2X */ u_int16_t linear_point_2_x; /* 线性插值点2X */

View File

@ -98,8 +98,8 @@ float32_t find_maxValPosition_by_sinInterpolation(float32_t a,float32_t b,float3
float32_t RSSI; float32_t RSSI;
/*****************滤波器BUFF**********/ /*****************滤波器BUFF**********/
float32_t buf[1024]; float32_t buf[ADC_VAL_LEN];
float32_t buf2[1024]; float32_t buf2[ADC_VAL_LEN];
/*****************滤波器BUFF**********/ /*****************滤波器BUFF**********/
float32_t cal_tof(q15_t* x,uint32_t len) float32_t cal_tof(q15_t* x,uint32_t len)
{ {
@ -439,10 +439,10 @@ void wind_task(void const * argument)
// 通过各通道渡越时间求时间差 // 通过各通道渡越时间求时间差
dtof = tofx-tofy; dtof = tofx-tofy;
weather_info.wind_c = DISTANCE/2.0f*(1.0f/tofx+1.0f/tofy); weather_info.wind_c = (g_stConfigInfo.transducer_distace * 2.0f)/2.0f*(1.0f/tofx+1.0f/tofy);
// weather_info.wind_velocity_x = 0-DISTANCE*dtof/1.41422f/tofx/tofx; // weather_info.wind_velocity_x = 0-DISTANCE*dtof/1.41422f/tofx/tofx;
// 修正公式 // 修正公式
weather_info.wind_velocity_x = 0-DISTANCE*dtof/1.41422f/tofx/tofy; weather_info.wind_velocity_x = 0-(g_stConfigInfo.transducer_distace * 2.0f)*dtof/1.41422f/tofx/tofy;
} }
// 通道3 通道4 测试东西风速 // 通道3 通道4 测试东西风速
@ -499,10 +499,10 @@ void wind_task(void const * argument)
// 通过各通道渡越时间求时间差 // 通过各通道渡越时间求时间差
dtof = tofx-tofy; dtof = tofx-tofy;
weather_info.wind_c = DISTANCE/2.0f*(1.0f/tofx+1.0f/tofy); weather_info.wind_c = (g_stConfigInfo.transducer_distace * 2.0f)/2.0f*(1.0f/tofx+1.0f/tofy);
// weather_info.wind_velocity_y = DISTANCE*dtof/1.41422f/tofx/tofx; // weather_info.wind_velocity_y = DISTANCE*dtof/1.41422f/tofx/tofx;
// 修正公式 // 修正公式
weather_info.wind_velocity_y = DISTANCE*dtof/1.41422f/tofx/tofy; weather_info.wind_velocity_y = (g_stConfigInfo.transducer_distace * 2.0f)*dtof/1.41422f/tofx/tofy;
} }
weather_info.wind_velocity = sqrtf(weather_info.wind_velocity_x*weather_info.wind_velocity_x + weather_info.wind_velocity_y*weather_info.wind_velocity_y); weather_info.wind_velocity = sqrtf(weather_info.wind_velocity_x*weather_info.wind_velocity_x + weather_info.wind_velocity_y*weather_info.wind_velocity_y);
@ -858,26 +858,50 @@ void tem_hum_update_task(void const * argument)
int time_s_temp_humi = 0; int time_s_temp_humi = 0;
uint32_t time_s_1Day = 0; uint32_t time_s_1Day = 0;
float backupTemperature;
get_temp_humi_data(&g_stMcs_Para.temperature, &g_stMcs_Para.humidity);//开机先采集一次 get_temp_humi_data(&g_stMcs_Para.temperature, &g_stMcs_Para.humidity);//开机先采集一次
while(1) while(1)
{ {
osDelay(1000); osDelay(1000);
time_s_temp_humi ++; time_s_temp_humi ++;
time_s_1Day ++; 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; time_s_temp_humi = 0;
} }
// 一天重启
if (time_s_1Day >= 86400) if (time_s_1Day >= 86400)
{ {
__iar_builtin_set_FAULTMASK(1); __iar_builtin_set_FAULTMASK(1);
NVIC_SystemReset(); NVIC_SystemReset();
} }
// 风速风向更新
my_update_mcs_param(av_speed, av_angle); my_update_mcs_param(av_speed, av_angle);
//采集HP203B数据(大气压)
get_press_data();
} }
} }

View File

@ -44,8 +44,9 @@ static u_int16_t FRT_ReadRegTransducerCFG1R5(void *pMsg);
static u_int16_t FRT_ReadRegTransducerCFG4R5(void *pMsg); static u_int16_t FRT_ReadRegTransducerCFG4R5(void *pMsg);
static u_int16_t FRT_ReadRegTransducerCFG8R0(void *pMsg); static u_int16_t FRT_ReadRegTransducerCFG8R0(void *pMsg);
static u_int16_t FRT_ReadRegRSSIRange(void *pMsg); static u_int16_t FRT_ReadRegRSSIRange(void *pMsg);
static u_int16_t FRT_ReadRegWaveData(void *pMsg); static u_int16_t FRT_ReadRegDISTANCE(void *pMsg);
static u_int16_t FRT_ReadRegErrorData(void *pMsg); static u_int16_t FRT_ReadRegErrorData(void *pMsg);
static u_int16_t FRT_ReadRegWindC(void *pMsg);
static u_int16_t FRT_ReadRegPoint_1X(void *pMsg); static u_int16_t FRT_ReadRegPoint_1X(void *pMsg);
static u_int16_t FRT_ReadRegPoint_2X(void *pMsg); static u_int16_t FRT_ReadRegPoint_2X(void *pMsg);
static u_int16_t FRT_ReadRegPoint_3X(void *pMsg); static u_int16_t FRT_ReadRegPoint_3X(void *pMsg);
@ -62,6 +63,7 @@ static u_int16_t FRT_WriteRegTransducerCFG1R5(void *pMsg);
static u_int16_t FRT_WriteRegTransducerCFG4R5(void *pMsg); static u_int16_t FRT_WriteRegTransducerCFG4R5(void *pMsg);
static u_int16_t FRT_WriteRegTransducerCFG8R0(void *pMsg); static u_int16_t FRT_WriteRegTransducerCFG8R0(void *pMsg);
static u_int16_t FRT_WriteRegRSSIRange(void *pMsg); static u_int16_t FRT_WriteRegRSSIRange(void *pMsg);
static u_int16_t FRT_WriteRegDISTANCE(void *pMsg);
static u_int16_t FRT_WriteRegPoint_1Y(void *pMsg); static u_int16_t FRT_WriteRegPoint_1Y(void *pMsg);
static u_int16_t FRT_WriteRegPoint_2Y(void *pMsg); static u_int16_t FRT_WriteRegPoint_2Y(void *pMsg);
static u_int16_t FRT_WriteRegPoint_3Y(void *pMsg); static u_int16_t FRT_WriteRegPoint_3Y(void *pMsg);
@ -101,7 +103,9 @@ FRT_RegProcTable_s g_RegTbl[] =
{ FRT_REGISTER_TRANSDUCER_CFG_4R5, FRT_ReadRegTransducerCFG4R5 }, /* 读换能器参数寄存器值4R5 */ { FRT_REGISTER_TRANSDUCER_CFG_4R5, FRT_ReadRegTransducerCFG4R5 }, /* 读换能器参数寄存器值4R5 */
{ FRT_REGISTER_TRANSDUCER_CFG_8R0, FRT_ReadRegTransducerCFG8R0 }, /* 读换能器参数寄存器值8R0 */ { FRT_REGISTER_TRANSDUCER_CFG_8R0, FRT_ReadRegTransducerCFG8R0 }, /* 读换能器参数寄存器值8R0 */
{ FRT_REGISTER_RSSI_RANGE, FRT_ReadRegRSSIRange }, /* 读RSSI有效范围 */ { FRT_REGISTER_RSSI_RANGE, FRT_ReadRegRSSIRange }, /* 读RSSI有效范围 */
{ FRT_REGISTER_DISTANCE, FRT_ReadRegDISTANCE }, /* 读探头表面有效距离 */
{ FRT_REGISTER_ERROR_LOG, FRT_ReadRegErrorData }, /* 读错误日志 */ { FRT_REGISTER_ERROR_LOG, FRT_ReadRegErrorData }, /* 读错误日志 */
{ FRT_REGISTER_WIND_C, FRT_ReadRegWindC }, /* 读计算得到的风速 */
{ FRT_REGISTER_LINEAR_POINT_X_1, FRT_ReadRegPoint_1X }, /* 线性插值原始点1 */ { FRT_REGISTER_LINEAR_POINT_X_1, FRT_ReadRegPoint_1X }, /* 线性插值原始点1 */
{ FRT_REGISTER_LINEAR_POINT_X_2, FRT_ReadRegPoint_2X }, /* 线性插值原始点2 */ { FRT_REGISTER_LINEAR_POINT_X_2, FRT_ReadRegPoint_2X }, /* 线性插值原始点2 */
{ FRT_REGISTER_LINEAR_POINT_X_3, FRT_ReadRegPoint_3X }, /* 线性插值原始点3 */ { FRT_REGISTER_LINEAR_POINT_X_3, FRT_ReadRegPoint_3X }, /* 线性插值原始点3 */
@ -128,6 +132,7 @@ FRT_RegProcTable_s g_Write_RegTbl[] =
{ FRT_REGISTER_TRANSDUCER_CFG_4R5, FRT_WriteRegTransducerCFG4R5 }, /* 写换能器参数寄存器值4R5 */ { FRT_REGISTER_TRANSDUCER_CFG_4R5, FRT_WriteRegTransducerCFG4R5 }, /* 写换能器参数寄存器值4R5 */
{ FRT_REGISTER_TRANSDUCER_CFG_8R0, FRT_WriteRegTransducerCFG8R0 }, /* 写换能器参数寄存器值8R0 */ { FRT_REGISTER_TRANSDUCER_CFG_8R0, FRT_WriteRegTransducerCFG8R0 }, /* 写换能器参数寄存器值8R0 */
{ FRT_REGISTER_RSSI_RANGE, FRT_WriteRegRSSIRange }, /* 写RSSI有效范围 */ { FRT_REGISTER_RSSI_RANGE, FRT_WriteRegRSSIRange }, /* 写RSSI有效范围 */
{ FRT_REGISTER_DISTANCE, FRT_WriteRegDISTANCE }, /* 写探头表面有效距离 */
{ FRT_REGISTER_LINEAR_POINT_Y_1, FRT_WriteRegPoint_1Y }, /* 线性插值校准点1 */ { FRT_REGISTER_LINEAR_POINT_Y_1, FRT_WriteRegPoint_1Y }, /* 线性插值校准点1 */
{ FRT_REGISTER_LINEAR_POINT_Y_2, FRT_WriteRegPoint_2Y }, /* 线性插值校准点2 */ { FRT_REGISTER_LINEAR_POINT_Y_2, FRT_WriteRegPoint_2Y }, /* 线性插值校准点2 */
{ FRT_REGISTER_LINEAR_POINT_Y_3, FRT_WriteRegPoint_3Y }, /* 线性插值校准点3 */ { FRT_REGISTER_LINEAR_POINT_Y_3, FRT_WriteRegPoint_3Y }, /* 线性插值校准点3 */
@ -503,6 +508,18 @@ static u_int16_t FRT_ReadRegRSSIRange(void *pMsg)
return FRT_swap_endian_16(value); return FRT_swap_endian_16(value);
} }
/**
* @brief
* @param
* @retval
*/
static u_int16_t FRT_ReadRegDISTANCE(void *pMsg)
{
read_config_info();
u_int16_t value=g_stConfigInfo.transducer_distace;
return FRT_swap_endian_16(value);
}
/** /**
* @brief * @brief
* @param * @param
@ -514,6 +531,17 @@ static u_int16_t FRT_ReadRegErrorData(void *pMsg)
return FRT_swap_endian_16(value); return FRT_swap_endian_16(value);
} }
/**
* @brief
* @param
* @retval
*/
static u_int16_t FRT_ReadRegWindC(void *pMsg)
{
u_int16_t value=weather_info.wind_c = 0;
return FRT_swap_endian_16(value);
}
/** /**
* @brief 线1 * @brief 线1
* @param * @param
@ -699,6 +727,22 @@ static u_int16_t FRT_WriteRegRSSIRange(void *pMsg)
return 0; return 0;
} }
/**
* @brief
* @param
* @retval
*/
static u_int16_t FRT_WriteRegDISTANCE(void *pMsg)
{
uint16_t *pMsgAddr = (uint16_t *)pMsg;
uint16_t data = *pMsgAddr;
g_stConfigInfo.transducer_distace = data;
save_config_info(g_stConfigInfo);
return 0;
}
/** /**
* @brief 线1 * @brief 线1
* @param * @param
@ -894,9 +938,9 @@ void FRT_MsgProc_ReadRegister(device_handle device, void *pMsg)
u_int16_t reg_num= (data[4] << 8)| data[5]; u_int16_t reg_num= (data[4] << 8)| data[5];
if ( \ if ( \
start_reg_addr < 0x00 ||\ start_reg_addr < 0x00 ||\
(start_reg_addr > 0x08 && start_reg_addr < 0x14) ||\ (start_reg_addr > FRT_REGISTER_PRESSURE && start_reg_addr < FRT_REGISTER_DEVICE_ADDR) ||\
(start_reg_addr > 0x17 && start_reg_addr < 0x1E) ||\ (start_reg_addr > FRT_REGISTER_TEMPHUM_UPDATE_TIME && start_reg_addr < FRT_REGISTER_TRANSDUCER_CFG_1R5) ||\
start_reg_addr > 0x2E \ start_reg_addr > FRT_REGISTER_LINEAR_ENABLE \
) )
{ {
@ -906,9 +950,9 @@ void FRT_MsgProc_ReadRegister(device_handle device, void *pMsg)
if ( \ if ( \
reg_num < 0x01 ||\ reg_num < 0x01 ||\
(((reg_num + start_reg_addr - 1) > 0x08) && ((reg_num + start_reg_addr - 1) < 0x14)) ||\ (((reg_num + start_reg_addr - 1) > FRT_REGISTER_PRESSURE) && ((reg_num + start_reg_addr - 1) < FRT_REGISTER_DEVICE_ADDR)) ||\
(((reg_num + start_reg_addr -1) > 0x17) && ((reg_num + start_reg_addr -1) < 0x1E)) ||\ (((reg_num + start_reg_addr -1) > FRT_REGISTER_TEMPHUM_UPDATE_TIME) && ((reg_num + start_reg_addr -1) < FRT_REGISTER_TRANSDUCER_CFG_1R5)) ||\
((reg_num + start_reg_addr -1) > 0x2E) \ ((reg_num + start_reg_addr -1) > FRT_REGISTER_LINEAR_ENABLE) \
) )
{ {
@ -957,20 +1001,20 @@ void FRT_MsgProc_WriteRegister(device_handle device, void *pMsg)
unsigned short return_crc_value; unsigned short return_crc_value;
// 校验 // 校验
if (start_reg_addr < 0x14 ||\ if (start_reg_addr < FRT_REGISTER_DEVICE_ADDR ||\
(start_reg_addr > 0x1C && start_reg_addr < 0x1E)||\ (start_reg_addr > FRT_REGISTER_REST_DEFAULT_SETTING && start_reg_addr < FRT_REGISTER_TRANSDUCER_CFG_1R5) ||\
(start_reg_addr > 0x21 && start_reg_addr < 0x29)||\ (start_reg_addr > FRT_REGISTER_DISTANCE && start_reg_addr < FRT_REGISTER_LINEAR_POINT_Y_1) ||\
(start_reg_addr > 0x2E) (start_reg_addr > FRT_REGISTER_LINEAR_ENABLE) \
) )
{ {
term_printf("start_reg_addr error:%d", start_reg_addr); term_printf("start_reg_addr error:%d", start_reg_addr);
return; return;
} }
if (reg_num < 0x01 ||\ if (reg_num < 0x01 ||\
((reg_num + start_reg_addr - 1) < 0x14) ||\ ((reg_num + start_reg_addr - 1) < FRT_REGISTER_DEVICE_ADDR) ||\
(((reg_num + start_reg_addr -1) > 0x1C) && ((reg_num + start_reg_addr -1) < 0x1E)) ||\ (((reg_num + start_reg_addr -1) > FRT_REGISTER_REST_DEFAULT_SETTING) && ((reg_num + start_reg_addr -1) < FRT_REGISTER_TRANSDUCER_CFG_1R5)) ||\
(((reg_num + start_reg_addr -1) > 0x21) && ((reg_num + start_reg_addr -1) < 0x29)) ||\ (((reg_num + start_reg_addr -1) > FRT_REGISTER_DISTANCE) && ((reg_num + start_reg_addr -1) < FRT_REGISTER_LINEAR_POINT_Y_1)) ||\
((reg_num + start_reg_addr -1) > 0x2E) ((reg_num + start_reg_addr -1) > FRT_REGISTER_LINEAR_ENABLE) \
) )
{ {
term_printf("reg_num error:%d", reg_num); term_printf("reg_num error:%d", reg_num);

1230
App/Src/frt_protocol.c.orig Normal file

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@ config_info g_stConfigInfo={
.transducer_cfg_4R5 = 35, /* 无锡电声换能器参数 */ .transducer_cfg_4R5 = 35, /* 无锡电声换能器参数 */
.transducer_cfg_8R0 = 65, /* 无锡电声换能器参数 */ .transducer_cfg_8R0 = 65, /* 无锡电声换能器参数 */
.RSSI_range = 20, /* RSSI大于0.2有效 */ .RSSI_range = 20, /* RSSI大于0.2有效 */
.transducer_distace = 57560, /* 换能器探头表面距离 */
.linear_point_1_x = 0, /* 线性插值点1 */ .linear_point_1_x = 0, /* 线性插值点1 */
.linear_point_1_y = 0, /* 线性插值点1 */ .linear_point_1_y = 0, /* 线性插值点1 */

View File

@ -3,7 +3,6 @@
#include "filter.h" #include "filter.h"
#include "anemometer_dev.h" #include "anemometer_dev.h"
/**************************** /****************************
*set_mode *set_mode
* *
@ -22,10 +21,10 @@ void hp203_set_mode()
/**************************** /****************************
*Hp203bReadPressure *Hp203bReadPressure
* *
*Press-- *
* *
* *
* *
*****************************/ *****************************/
float Hp203bReadPressure(void) float Hp203bReadPressure(void)
{ {
@ -48,36 +47,95 @@ float Hp203bReadPressure(void)
return ret; return ret;
} }
/****************************
*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 *get_press_data
* *
*Press-- *Press--
* *
* *
* *
*****************************/ *****************************/
#define COLLECT_PRESS_DATA_NUM 10 #define COLLECT_HB203_DATA_NUM 10
BOOL get_press_data(void) 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<COLLECT_PRESS_DATA_NUM; i++){ for(int i=0; i<COLLECT_HB203_DATA_NUM; i++){
collect_pressure[i].fValue = Hp203bReadPressure(); collect_pressure[i].fValue = Hp203bReadPressure();
osDelay(1); osDelay(1);
} }
U_DataType tmp_press = filter_middle(collect_pressure, COLLECT_PRESS_DATA_NUM, FILTER_DATA_TYPE_FLOAT); U_DataType tmp_press = filter_middle(collect_pressure, COLLECT_HB203_DATA_NUM, FILTER_DATA_TYPE_FLOAT);
if(tmp_press.fValue < 300) if(tmp_press.fValue < 300)
{ {
tmp_press.fValue = 300; tmp_press.fValue = 300;
return FALSE; // return FALSE;
goto error_return;
} }
if(tmp_press.fValue > 1200) if(tmp_press.fValue > 1200)
{ {
tmp_press.fValue = 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<COLLECT_HB203_DATA_NUM; i++){
collect_tempture[i].fValue = Hp203bReadTempture();
osDelay(1);
} }
g_stMcs_Para.pressure = tmp_press.fValue; U_DataType tmp_tempture = filter_middle(collect_tempture, COLLECT_HB203_DATA_NUM, 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;
}
*tempdata = tmp_tempture.fValue;
*press = tmp_press.fValue;
return TRUE; return TRUE;
error_return:
*tempdata = 0;
*press = 0;
return FALSE;
} }

View File

@ -25,9 +25,7 @@ extern "C" {
#define HP20X_CONVERT_OSR1024 0x48 #define HP20X_CONVERT_OSR1024 0x48
void hp203_set_mode(); void hp203_set_mode();
float Hp203bReadPressure(void); BOOL get_HP203_data(float* tempdata, float* press);
BOOL get_press_data(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -127,15 +127,16 @@ u_int8_t sht30_collect_data(stTempHumiSensor stSensorDev, float *temp, float *hu
#define COLLECT_DATA_NUM 10 #define COLLECT_DATA_NUM 10
BOOL get_temp_humi_data(float* temdata, float* humidata) BOOL get_temp_humi_data(float* temdata, float* humidata)
{ {
U_DataType collect_temdata[30]={0x00}; U_DataType collect_temdata[COLLECT_DATA_NUM]={0x00};
U_DataType collect_humidata[30]={0x00}; U_DataType collect_humidata[COLLECT_DATA_NUM]={0x00};
U_DataType tmp_temdata,tmp_humidata; U_DataType tmp_temdata,tmp_humidata;
for(int i=0; i<COLLECT_DATA_NUM; i++){ for(int i=0; i<COLLECT_DATA_NUM; i++){
int ret = sht30_collect_data(g_stTempHumiSensor,&collect_temdata[i].fValue, &collect_humidata[i].fValue); int ret = sht30_collect_data(g_stTempHumiSensor,&collect_temdata[i].fValue, &collect_humidata[i].fValue);
// AssertError(ret == HAL_OK, return FALSE, "sht30²ÉÑùʧ°Ü"); // AssertError(ret == HAL_OK, return FALSE, "sht30²ÉÑùʧ°Ü");
if(ret == HAL_ERROR) if(ret == HAL_ERROR)
return FALSE; // return FALSE;
goto error_return;
osDelay(1); osDelay(1);
} }
@ -149,25 +150,29 @@ BOOL get_temp_humi_data(float* temdata, float* humidata)
{ {
tmp_temdata.fValue = -40; tmp_temdata.fValue = -40;
// term_printf("sht30ζÈֵУÑéʧ°Ü"); // term_printf("sht30ζÈֵУÑéʧ°Ü");
return FALSE; // return FALSE;
goto error_return;
} }
if(tmp_temdata.fValue > 125) if(tmp_temdata.fValue > 125)
{ {
tmp_temdata.fValue = 125; tmp_temdata.fValue = 125;
// term_printf("sht30ζÈֵУÑéʧ°Ü"); // term_printf("sht30ζÈֵУÑéʧ°Ü");
return FALSE; // return FALSE;
goto error_return;
} }
if(tmp_humidata.fValue < 0) if(tmp_humidata.fValue < 0)
{ {
tmp_humidata.fValue = 0; tmp_humidata.fValue = 0;
// term_printf("sht30ʪ¶ÈֵУÑéʧ°Ü"); // term_printf("sht30ʪ¶ÈֵУÑéʧ°Ü");
return FALSE; // return FALSE;
goto error_return;
} }
if(tmp_humidata.fValue > 100) if(tmp_humidata.fValue > 100)
{ {
tmp_humidata.fValue = 100; tmp_humidata.fValue = 100;
// term_printf("sht3ʪ¶ÈֵУÑéʧ°Ü"); // term_printf("sht3ʪ¶ÈֵУÑéʧ°Ü");
return FALSE; // return FALSE;
goto error_return;
} }
*temdata = tmp_temdata.fValue; *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.temp = tmp_temdata.fValue;
//g_stTempHumiData.humi = tmp_humidata.fValue; //g_stTempHumiData.humi = tmp_humidata.fValue;
return TRUE; return TRUE;
error_return:
*temdata = 0;
*humidata = 0;
return FALSE;
} }
#if 0 #if 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -49,8 +49,8 @@
| :-: | :------------------: | | :-: | :------------------: |
| 0 | 南北方向探头遮挡 | | 0 | 南北方向探头遮挡 |
| 1 | 东西方向探头遮挡 | | 1 | 东西方向探头遮挡 |
| 1 | | | 1 | SHT30报错温湿度传感器 |
| 3 | | | 3 | HP203B报错大气压传感器 |
| 4 | | | 4 | |
| 5 | | | 5 | |
| 6 | | | 6 | |