first cut at turnon scripts for EasyTimer v2
[fw/altos] / src / drivers / ao_bmx160.h
index e62f172da9bfe8711f23a32b26a96b20c8c91b0a..c5bf0aff634fcd2ccf9453ba0757448517b81f21 100644 (file)
@@ -25,7 +25,7 @@ struct ao_bmx160_sample {
        int16_t         mag_x;
        int16_t         mag_y;
        int16_t         mag_z;
-       int16_t         rhall;
+       uint16_t        rhall;
        int16_t         gyr_x;
        int16_t         gyr_y;
        int16_t         gyr_z;
@@ -46,6 +46,20 @@ struct ao_bmx160_offset {
        uint8_t         offset_6;
 };
 
+struct ao_bmm150_trim {
+       int8_t          dig_x1;
+       int8_t          dig_y1;
+       int8_t          dig_x2;
+       int8_t          dig_y2;
+       uint16_t        dig_z1;
+       int16_t         dig_z2;
+       int16_t         dig_z3;
+       int16_t         dig_z4;
+       uint8_t         dig_xy1;
+       int8_t          dig_xy2;
+       uint16_t        dig_xyz1;
+};
+
 void
 ao_bmx160_init(void);
 
@@ -61,10 +75,12 @@ ao_bmx160_init(void);
 #define   BMX160_PMU_STATUS_GYR_PMU_STATUS_SUSPEND             0
 #define   BMX160_PMU_STATUS_GYR_PMU_STATUS_NORMAL              1
 #define   BMX160_PMU_STATUS_GYR_PMU_STATUS_FAST_START_UP       3
+#define   BMX160_PMU_STATUS_GYR_PMU_STATUS_MASK                        3
 #define  BMX160_PMU_STATUS_ACC_PMU_STATUS      4
 #define   BMX160_PMU_STATUS_ACC_PMU_STATUS_SUSPEND             0
 #define   BMX160_PMU_STATUS_ACC_PMU_STATUS_NORMAL              1
 #define   BMX160_PMU_STATUS_ACC_PMU_STATUS_LOW_POWER           2
+#define   BMX160_PMU_STATUS_ACC_PMU_STATUS_MASK                        3
 #define BMX160_DATA_0                  0x04
 #define BMX160_MAG_X_0_7               0x04
 #define BMX160_MAG_X_8_15              0x05
@@ -186,6 +202,8 @@ ao_bmx160_init(void);
 #define BMX160_FOC_CONF                        0x69
 #define BMX160_CONF                    0x6A
 #define BMX160_IF_CONF                 0x6B
+#define  BMX160_IF_CONF_IF_MODE                        4
+#define  BMX160_IF_CONF_IF_MODE_AUTO_MAG               0x02
 #define BMX160_PMU_TRIGGER             0x6C
 #define BMX160_SELF_TEST               0x6D
 #define BMX160_NV_CONF                 0x70
@@ -250,6 +268,30 @@ ao_bmx160_init(void);
 #define BMM150_REPZ                            0x52
 #define  BMM150_REPZ_VALUE(n)                          ((n) -1)
 
+/* Trim Extended Registers */
+#define BMM150_DIG_X1                        0x5D
+#define BMM150_DIG_Y1                        0x5E
+#define BMM150_DIG_Z4_LSB                    0x62
+#define BMM150_DIG_Z4_MSB                    0x63
+#define BMM150_DIG_X2                        0x64
+#define BMM150_DIG_Y2                        0x65
+#define BMM150_DIG_Z2_LSB                    0x68
+#define BMM150_DIG_Z2_MSB                    0x69
+#define BMM150_DIG_Z1_LSB                    0x6A
+#define BMM150_DIG_Z1_MSB                    0x6B
+#define BMM150_DIG_XYZ1_LSB                  0x6C
+#define BMM150_DIG_XYZ1_MSB                  0x6D
+#define BMM150_DIG_Z3_LSB                    0x6E
+#define BMM150_DIG_Z3_MSB                    0x6F
+#define BMM150_DIG_XY2                       0x70
+#define BMM150_DIG_XY1                       0x71
+
+#define BMM150_XYAXES_FLIP_OVERFLOW_ADCVAL   -4096
+#define BMM150_ZAXIS_HALL_OVERFLOW_ADCVAL    -16384
+#define BMM150_OVERFLOW_OUTPUT               -32768
+#define BMM150_NEGATIVE_SATURATION_Z         -32767
+#define BMM150_POSITIVE_SATURATION_Z         32767
+
 #define BMX160_GYRO_FULLSCALE  ((float) 2000 * M_PI/180.0)
 
 static inline float
@@ -264,4 +306,6 @@ ao_bmx160_accel(int16_t sensor) {
        return (float) sensor * ((float) (BMX160_ACCEL_FULLSCALE * GRAVITY / 32767.0));
 }
 
+#define ao_bmx_accel_to_sample(accel) ((accel_t) (accel) * (32767.0f / (BMX160_ACCEL_FULLSCALE * GRAVITY)))
+
 #endif /* _BMX160_H_ */