static ZEND_MSHUTDOWN_FUNCTION(zend_accelerator) { (void)type; /* keep the compiler happy */ UNREGISTER_INI_ENTRIES(); accel_shutdown(TSRMLS_C); return SUCCESS; }
//enable accelerometer for single sample, no interrupt void accel_enable_sample(void) { uint8_t i2cbuffer[4]; accel_shutdown(); //reset accel //Initialize I2C master i2c_init(I2C_SCL_RATIO(1), i2cbuffer, 4); I2C_BYTE_WRITE(LIS3DH_ADDR, LIS3DH_CTRL_REG1, LIS3DH_50HZ | LIS3DH_LP | LIS3DH_ENX | LIS3DH_ENY | LIS3DH_ENZ); //original stuff for init below: //I2C_BYTE_WRITE(LIS3DH_ADDR, LIS3DH_CTRL_REG1, LIS3DH_50HZ | LIS3DH_LP | LIS3DH_ENX | LIS3DH_ENY | LIS3DH_ENZ); }
//enable accelerometer for pedometer void accel_enable_fifo(void) { uint8_t i2cbuffer[4]; //QPRINTF("Configuring FIFO..."); accel_shutdown(); //reset accel //Initialize I2C master i2c_init(I2C_SCL_RATIO(1), i2cbuffer, 4); I2C_BYTE_WRITE(LIS3DH_ADDR, LIS3DH_CTRL_REG1, LIS3DH_50HZ | LIS3DH_LP | LIS3DH_ENX | LIS3DH_ENY | LIS3DH_ENZ); //turn on XYZ, low power, 50Hz I2C_BYTE_WRITE(LIS3DH_ADDR, LIS3DH_FIFO_CTRL_REG, LIS3DH_FIFO_MODE | ACCEL_FIFO_DEPTH); //fifo mode, watermark length 10, Send to inerrupt to INT1 I2C_BYTE_WRITE(LIS3DH_ADDR, LIS3DH_CTRL_REG5, LIS3DH_FIFO_EN | LIS3DH_LIR_INT1); //Enable FIFO I2C_BYTE_WRITE(LIS3DH_ADDR, LIS3DH_CTRL_REG3, LIS3DH_FIFO_WM | LIS3DH_INT1_EN | LIS3DH_FIFO_OVERRUN); //Enable FIFO watermark interrupt 1 I2C_BYTE_WRITE(LIS3DH_ADDR, LIS3DH_CTRL_REG2, LIS3DH_HPF_EN); //enalbe high pass filter for pedometer, disable for better value range on all XYZ axis //I2C_BYTE_READ(LIS3DH_ADDR, LIS3DH_HP_FILTER_RESET); //reset high pass filter zero level to current //QPRINTF("Done\r\n"); }