void MAG3110::init(byte sysmod)
{
	Wire.begin();
	setRegisterBit(MAG3110_REG_CTRL_REG2,
				   MAG3110_BIT_AUTO_RESET,
				   1);
	switch(sysmod)
	{
		case SYSMOD_STANDBY:
			setRegisterBit(MAG3110_REG_CTRL_REG1,
						   MAG3110_BIT_ACTIVE,
						   0);
			break;
		case SYSMOD_ACTIVE_RAW:
			setRegisterBit(MAG3110_REG_CTRL_REG1,
						   MAG3110_BIT_ACTIVE,
						   1);
			setRegisterBit(MAG3110_REG_CTRL_REG2,
						   MAG3110_BIT_RAW,
						   1);
			break;
		case SYSMOD_ACTIVE:
			setRegisterBit(MAG3110_REG_CTRL_REG1,
						   MAG3110_BIT_ACTIVE,
						   1);
			setRegisterBit(MAG3110_REG_CTRL_REG2,
						   MAG3110_BIT_RAW,
						   0);
			break;
	}
}
void MAG3110::setRawMode(bool isRaw)
{
	setRegisterBit(MAG3110_REG_CTRL_REG2,
				   MAG3110_BIT_RAW,
				   isRaw?1:0);
}
Exemple #3
0
void CAdxl345::setInterrupt(byte interruptBit, bool state) {
	setRegisterBit(ADXL345_INT_ENABLE, interruptBit, state);
}
Exemple #4
0
void CAdxl345::setLowPower(bool state) {
	setRegisterBit(ADXL345_BW_RATE, 4, state);
}
Exemple #5
0
void CAdxl345::setSuppressBit(bool state) {
	setRegisterBit(ADXL345_TAP_AXES, 3, state);
}
Exemple #6
0
void CAdxl345::setActivityZ(bool state) {
	setRegisterBit(ADXL345_ACT_INACT_CTL, 4, state);
}
Exemple #7
0
// Sets the FULL_RES bit
// if set to 1, the device is in full resolution mode, where the output resolution increases with the
//   g range set by the range bits to maintain a 4mg/LSB scal factor
// if set to 0, the device is in 10-bit mode, and the range buts determine the maximum g range
//   and scale factor
void CAdxl345::setFullResBit(bool fullResBit) {
	setRegisterBit(ADXL345_DATA_FORMAT, 3, fullResBit);
}
Exemple #8
0
// Sets the SPI bit
// if set to 1 it sets the device to 3-wire mode
// if set to 0 it sets the device to 4-wire SPI mode
void CAdxl345::setSpiBit(bool spiBit) {
	setRegisterBit(ADXL345_DATA_FORMAT, 6, spiBit);
}
// Sets the FULL_RES bit
// if set to 1, the device is in full resolution mode, where the output resolution increases with the
//   g range set by the range bits to maintain a 4mg/LSB scal factor
// if set to 0, the device is in 10-bit mode, and the range buts determine the maximum g range
//   and scale factor
void Accelerometer::setFullResBit(bool fullResBit) {
  setRegisterBit(ADXL345_DATA_FORMAT, 3, fullResBit);
}
// Sets the INT_INVERT bit
// if set to 0 sets the interrupts to active high
// if set to 1 sets the interrupts to active low
void Accelerometer::setInterruptLevelBit(bool interruptLevelBit) {
  setRegisterBit(ADXL345_DATA_FORMAT, 5, interruptLevelBit);
}
// Sets the SPI bit
// if set to 1 it sets the device to 3-wire mode
// if set to 0 it sets the device to 4-wire SPI mode
void Accelerometer::setSpiBit(bool spiBit) {
  setRegisterBit(ADXL345_DATA_FORMAT, 6, spiBit);
}
Exemple #12
0
void IMU3000::setSleepState(bool state)
{
	setRegisterBit(IMU3000_REG_PWR_MAN, IMU3000_SLEEP, state);
}
Exemple #13
0
void IMU3000::reset()
{
	setRegisterBit(IMU3000_REG_PWR_MAN, IMU3000_H_RESET,true);
}
// initialize sensor
void acc_adxl345_init(void *i2c_dev)
{

    __I2C_Device = i2c_dev;

    //suli_i2c_init(__I2C_Device);

    //Turning on the ADXL345
    writeTo(ADXL345_POWER_CTL, 0);
    writeTo(ADXL345_POWER_CTL, 16);
    writeTo(ADXL345_POWER_CTL, 8);

    writeTo(ADXL345_THRESH_ACT, 75);
    writeTo(ADXL345_THRESH_INACT, 75);
    writeTo(ADXL345_TIME_INACT, 10);

    //look of activity movement on this axes - 1 == on; 0 == off
    setRegisterBit(ADXL345_ACT_INACT_CTL, 6, 1);
    setRegisterBit(ADXL345_ACT_INACT_CTL, 5, 1);
    setRegisterBit(ADXL345_ACT_INACT_CTL, 4, 1);

    //look of inactivity movement on this axes - 1 == on; 0 == off
    setRegisterBit(ADXL345_ACT_INACT_CTL, 2, 1);
    setRegisterBit(ADXL345_ACT_INACT_CTL, 1, 1);
    setRegisterBit(ADXL345_ACT_INACT_CTL, 0, 1);

    setRegisterBit(ADXL345_TAP_AXES, 2, 0);
    setRegisterBit(ADXL345_TAP_AXES, 1, 0);
    setRegisterBit(ADXL345_TAP_AXES, 0, 0);

    //set values for what is a tap, and what is a double tap (0-255)
    //setTapThreshold(50); //62.5mg per increment
    writeTo(ADXL345_THRESH_TAP, 50);

    writeTo(ADXL345_DUR, 15);

    writeTo(ADXL345_LATENT, 80);

    //setDoubleTapWindow(200); //1.25ms per increment
    writeTo(ADXL345_WINDOW, (uint8)200);

    //set values for what is considered freefall (0-255)

    writeTo(ADXL345_THRESH_FF, 7);

    writeTo(ADXL345_TIME_FF, 45);
    //setting all interrupts to take place on int pin 1
    //I had issues with int pin 2, was unable to reset it

    setRegisterBit(ADXL345_INT_MAP, ADXL345_INT_SINGLE_TAP_BIT,   ADXL345_INT1_PIN);
    setRegisterBit(ADXL345_INT_MAP, ADXL345_INT_DOUBLE_TAP_BIT,   ADXL345_INT1_PIN);
    setRegisterBit(ADXL345_INT_MAP, ADXL345_INT_FREE_FALL_BIT,    ADXL345_INT1_PIN);
    setRegisterBit(ADXL345_INT_MAP, ADXL345_INT_ACTIVITY_BIT,     ADXL345_INT1_PIN);
    setRegisterBit(ADXL345_INT_MAP, ADXL345_INT_INACTIVITY_BIT,   ADXL345_INT1_PIN);

    //register interrupt actions - 1 == on; 0 == off
    setRegisterBit(ADXL345_INT_ENABLE, ADXL345_INT_SINGLE_TAP_BIT, 1);
    setRegisterBit(ADXL345_INT_ENABLE, ADXL345_INT_DOUBLE_TAP_BIT, 1);
    setRegisterBit(ADXL345_INT_ENABLE, ADXL345_INT_FREE_FALL_BIT,  1);
    setRegisterBit(ADXL345_INT_ENABLE, ADXL345_INT_ACTIVITY_BIT,   1);
    setRegisterBit(ADXL345_INT_ENABLE, ADXL345_INT_INACTIVITY_BIT, 1);
}
void Accelerometer::setInterrupt(byte interruptBit, bool state) {
  setRegisterBit(ADXL345_INT_ENABLE, interruptBit, state);
}
// Sets the JUSTIFY bit
// if sets to 1 selects the left justified mode
// if sets to 0 selects right justified mode with sign extension
void Accelerometer::setJustifyBit(bool justifyBit) {
  setRegisterBit(ADXL345_DATA_FORMAT, 2, justifyBit);
}
// Sets the SELF-TEST bit
// if set to 1 it applies a self-test force to the sensor causing a shift in the output data
// if set to 0 it disables the self-test force
void Accelerometer::setSelfTestBit(bool selfTestBit) {
  setRegisterBit(ADXL345_DATA_FORMAT, 7, selfTestBit);
}
void Accelerometer::setActivityZ(bool state) {  
  setRegisterBit(ADXL345_ACT_INACT_CTL, 4, state); 
}
Exemple #19
0
// Sets the INT_INVERT bit
// if set to 0 sets the interrupts to active high
// if set to 1 sets the interrupts to active low
void CAdxl345::setInterruptLevelBit(bool interruptLevelBit) {
	setRegisterBit(ADXL345_DATA_FORMAT, 5, interruptLevelBit);
}
void Accelerometer::setInactivityAc(bool state) {  
  setRegisterBit(ADXL345_ACT_INACT_CTL, 3, state); 
}
Exemple #21
0
// Sets the JUSTIFY bit
// if sets to 1 selects the left justified mode
// if sets to 0 selects right justified mode with sign extension
void CAdxl345::setJustifyBit(bool justifyBit) {
	setRegisterBit(ADXL345_DATA_FORMAT, 2, justifyBit);
}
void Accelerometer::setSuppressBit(bool state) {  
  setRegisterBit(ADXL345_TAP_AXES, 3, state); 
}
Exemple #23
0
void CAdxl345::setInactivityAc(bool state) {
	setRegisterBit(ADXL345_ACT_INACT_CTL, 3, state);
}
void Accelerometer::setTapDetectionOnZ(bool state) {  
  setRegisterBit(ADXL345_TAP_AXES, 0, state); 
}
Exemple #25
0
void CAdxl345::setTapDetectionOnZ(bool state) {
	setRegisterBit(ADXL345_TAP_AXES, 0, state);
}
void Accelerometer::setLowPower(bool state) {  
  setRegisterBit(ADXL345_BW_RATE, 4, state); 
}
Exemple #27
0
// Set the mapping of an interrupt to pin1 or pin2
// eg: setInterruptMapping(ADXL345_INT_DOUBLE_TAP_BIT,ADXL345_INT2_PIN);
void CAdxl345::setInterruptMapping(byte interruptBit, bool interruptPin) {
	setRegisterBit(ADXL345_INT_MAP, interruptBit, interruptPin);
}
// Set the mapping of an interrupt to pin1 or pin2
// eg: setInterruptMapping(ADXL345_INT_DOUBLE_TAP_BIT,ADXL345_INT2_PIN);
void Accelerometer::setInterruptMapping(byte interruptBit, bool interruptPin) {
  setRegisterBit(ADXL345_INT_MAP, interruptBit, interruptPin);
}
Exemple #29
0
// Sets the SELF-TEST bit
// if set to 1 it applies a self-test force to the sensor causing a shift in the output data
// if set to 0 it disables the self-test force
void CAdxl345::setSelfTestBit(bool selfTestBit) {
	setRegisterBit(ADXL345_DATA_FORMAT, 7, selfTestBit);
}
void MAG3110::setOperatingMode(bool isActive)
{
	setRegisterBit(MAG3110_REG_CTRL_REG1,
				   MAG3110_BIT_ACTIVE,
				   isActive);
}