关于LIS3DH陀螺仪传感器配置INT1为移动检测中断

#if 1
  uint8_t response=0;
  
  response = LIS3DH_SetAxis(LIS3DH_X_ENABLE | LIS3DH_Y_ENABLE | LIS3DH_Z_ENABLE);
  response = LIS3DH_SetODR(LIS3DH_ODR_50Hz);
  response = LIS3DH_SetMode(LIS3DH_LOW_POWER);
  response = LIS3DH_SetFullScale(LIS3DH_FULLSCALE_2);

  LIS3DH_SetInt1Pin(LIS3DH_I1_INT1_ON_PIN_INT1_ENABLE);
//  LIS3DH_SetTriggerInt(LIS3DH_TRIG_INT1);  
//  LIS3DH_SetWaterMark(31);             // buff full will have a int
//  SetFilterDataSel(MEMS_DISABLE);

  LIS3DH_SetIntMode(LIS3DH_INT_MODE_6D_MOVEMENT);
  response = LIS3DH_SetIntConfiguration(LIS3DH_INT1_ZHIE_ENABLE | LIS3DH_INT1_ZLIE_ENABLE |
                                        LIS3DH_INT1_YHIE_ENABLE | LIS3DH_INT1_YLIE_ENABLE |
                                        LIS3DH_INT1_XHIE_ENABLE | LIS3DH_INT1_XLIE_ENABLE );
  //set Interrupt Threshold 
  response = LIS3DH_SetInt1Threshold(0x16);
  LIS3DH_SetInt1Duration(0);
#else
  I2C_WriteByte(ADDRESS_LIS3DH, LIS3DH_CTRL_REG1, 0x4F);  // 50hz    
  I2C_WriteByte(ADDRESS_LIS3DH, LIS3DH_CTRL_REG2, 0);
  I2C_WriteByte(ADDRESS_LIS3DH, LIS3DH_CTRL_REG3, 0x40);
	I2C_WriteByte(ADDRESS_LIS3DH, LIS3DH_CTRL_REG4, 0);
	I2C_WriteByte(ADDRESS_LIS3DH, LIS3DH_CTRL_REG5, 0x00);  // lht
  I2C_WriteByte(ADDRESS_LIS3DH, LIS3DH_CTRL_REG6, 0x00);  // lht
  I2C_WriteByte(ADDRESS_LIS3DH, LIS3DH_INT1_CFG, 0x7F);
	I2C_WriteByte(ADDRESS_LIS3DH, LIS3DH_INT1_THS, 0x16);
	I2C_WriteByte(ADDRESS_LIS3DH, LIS3DH_INT1_DURATION, 0x00);  // 00 
#endif

 

你可能感兴趣的:(单片机驱动程序)