67 lines
1.7 KiB
C
67 lines
1.7 KiB
C
/**
|
|
* ==================================================
|
|
* @file imu_lis3dhtr.h
|
|
* @brief TODO 描述该文件的功能
|
|
* @author wangb
|
|
* @date 2026-01-27 12:21
|
|
* @version 1.0
|
|
*
|
|
* @details 本文件包含...
|
|
*
|
|
* @copyright Copyright (c) 2026 wangb. All Rights Reserved.
|
|
*
|
|
* @license 不开源
|
|
* ==================================================
|
|
*/
|
|
|
|
|
|
#ifndef SMART_CANE_FALL_DETECTION_IMU_LIS3DHTR_H
|
|
#define SMART_CANE_FALL_DETECTION_IMU_LIS3DHTR_H
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
extern volatile uint8_t lis3dh_int_flag ;
|
|
|
|
|
|
|
|
/* ================= 寄存器定义 ================= */
|
|
#define LIS3DH_REG_WHOAMI 0x0F
|
|
#define LIS3DH_REG_CTRL1 0x20
|
|
#define LIS3DH_REG_CTRL2 0x21
|
|
#define LIS3DH_REG_CTRL3 0x22
|
|
#define LIS3DH_REG_CTRL4 0x23
|
|
#define LIS3DH_REG_CTRL5 0x24
|
|
#define LIS3DH_REG_STATUS 0x27
|
|
|
|
#define LIS3DH_REG_OUT_X_L 0x28
|
|
#define LIS3DH_REG_OUT_Y_L 0x2A
|
|
#define LIS3DH_REG_OUT_Z_L 0x2C
|
|
|
|
/* ---------- 中断相关寄存器 ---------- */
|
|
#define LIS3DH_REG_INT1_CFG 0x30
|
|
#define LIS3DH_REG_INT1_SRC 0x31
|
|
#define LIS3DH_REG_INT1_THS 0x32
|
|
#define LIS3DH_REG_INT1_DUR 0x33
|
|
|
|
#define LIS3DH_REG_REFERENCE 0x26
|
|
|
|
/* ================= I2C 地址 ================= */
|
|
#define LIS3DHTR_I2C_ADDR (0x18 << 1)
|
|
|
|
|
|
/* ================= 数据结构 ================= */
|
|
typedef struct
|
|
{
|
|
float x_g;
|
|
float y_g;
|
|
float z_g;
|
|
} lis3dh_accel_t;
|
|
|
|
/* ================= 接口函数 ================= */
|
|
void lis3dh_read(uint8_t reg, uint8_t *data, uint16_t len);
|
|
void lis3dh_write(uint8_t reg, uint8_t data);
|
|
uint8_t imu_lis3dhtr_init(void);
|
|
uint8_t imu_lis3dhtr_read_accel(lis3dh_accel_t *accel);
|
|
void lis3dh_clear_all_int_flags(void);
|
|
#endif //SMART_CANE_FALL_DETECTION_IMU_LIS3DHTR_H
|