配置代码:
unsigned char lis3dhinit(void)
{
unsigned char response=0;
LIS3DH_WriteRegReg(0x20, 0x4f); //CTRL_REG1 25HZ ,使能XYZ轴,开启低功耗模式 0x3f ODR + F XYZ +低功耗
LIS3DH_WriteRegReg(0x21, 0x09); //CTRL_REG2 打开高通滤波器,使能中断1
LIS3DH_WriteRegReg(0x22, 0x40); //CTRL_REG3 打开IA1 INT1 中断使能
LIS3DH_WriteRegReg(0x23, 0x00); //CTRL_REG4 +-2g
LIS3DH_WriteRegReg(0x24, 0x00); //CTRL_REG5 写入00 可正常产生中断 08是锁存中断
/*********控制中断检测灵敏度*****/
LIS3DH_WriteRegReg(0x32, 0x08); //INT1_THS 加速度阈值 41
LIS3DH_WriteRegReg(0x33, 0X00); //INT1_DURATION 0x80 中断1 持续时间 改为 0 试试 82
LIS3DH_WriteRegReg(0x30, 0x2A); //INT1_CFG 0x2A
LIS3DH_WriteRegReg(0x25, 0x02); //CTRL_REG6
return response;
}