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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.h Source File

main.h

00001 
00002 #define MPL3115A2_I2C_ADDRESS (0x60<<1)
00003 #define MAG_ADDR 0x1D
00004 // define registers
00005 #define MAG_DR_STATUS 0x00
00006 #define MAG_OUT_X_MSB 0x01
00007 #define MAG_OUT_X_LSB 0x02
00008 #define MAG_OUT_Y_MSB 0x03
00009 #define MAG_OUT_Y_LSB 0x04
00010 #define MAG_OUT_Z_MSB 0x05
00011 #define MAG_OUT_Z_LSB 0x06
00012 #define MAG_WHO_AM_I  0x07
00013 #define MAG_SYSMOD    0x08
00014 #define MAG_OFF_X_MSB 0x09
00015 #define MAG_OFF_X_LSB 0x0A
00016 #define MAG_OFF_Y_MSB 0x0B
00017 #define MAG_OFF_Y_LSB 0x0C
00018 #define MAG_OFF_Z_MSB 0x0D
00019 #define MAG_OFF_Z_LSB 0x0E
00020 #define MAG_DIE_TEMP  0x0F
00021 #define MAG_CTRL_REG1 0x10
00022 #define MAG_CTRL_REG2 0x11
00023 
00024 // what should WHO_AM_I return?
00025 #define MAG_3110_WHO_AM_I_VALUE 0xC4
00026 
00027 
00028 // Fields in registers
00029 // CTRL_REG1: dr2,dr1,dr0  os1,os0  fr tm ac
00030 
00031 // Sampling rate from 80Hz down to 0.625Hz
00032 #define MAG_3110_SAMPLE80 0
00033 #define MAG_3110_SAMPLE40 0x20
00034 #define MAG_3110_SAMPLE20 0x40
00035 #define MAG_3110_SAMPLE10 0x60
00036 #define MAG_3110_SAMPLE5 0x80
00037 #define MAG_3110_SAMPLE2_5 0xA0
00038 #define MAG_3110_SAMPLE1_25 0xC0
00039 #define MAG_3110_SAMPLE0_625 0xE0
00040 
00041 // How many samples to average (lowers data rate)
00042 #define MAG_3110_OVERSAMPLE1 0
00043 #define MAG_3110_OVERSAMPLE2 0x08
00044 #define MAG_3110_OVERSAMPLE3 0x10
00045 #define MAG_3110_OVERSAMPLE4 0x18
00046 
00047 // read only 1 byte per axis
00048 #define MAG_3110_FASTREAD 0x04
00049 // do one measurement (even if in standby mode)
00050 #define MAG_3110_TRIGGER 0x02
00051 // put in active mode
00052 #define MAG_3110_ACTIVE 0x01
00053 
00054 // CTRL_REG2: AUTO_MRST_EN  _ RAW MAG_RST _ _ _ _ _
00055 // reset sensor after each reading
00056 #define MAG_3110_AUTO_MRST_EN 0x80
00057 // don't subtract user offsets
00058 #define MAG_3110_RAW 0x20
00059 // reset magnetic sensor after too-large field
00060 #define MAG_3110_MAG_RST 0x10
00061 
00062 // DR_STATUS Register ZYXOW ZOW YOW XOW ZYXDR ZDR YDR XDR
00063 #define MAG_3110_ZYXDR  0x08
00064 
00065 
00066 #define PI 3.14159265359
00067 #define ON  0
00068 #define OFF 1
00069 
00070 #define RGB_LED_ON  0
00071 #define RGB_LED_OFF 1
00072