void adxl362_init(void)
{
char buf[1];
xl362Write(1, XL362_SOFT_RESET, soft_reset_adxl362);
__delay_ms(20);
//ADXL362_Write_Reg(0x2D,0x02); // 0x2d POWER_CTL Measurement mode.
ADXL362_SetRegisterValue( 0x00, ADXL362_REG_POWER_CTL, 1);
__delay_ms(20);
/*#define ADXL362_REG_THRESH_ACT_L 0x20
#define ADXL362_REG_THRESH_ACT_H 0x21
#define ADXL362_REG_TIME_ACT 0x22
#define ADXL362_REG_THRESH_INACT_L 0x23
#define ADXL362_REG_THRESH_INACT_H 0x24
#define ADXL362_REG_TIME_INACT_L 0x25
#define ADXL362_REG_TIME_INACT_H 0x26
#define ADXL362_REG_ACT_INACT_CTL 0x27
#define ADXL362_REG_FIFO_CTL 0x28
#define ADXL362_REG_FIFO_SAMPLES 0x29
#define ADXL362_REG_INTMAP1 0x2A
#define ADXL362_REG_INTMAP2 0x2B
#define ADXL362_REG_FILTER_CTL 0x2C
#define ADXL362_REG_POWER_CTL 0x2D
#define ADXL362_REG_SELF_TEST 0x2E
*/
ADXL362_SetRegisterValue( 0x0a, ADXL362_REG_THRESH_ACT_L, 1); //0x20
ADXL362_SetRegisterValue( 0x00, ADXL362_REG_THRESH_ACT_H, 1); //0x21
ADXL362_SetRegisterValue( 0x03, ADXL362_REG_TIME_ACT, 1); //0x22
ADXL362_SetRegisterValue( 0x03, ADXL362_REG_ACT_INACT_CTL, 1); //0x27
ADXL362_SetRegisterValue( 0x90, ADXL362_REG_INTMAP1, 1); //0x2Aactive low, action detection
ADXL362_SetRegisterValue( 0x00, ADXL362_REG_INTMAP2, 1); //0x2B not used for now
ADXL362_SetRegisterValue( 0x82, ADXL362_REG_FILTER_CTL, 1); //0x2C filter configuration, 0x82--50hz
xl362Read(1, 0x0B, buf);
xl362Read(1, 0X2b, buf);
ADXL362_SetRegisterValue( 0x02, ADXL362_REG_POWER_CTL, 1);
__delay_ms(200);
xl362Read(1, 0X0b, buf);
xl362Read(1, 0x00, buf);
xl362Read(1, 0X2b, buf);
xl362Read(1, 0X2b, buf);
}
|