micro_climate/tools/xcorr.h

44 lines
21 KiB
C
Raw Normal View History

2024-07-05 03:52:43 +00:00
#ifndef __XCORR_H__
#define __XCORR_H__
#include "stm32l4xx_hal.h"
#include "math.h"
#include "arm_math.h"
#include "tim.h"
#include "main.h"
#include "stdio.h"
#include "string.h"
#include "adc.h"
#define DATA_LEN 512
//const float x[DATA_LEN] = {
//2076,2079,2082,2081,2080,2076,2073,2067,2063,2056,2053,2048,2045,2044,2043,2043,2042,2043,2046,2049,2050,2053,2058,2060,2064,2067,2067,2068,2067,2067,2064,2061,2058,2055,2051,2049,2046,2047,2046,2044,2045,2044,2046,2049,2050,2056,2061,2065,2068,2069,2068,2068,2066,2064,2060,2056,2053,2051,2046,2046,2042,2039,2038,2037,2038,2039,2040,2042,2046,2049,2050,2053,2056,2059,2061,2062,2064,2065,2064,2062,2060,2056,2053,2049,2045,2044,2039,2037,2036,2035,2035,2037,2039,2043,2046,2052,2052,2055,2058,2060,2064,2067,2068,2070,2071,2068,2064,2059,2054,2050,2046,2044,2039,2038,2034,2034,2033,2033,2034,2037,2041,2044,2050,2053,2056,2062,2064,2066,2066,2068,2066,2064,2061,2057,2053,2049,2047,2043,2041,2039,2036,2036,2035,2037,2037,2041,2044,2047,2052,2054,2058,2064,2065,2066,2065,2064,2064,2061,2061,2060,2057,2052,2049,2045,2042,2038,2037,2035,2035,2034,2036,2037,2041,2044,2047,2051,2052,2056,2060,2062,2065,2066,2066,2067,2064,2062,2059,2057,2052,2048,2044,2042,2041,2036,2036,2034,2034,2036,2038,2040,2045,2050,2051,2054,2058,2061,2064,2067,2064,2064,2062,2060,2057,2053,2053,2050,2049,2044,2044,2040,2038,2037,2037,2037,2039,2042,2043,2047,2050,2050,2051,2054,2056,2058,2060,2061,2062,2061,2060,2059,2056,2054,2052,2049,2047,2047,2047,2047,2047,2047,2046,2048,2046,2050,2049,2048,2047,2049,2046,2047,2047,2049,2048,2049,2049,2048,2048,2047,2052,2048,2050,2053,2054,2055,2058,2057,2059,2058,2057,2057,2055,2053,2052,2050,2047,2048,2043,2045,2042,2041,2042,2042,2042,2042,2043,2046,2050,2049,2052,2055,2058,2061,2064,2065,2067,2067,2065,2062,2057,2054,2050,2047,2047,2044,2042,2038,2035,2032,2032,2032,2033,2036,2040,2045,2050,2053,2057,2061,2066,2068,2071,2071,2073,2072,2068,2067,2063,2058,2053,2045,2043,2036,2033,2027,2026,2024,2024,2026,2029,2035,2039,2045,2052,2057,2064,2067,2070,2072,2073,2074,2075,2072,2074,2070,2066,2059,2052,2045,2041,2036,2032,2027,2027,2026,2026,2029,2032,2036,2042,2046,2052,2054,2060,2064,2069,2071,2073,2071,2072,2068,2066,2061,2058,2052,2046,2045,2041,2037,2035,2033,2033,2032,2034,2036,2039,2043,2047,2051,2053,2057,2064,2067,2068,2068,2067,2065,2064,2060,2058,2056,2054,2051,2045,2043,2041,2037,2036,2035,2036,2037,2040,2042,2046,2049,2048,2051,2055,2057,2058,2061,2064,2064,2064,2064,2062,2061,2058,2056,2054,2050,2048,2045,2046,2043,2042,2039,2037,2038,2039,2041,2042,2045,2048,2049,2053,2055,2056,2057,2056,2057,2058,2058,2060,2060,2060,2058,2056,2053,2050,2047,2047,2045,2042,2042,2040,2040,2040,2040,2042,2043,2044,2046,2051,2051,2055,2059,2061,2064,2066,2067,2068,2067,2066,2064,2061,2058,2053,2051,2045,2044,2041,2038,2036,2033,2033,2034,2036,2038,2041,2042,2045,2048,2049,2053,2059,2064,2066,2067,2066,2065,2062,2058,2056,2052,2049,2045,2046,2043,2041,2040,2040,2042,2043,2045,2047,2050,2052,2055,2058,2060,2064,2065,2067,2067,2064,2064,2060,2056,2052,2047,2045,2041,2039,2034,2032,2032,2032,2033,2037,2041,2044,2049,2051,2055,2059,2064,2068,2071,2071,2071,2068,2064,2059,2054,2050,2046,2045,2043,2039,2036,2036,2036,2034,2035,2036,2039,2043,2047,2051,2054,2058,2064,2067,2070,2072,2073,2072,2071,2068,2066,2061,2055,2051,2046,2043,2039,2035,2033,2032,2031,2031,2030,2031,2034,2037,2044,2050,2054,2059,2061,2065,2066,2069,2068,2067,2067,2066,2064,2060,2056,2052,2049,2044,2042,2039,2037,2035,2035,2034,2036,2036,2039,2041,2045,2050,2050,2055,2059,2062,2065,2067,2067,2069,2068,2067,2064,2060,2058,2054,2049,2045,2043,2040,2037,2035,2035,2035,2035,2035,2035,2037,2039,2045,2049,2053,2059,2064,2067,2068,2069,2068,2068,2065,2064,2060,2057,2053,2050,2046,2044,2042,2039,2037,2035,2035,2036,2037,2038,2042,2045,2047,2054,2053,2056,2060,2064,2065,2067,2066,2067,2066,2062,2061,2056,2055,2049,2048,2045,2044,2042,2039,2036,2034,2035,2036,2040,2043,2047,2049,2048,2050,2052,2056,2057,2060,2062,2064,2064,2064,2064,2061,2059,2056,2052,2048,2045,2045,2043,2041,2041,2040,2042,2043,2046,2046,2049,2049,2051,2052,2053,2054,2054,2055,2055,2056,2054,2054,2054,2052,2052,2051,2049,2050,2048,2049,2047,2049,2046,2047,2049,2049,2050,2052,2052,2049,2047,2045,2041,2039,2035,2033,2033,2034,2036,2042,2049,2056,2068,2082,2095,2106,2116,2121,2122,2117,2103,2085,2060,203
//};
//
//const float y[DATA_LEN] = {
//2076,2079,2082,2081,2080,2076,2073,2067,2063,2056,2053,2048,2045,2044,2043,2043,2042,2043,2046,2049,2050,2053,2058,2060,2064,2067,2067,2068,2067,2067,2064,2061,2058,2055,2051,2049,2046,2047,2046,2044,2045,2044,2046,2049,2050,2056,2061,2065,2068,2069,2068,2068,2066,2064,2060,2056,2053,2051,2046,2046,2042,2039,2038,2037,2038,2039,2040,2042,2046,2049,2050,2053,2056,2059,2061,2062,2064,2065,2064,2062,2060,2056,2053,2049,2045,2044,2039,2037,2036,2035,2035,2037,2039,2043,2046,2052,2052,2055,2058,2060,2064,2067,2068,2070,2071,2068,2064,2059,2054,2050,2046,2044,2039,2038,2034,2034,2033,2033,2034,2037,2041,2044,2050,2053,2056,2062,2064,2066,2066,2068,2066,2064,2061,2057,2053,2049,2047,2043,2041,2039,2036,2036,2035,2037,2037,2041,2044,2047,2052,2054,2058,2064,2065,2066,2065,2064,2064,2061,2061,2060,2057,2052,2049,2045,2042,2038,2037,2035,2035,2034,2036,2037,2041,2044,2047,2051,2052,2056,2060,2062,2065,2066,2066,2067,2064,2062,2059,2057,2052,2048,2044,2042,2041,2036,2036,2034,2034,2036,2038,2040,2045,2050,2051,2054,2058,2061,2064,2067,2064,2064,2062,2060,2057,2053,2053,2050,2049,2044,2044,2040,2038,2037,2037,2037,2039,2042,2043,2047,2050,2050,2051,2054,2056,2058,2060,2061,2062,2061,2060,2059,2056,2054,2052,2049,2047,2047,2047,2047,2047,2047,2046,2048,2046,2050,2049,2048,2047,2049,2046,2047,2047,2049,2048,2049,2049,2048,2048,2047,2052,2048,2050,2053,2054,2055,2058,2057,2059,2058,2057,2057,2055,2053,2052,2050,2047,2048,2043,2045,2042,2041,2042,2042,2042,2042,2043,2046,2050,2049,2052,2055,2058,2061,2064,2065,2067,2067,2065,2062,2057,2054,2050,2047,2047,2044,2042,2038,2035,2032,2032,2032,2033,2036,2040,2045,2050,2053,2057,2061,2066,2068,2071,2071,2073,2072,2068,2067,2063,2058,2053,2045,2043,2036,2033,2027,2026,2024,2024,2026,2029,2035,2039,2045,2052,2057,2064,2067,2070,2072,2073,2074,2075,2072,2074,2070,2066,2059,2052,2045,2041,2036,2032,2027,2027,2026,2026,2029,2032,2036,2042,2046,2052,2054,2060,2064,2069,2071,2073,2071,2072,2068,2066,2061,2058,2052,2046,2045,2041,2037,2035,2033,2033,2032,2034,2036,2039,2043,2047,2051,2053,2057,2064,2067,2068,2068,2067,2065,2064,2060,2058,2056,2054,2051,2045,2043,2041,2037,2036,2035,2036,2037,2040,2042,2046,2049,2048,2051,2055,2057,2058,2061,2064,2064,2064,2064,2062,2061,2058,2056,2054,2050,2048,2045,2046,2043,2042,2039,2037,2038,2039,2041,2042,2045,2048,2049,2053,2055,2056,2057,2056,2057,2058,2058,2060,2060,2060,2058,2056,2053,2050,2047,2047,2045,2042,2042,2040,2040,2040,2040,2042,2043,2044,2046,2051,2051,2055,2059,2061,2064,2066,2067,2068,2067,2066,2064,2061,2058,2053,2051,2045,2044,2041,2038,2036,2033,2033,2034,2036,2038,2041,2042,2045,2048,2049,2053,2059,2064,2066,2067,2066,2065,2062,2058,2056,2052,2049,2045,2046,2043,2041,2040,2040,2042,2043,2045,2047,2050,2052,2055,2058,2060,2064,2065,2067,2067,2064,2064,2060,2056,2052,2047,2045,2041,2039,2034,2032,2032,2032,2033,2037,2041,2044,2049,2051,2055,2059,2064,2068,2071,2071,2071,2068,2064,2059,2054,2050,2046,2045,2043,2039,2036,2036,2036,2034,2035,2036,2039,2043,2047,2051,2054,2058,2064,2067,2070,2072,2073,2072,2071,2068,2066,2061,2055,2051,2046,2043,2039,2035,2033,2032,2031,2031,2030,2031,2034,2037,2044,2050,2054,2059,2061,2065,2066,2069,2068,2067,2067,2066,2064,2060,2056,2052,2049,2044,2042,2039,2037,2035,2035,2034,2036,2036,2039,2041,2045,2050,2050,2055,2059,2062,2065,2067,2067,2069,2068,2067,2064,2060,2058,2054,2049,2045,2043,2040,2037,2035,2035,2035,2035,2035,2035,2037,2039,2045,2049,2053,2059,2064,2067,2068,2069,2068,2068,2065,2064,2060,2057,2053,2050,2046,2044,2042,2039,2037,2035,2035,2036,2037,2038,2042,2045,2047,2054,2053,2056,2060,2064,2065,2067,2066,2067,2066,2062,2061,2056,2055,2049,2048,2045,2044,2042,2039,2036,2034,2035,2036,2040,2043,2047,2049,2048,2050,2052,2056,2057,2060,2062,2064,2064,2064,2064,2061,2059,2056,2052,2048,2045,2045,2043,2041,2041,2040,2042,2043,2046,2046,2049,2049,2051,2052,2053,2054,2054,2055,2055,2056,2054,2054,2054,2052,2052,2051,2049,2050,2048,2049,2047,2049,2046,2047,2049,2049,2050,2052,2052,2049,2047,2045,2041,2039,2035,2033,2033,2034,2036,2042,2049,2056,2068,2082,2095,2106,2116,2121,2122,2117,2103,2085,2060,203
//};
void fft_acc_corr_f32_test();
void fft_acc_corr_q15_test();
// 求解x y 相关系数最大时候的相位差
// xcorr_out 储存相关系数
// out 相关系数最大值的位置
//float xcorr_max_position_uint16_t(float* xcorr_out,float* x , float* y , uint32_t len);
// 相关运算计算时差
float32_t cal_dtof(q15_t* x , q15_t* y , uint32_t len);
// 计算到达时间
float cal_tof(q15_t* x,uint32_t len);
// not use
float xcorr_max_position_uint16_t(q15_t* xcorr_out,q15_t* x , q15_t* y , uint32_t len);
#endif