Files
99_7018_lmx/apps/earphone/xtell_Sensor/LIS2DH12.h
2025-10-29 16:24:16 +08:00

57 lines
1.2 KiB
C
Raw 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 LIS2DH12_H
#define LIS2DH12_H
#include "gSensor/gSensor_manage.h"
// #include <stdatomic.h>
#include "le_rcsp_adv_module.h"
// Constants
#define GRAVITY_EARTH 9.80665f // m/s^2
#define SAMPLING_PERIOD_S 2 // 采样周期s
#define LPF_ALPHA 0.8f // 低通滤波系数
typedef struct {
float x;
float y;
float z;
} axis_info_xtell;
typedef struct {
axis_info_xtell velocity; // m/s
axis_info_xtell distance; // m
} motion_data_t;
// 定义可能的满量程范围
typedef enum {
SCALE_2G = 2,
SCALE_4G = 4,
SCALE_8G = 8,
SCALE_16G = 16
} scale_t;
unsigned char LIS2DH12_Config(void);
char LIS2DH12_Check();
unsigned char LIS2DH12_disable(void);
void LIS2DH12_read_data(axis_info_t *sl_accel);
void print_register_values();
void LIS2DH12_reinit_fifo();
// float convert_to_g(int16_t raw_value, scale_t scale);
float convert_to_g(int16_t raw_value);
void xtell_i2c_test();
// 获取运动数据
void get_motion_data(motion_data_t *data);
axis_info_xtell get_current_accel_mss(void);
//10位2补码转换
int16_t convert_10bit_2s_complement(int16_t data);
// typedef struct {
// short x;
// short y;
// short z;
// } axis_info_t;
#endif