/* * Copyright (C) 2011 MCUBE, Inc. * * Initial Code: * Tan Liang */ #ifndef __MC32X0_H__ #define __MC32X0_H__ #define MC32X0_WR_FUNC_PTR char (* bus_write)(unsigned char, unsigned char *, unsigned char) #define MC32X0_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len)\ bus_write(reg_addr, reg_data, wr_len) #define MC32X0_RD_FUNC_PTR char (* bus_read)( unsigned char, unsigned char *, unsigned char) #define MC32X0_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, r_len)\ bus_read(reg_addr, reg_data, r_len) #define GET_REAL_VALUE(rv, bn) \ ((rv & (0x01 << (bn - 1))) ? (- (rv & ~(0xffff << (bn - 1)))) : (rv & ~(0xffff << (bn - 1)))) //#define MC32X0_HIGH_END /*******MC3210/20 define this**********/ //#define MCUBE_2G_10BIT_TAP //#define MCUBE_2G_10BIT //#define MCUBE_8G_14BIT_TAP //#define MCUBE_8G_14BIT //#define MC32X0_LOW_END /*******MC3230 define this**********/ //#define MCUBE_1_5G_8BIT //#define MCUBE_1_5G_8BIT_TAP /** MC32X0 I2C Address */ #define MC32X0_I2C_ADDR 0x4c // 0x98 >> 1 /* MC32X0 API error codes */ #define E_NULL_PTR (char)-127 /* * * register definitions * */ #define MC32X0_XOUT_REG 0x00 #define MC32X0_YOUT_REG 0x01 #define MC32X0_ZOUT_REG 0x02 #define MC32X0_Tilt_Status_REG 0x03 #define MC32X0_Sampling_Rate_Status_REG 0x04 #define MC32X0_Sleep_Count_REG 0x05 #define MC32X0_Interrupt_Enable_REG 0x06 #define MC32X0_Mode_Feature_REG 0x07 #define MC32X0_Sample_Rate_REG 0x08 #define MC32X0_Tap_Detection_Enable_REG 0x09 #define MC32X0_TAP_Dwell_Reject_REG 0x0a #define MC32X0_DROP_Control_Register_REG 0x0b #define MC32X0_SHAKE_Debounce_REG 0x0c #define MC32X0_XOUT_EX_L_REG 0x0d #define MC32X0_XOUT_EX_H_REG 0x0e #define MC32X0_YOUT_EX_L_REG 0x0f #define MC32X0_YOUT_EX_H_REG 0x10 #define MC32X0_ZOUT_EX_L_REG 0x11 #define MC32X0_ZOUT_EX_H_REG 0x12 #define MC32X0_CHIP_ID 0x18 #define MC32X0_RANGE_Control_REG 0x20 #define MC32X0_SHAKE_Threshold_REG 0x2B #define MC32X0_UD_Z_TH_REG 0x2C #define MC32X0_UD_X_TH_REG 0x2D #define MC32X0_RL_Z_TH_REG 0x2E #define MC32X0_RL_Y_TH_REG 0x2F #define MC32X0_FB_Z_TH_REG 0x30 #define MC32X0_DROP_Threshold_REG 0x31 #define MC32X0_TAP_Threshold_REG 0x32 /** MC32X0 acceleration data \brief Structure containing acceleration values for x,y and z-axis in signed short */ typedef struct { short x, /**< holds x-axis acceleration data sign extended. Range -512 to 511. */ y, /**< holds y-axis acceleration data sign extended. Range -512 to 511. */ z; /**< holds z-axis acceleration data sign extended. Range -512 to 511. */ } mc32x0acc_t; /* RANGE */ #define MC32X0_RANGE__POS 2 #define MC32X0_RANGE__LEN 2 #define MC32X0_RANGE__MSK 0x0c #define MC32X0_RANGE__REG MC32X0_RANGE_Control_REG /* MODE */ #define MC32X0_MODE__POS 0 #define MC32X0_MODE__LEN 2 #define MC32X0_MODE__MSK 0x03 #define MC32X0_MODE__REG MC32X0_Mode_Feature_REG #define MC32X0_MODE_DEF 0x43 /* BANDWIDTH */ #define MC32X0_BANDWIDTH__POS 4 #define MC32X0_BANDWIDTH__LEN 3 #define MC32X0_BANDWIDTH__MSK 0x70 #define MC32X0_BANDWIDTH__REG MC32X0_RANGE_Control_REG #define MC32X0_GET_BITSLICE(regvar, bitname)\ (regvar & bitname##__MSK) >> bitname##__POS #define MC32X0_SET_BITSLICE(regvar, bitname, val)\ (regvar & ~bitname##__MSK) | ((val<