bossay_release_out/app/A03_MAX30102_B/include/algorithm.h
2025-09-24 11:16:14 +08:00

64 lines
1.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __ALGORITHM_H
#define __ALGORITHM_H
#include <stdint.h>
#define FFT_N 512 //定义傅里叶变换的点数
#define START_INDEX 4 //低频过滤阈值
struct compx //定义一个复数结构
{
float real;
float imag;
};
//向下取整
double my_floor(double x);
//求余运算
double my_fmod(double x, double y);
//正弦函数
double XSin( double x );
//余弦函数
double XCos( double x );
//开平方
int qsqrt(int a);
/*******************************************************************
函数原型struct compx EE(struct compx b1,struct compx b2)
函数功能:对两个复数进行乘法运算
输入参数两个以联合体定义的复数a,b
输出参数a和b的乘积以联合体的形式输出
*******************************************************************/
struct compx EE(struct compx a,struct compx b);
/*****************************************************************
函数原型void FFT(struct compx *xin,int N)
函数功能对输入的复数组进行快速傅里叶变换FFT
输入参数:*xin复数结构体组的首地址指针struct型
*****************************************************************/
void FFT(struct compx *xin);
//读取峰值
int find_max_num_index(struct compx *data,int count);
typedef struct
{
float w;
int init;
float a;
}DC_FilterData;
//直流滤波器
int dc_filter(int input,DC_FilterData * df);
typedef struct
{
float v0;
float v1;
}BW_FilterData;
int bw_filter(int input,BW_FilterData * bw);
#endif /*__ALGORITHM_H*/