micro_climate/Device/anemometer.h

83 lines
1.5 KiB
C

#ifndef _ANEMOMETER__H_
#define _ANEMOMETER__H_
#include "adc.h"
#include "dma.h"
#include "i2c.h"
#include "usart.h"
#include "tim.h"
#include "gpio.h"
#include "stdio.h"
#include "string.h"
#include "math.h"
#include "arr_tool.h"
#include "FreeRTOS.h"
#include "cmsis_os.h"
#include "arm_math.h"
#include "xcorr.h"
// 延时REV_MUTE_DELAY us启动ADC采集数据
#define REV_MUTE_DELAY 150
// adc 采样率
// 5 5M
// 4 4M
// 3 3M
#define ADC_SAMP_RATE 2.5
// x方向
#define WIND_DIRECTION_X 0x00
// y方向
#define WIND_DIRECTION_Y 0x01
// adc 采集buf长度
#define ADC_VAL_LEN 1024
extern int16_t adc_val[ADC_VAL_LEN];
extern int16_t adc_val1[ADC_VAL_LEN];
typedef struct __weather_param
{
float32_t wind_velocity_x;
// 校准dtof 偏差
//float32_t wind_velocity_x_dtof_offset;
float32_t wind_velocity_y;
//float32_t wind_velocity_y_offset;
// 风速
float32_t wind_velocity;
// 超声波传播速度
float32_t wind_c;
// 风向
float32_t wind_angle;
// 温度
float32_t temperature;
// 湿度
float32_t humidity;
// 降雨量
float32_t precipitation;
} Weather_param;
extern Weather_param weather_info;
// 切换通道
void change_channel(uint32_t channel);
// 采集一次数据
void play_one_measure(int16_t* result_data,uint32_t len);
// 通过采集的数据计算 风速 风向
void calculate_param(Weather_param *parm ,uint32_t direction , int16_t *adc_buf1,int16_t *adc_buf2,uint32_t len);
void wind_task(void const * argument);
#endif