Used for testing battery sense circuit, looking for max and min levels. Allow for finding true empty, half and full values for driving LEDs for example
Dependencies: mbed MPL3115A2 TSI WiGo_BattCharger
main.h@5:4438d5665b4f, 2013-09-03 (annotated)
- Committer:
- monpjc
- Date:
- Tue Sep 03 08:59:49 2013 +0000
- Revision:
- 5:4438d5665b4f
WIP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
monpjc | 5:4438d5665b4f | 1 | |
monpjc | 5:4438d5665b4f | 2 | #define MPL3115A2_I2C_ADDRESS (0x60<<1) |
monpjc | 5:4438d5665b4f | 3 | #define MAG_ADDR 0x1D |
monpjc | 5:4438d5665b4f | 4 | // define registers |
monpjc | 5:4438d5665b4f | 5 | #define MAG_DR_STATUS 0x00 |
monpjc | 5:4438d5665b4f | 6 | #define MAG_OUT_X_MSB 0x01 |
monpjc | 5:4438d5665b4f | 7 | #define MAG_OUT_X_LSB 0x02 |
monpjc | 5:4438d5665b4f | 8 | #define MAG_OUT_Y_MSB 0x03 |
monpjc | 5:4438d5665b4f | 9 | #define MAG_OUT_Y_LSB 0x04 |
monpjc | 5:4438d5665b4f | 10 | #define MAG_OUT_Z_MSB 0x05 |
monpjc | 5:4438d5665b4f | 11 | #define MAG_OUT_Z_LSB 0x06 |
monpjc | 5:4438d5665b4f | 12 | #define MAG_WHO_AM_I 0x07 |
monpjc | 5:4438d5665b4f | 13 | #define MAG_SYSMOD 0x08 |
monpjc | 5:4438d5665b4f | 14 | #define MAG_OFF_X_MSB 0x09 |
monpjc | 5:4438d5665b4f | 15 | #define MAG_OFF_X_LSB 0x0A |
monpjc | 5:4438d5665b4f | 16 | #define MAG_OFF_Y_MSB 0x0B |
monpjc | 5:4438d5665b4f | 17 | #define MAG_OFF_Y_LSB 0x0C |
monpjc | 5:4438d5665b4f | 18 | #define MAG_OFF_Z_MSB 0x0D |
monpjc | 5:4438d5665b4f | 19 | #define MAG_OFF_Z_LSB 0x0E |
monpjc | 5:4438d5665b4f | 20 | #define MAG_DIE_TEMP 0x0F |
monpjc | 5:4438d5665b4f | 21 | #define MAG_CTRL_REG1 0x10 |
monpjc | 5:4438d5665b4f | 22 | #define MAG_CTRL_REG2 0x11 |
monpjc | 5:4438d5665b4f | 23 | |
monpjc | 5:4438d5665b4f | 24 | // what should WHO_AM_I return? |
monpjc | 5:4438d5665b4f | 25 | #define MAG_3110_WHO_AM_I_VALUE 0xC4 |
monpjc | 5:4438d5665b4f | 26 | |
monpjc | 5:4438d5665b4f | 27 | |
monpjc | 5:4438d5665b4f | 28 | // Fields in registers |
monpjc | 5:4438d5665b4f | 29 | // CTRL_REG1: dr2,dr1,dr0 os1,os0 fr tm ac |
monpjc | 5:4438d5665b4f | 30 | |
monpjc | 5:4438d5665b4f | 31 | // Sampling rate from 80Hz down to 0.625Hz |
monpjc | 5:4438d5665b4f | 32 | #define MAG_3110_SAMPLE80 0 |
monpjc | 5:4438d5665b4f | 33 | #define MAG_3110_SAMPLE40 0x20 |
monpjc | 5:4438d5665b4f | 34 | #define MAG_3110_SAMPLE20 0x40 |
monpjc | 5:4438d5665b4f | 35 | #define MAG_3110_SAMPLE10 0x60 |
monpjc | 5:4438d5665b4f | 36 | #define MAG_3110_SAMPLE5 0x80 |
monpjc | 5:4438d5665b4f | 37 | #define MAG_3110_SAMPLE2_5 0xA0 |
monpjc | 5:4438d5665b4f | 38 | #define MAG_3110_SAMPLE1_25 0xC0 |
monpjc | 5:4438d5665b4f | 39 | #define MAG_3110_SAMPLE0_625 0xE0 |
monpjc | 5:4438d5665b4f | 40 | |
monpjc | 5:4438d5665b4f | 41 | // How many samples to average (lowers data rate) |
monpjc | 5:4438d5665b4f | 42 | #define MAG_3110_OVERSAMPLE1 0 |
monpjc | 5:4438d5665b4f | 43 | #define MAG_3110_OVERSAMPLE2 0x08 |
monpjc | 5:4438d5665b4f | 44 | #define MAG_3110_OVERSAMPLE3 0x10 |
monpjc | 5:4438d5665b4f | 45 | #define MAG_3110_OVERSAMPLE4 0x18 |
monpjc | 5:4438d5665b4f | 46 | |
monpjc | 5:4438d5665b4f | 47 | // read only 1 byte per axis |
monpjc | 5:4438d5665b4f | 48 | #define MAG_3110_FASTREAD 0x04 |
monpjc | 5:4438d5665b4f | 49 | // do one measurement (even if in standby mode) |
monpjc | 5:4438d5665b4f | 50 | #define MAG_3110_TRIGGER 0x02 |
monpjc | 5:4438d5665b4f | 51 | // put in active mode |
monpjc | 5:4438d5665b4f | 52 | #define MAG_3110_ACTIVE 0x01 |
monpjc | 5:4438d5665b4f | 53 | |
monpjc | 5:4438d5665b4f | 54 | // CTRL_REG2: AUTO_MRST_EN _ RAW MAG_RST _ _ _ _ _ |
monpjc | 5:4438d5665b4f | 55 | // reset sensor after each reading |
monpjc | 5:4438d5665b4f | 56 | #define MAG_3110_AUTO_MRST_EN 0x80 |
monpjc | 5:4438d5665b4f | 57 | // don't subtract user offsets |
monpjc | 5:4438d5665b4f | 58 | #define MAG_3110_RAW 0x20 |
monpjc | 5:4438d5665b4f | 59 | // reset magnetic sensor after too-large field |
monpjc | 5:4438d5665b4f | 60 | #define MAG_3110_MAG_RST 0x10 |
monpjc | 5:4438d5665b4f | 61 | |
monpjc | 5:4438d5665b4f | 62 | // DR_STATUS Register ZYXOW ZOW YOW XOW ZYXDR ZDR YDR XDR |
monpjc | 5:4438d5665b4f | 63 | #define MAG_3110_ZYXDR 0x08 |
monpjc | 5:4438d5665b4f | 64 | |
monpjc | 5:4438d5665b4f | 65 | |
monpjc | 5:4438d5665b4f | 66 | #define PI 3.14159265359 |
monpjc | 5:4438d5665b4f | 67 | #define ON 0 |
monpjc | 5:4438d5665b4f | 68 | #define OFF 1 |
monpjc | 5:4438d5665b4f | 69 | |
monpjc | 5:4438d5665b4f | 70 | #define RGB_LED_ON 0 |
monpjc | 5:4438d5665b4f | 71 | #define RGB_LED_OFF 1 |
monpjc | 5:4438d5665b4f | 72 |