예제 #1
0
void ADXL362::setupACInactivityInterrupt(int threshold, int time){
  //  Setup motion and time thresholds
  SPIwriteTwoRegisters(0x23, threshold);
  SPIwriteTwoRegisters(0x25, time);
 
  // turn on inactivity interrupt
  byte ACT_INACT_CTL_Reg = SPIreadOneRegister(0x27);   // Read current reg value
  ACT_INACT_CTL_Reg = ACT_INACT_CTL_Reg | (0x0C);      // turn on bit 3 and 4, INACT_AC_DCB, INACT_EN  
  SPIwriteOneRegister(0x27, ACT_INACT_CTL_Reg);        // Write new reg value 
  ACT_INACT_CTL_Reg = SPIreadOneRegister(0x27);        // Verify properly written

#ifdef ADXL362_DEBUG
  Serial.print("AC Inactivity Threshold set to ");  Serial.print(SPIreadTwoRegisters(0x23));
  Serial.print(", Time Inactivity set to ");  Serial.print(SPIreadTwoRegisters(0x25)); 
  Serial.print(", ACT_INACT_CTL Register is ");  Serial.println(ACT_INACT_CTL_Reg, HEX);
#endif
}
void ADXL362::setupDCInactivityInterrupt(int threshold, uint8_t time){
  //  Setup motion and time thresholds
  SPIwriteTwoRegisters(XL362_THRESH_ACT_L, threshold);
  SPIwriteOneRegister(XL362_TIME_ACT, time);

  // turn on inactivity interrupt
  uint8_t ACT_INACT_CTL_Reg = SPIreadOneRegister(XL362_ACT_INACT_CTL);   // Read current reg value 
  ACT_INACT_CTL_Reg = ACT_INACT_CTL_Reg | (0x04);      // turn on bit 3, INACT_EN  
  SPIwriteOneRegister(XL362_ACT_INACT_CTL, ACT_INACT_CTL_Reg);       // Write new reg value 

#ifdef ADXL362_DEBUG
  Serial.print("DC Activity Threshold set to "); Serial.print(SPIreadTwoRegisters(XL362_THRESH_ACT_L));
  Serial.print(", Time threshold set to ");      Serial.print(SPIreadOneRegister(XL362_TIME_ACT)); 
  Serial.print(", ACT_INACT_CTL Register is ");  Serial.println(SPIreadOneRegister(XL362_ACT_INACT_CTL), HEX);
#endif
}
예제 #3
0
void ADXL362::setupDCActivityInterrupt(int threshold, byte time){
  //  Setup motion and time thresholds
  SPIwriteTwoRegisters(0x20, threshold);
  SPIwriteOneRegister(0x22, time);

  // turn on activity interrupt
  byte ACT_INACT_CTL_Reg = SPIreadOneRegister(0x27);  // Read current reg value
  ACT_INACT_CTL_Reg = ACT_INACT_CTL_Reg | (0x01);     // turn on bit 1, ACT_EN  
  SPIwriteOneRegister(0x27, ACT_INACT_CTL_Reg);       // Write new reg value 
  ACT_INACT_CTL_Reg = SPIreadOneRegister(0x27);       // Verify properly written

#ifdef ADXL362_DEBUG
  Serial.print("DC Activity Threshold set to ");  	Serial.print(SPIreadTwoRegisters(0x20));
  Serial.print(", Time threshold set to ");  		Serial.print(SPIreadOneRegister(0x22)); 
  Serial.print(", ACT_INACT_CTL Register is ");  	Serial.println(ACT_INACT_CTL_Reg, HEX);
#endif
}