Jim Cooke / Mbed 2 deprecated Hat_Board_v5_1

Dependencies:   mbed-dsp mbed

Fork of Hat_Board_v5 by John Scharf

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SI_LIS.h Source File

SI_LIS.h

00001 
00002 #ifndef SI_LIS_h
00003 #define SI_LIS_h
00004 
00005 #include "mbed.h"
00006 
00007 #define IR_ADDRESS                  0x5A
00008 #define LIS_Addr                    0x18
00009 #define HW_KEY_VAL0                 0x17    //Value to write into the HW Key register
00010 
00011 // Register Addresses
00012 
00013 #define PART_ID                     0x00
00014 #define REV_ID                      0x01
00015 #define SEQ_ID                      0x02    //Si114x-A11 (MAJOR_SEQ=1, MINOR_SEQ=1)
00016 #define INT_CFG                     0x03
00017 #define IRQ_ENABLE                  0x04
00018 #define IRQ_MODE1                   0x05
00019 #define IRQ_MODE2                   0x06
00020 #define HW_KEY                      0x07
00021 
00022 #define MEAS_RATE                   0x08
00023 #define ALS_RATE                    0x09
00024 #define PS_RATE                     0x0A
00025 
00026 #define ALS_LOW_TH0                 0x0B
00027 #define ALS_LOW_TH1                 0x0C
00028 #define ALS_HI_TH0                  0x0D
00029 #define ALS_HI_TH1                  0x0E
00030 
00031 #define PS_LED21                    0x0F
00032 #define PS_LED3                     0x10
00033 
00034 #define PS1_TH0                     0x11
00035 #define PS1_TH1                     0x12
00036 #define PS2_TH0                     0x13
00037 #define PS2_TH1                     0x14
00038 #define PS3_TH0                     0x15
00039 
00040 #define PS3_TH1                     0x16
00041 #define PARAM_WR                    0x17
00042 #define COMMAND                     0x18
00043 
00044 #define RESPONSE                    0x20
00045 #define IRQ_STATUS                  0x21
00046 
00047 #define ALS_VIS_DATA0               0x22
00048 #define ALS_VIS_DATA1               0x23
00049 #define ALS_IR_DATA0                0x24
00050 #define ALS_IR_DATA1                0x25
00051 
00052 #define PS1_DATA0                   0x26
00053 #define PS1_DATA1                   0x27
00054 #define PS2_DATA0                   0x28
00055 #define PS2_DATA1                   0x29
00056 #define PS3_DATA0                   0x2A
00057 #define PS3_DATA1                   0x2B
00058 
00059 
00060 #define AUX_DATA0                   0x2C
00061 #define AUX_DATA1                   0x2D
00062 
00063 #define PARAM_RD                    0x2E
00064 #define CHIP_STAT                   0x30
00065 #define ANA_IN_KEY                  0x3B
00066 
00067 // Command Register Values
00068 
00069 #define PARAM_QUERY                 0x80    //Value is ORed with Parameter Offset
00070 #define PARAM_SET                   0xA0    //Value is ORed with Parameter Offset
00071 #define PARAM_AND                   0xC0    //Value is ORed with Parameter Offset
00072 #define PARAM_OR                    0xE0    //Value is ORed with Parameter Offset
00073 #define NOP                         0x00
00074 #define RESET                       0x01
00075 #define BUSADDR                     0x02
00076 #define PS_FORCE                    0x05
00077 #define ALS_FORCE                   0x06
00078 #define PSALS_FORCE                 0x07
00079 #define PS_PAUSE                    0x09
00080 #define ALS_PAUSE                   0x0A
00081 #define PSALS_PAUSE                 0x0B
00082 #define PS_AUTO                     0x0D
00083 #define ALS_AUTO                    0x0E
00084 #define PSALS_AUTO                  0x0F
00085 
00086 // Ram Addresses
00087 
00088 #define I2C_ADDR                    0x00
00089 #define CHLIST                      0x01
00090 #define PSLED12_SELECT              0x02
00091 #define PSLED3_SELECT               0x03
00092 #define FILTER_EN                   0x04
00093 #define PS_ENCODING                 0x05
00094 #define ALS_ENCODING                0x06
00095 #define PS1_ADCMUX                  0x07
00096 #define PS2_ADCMUX                  0x08
00097 #define PS3_ADCMUX                  0x09
00098 #define PS_ADC_COUNTER              0x0A
00099 #define PS_ADC_GAIN                 0x0B
00100 #define PS_ADC_MISC                 0x0C
00101 #define ALS1_ADCMUX                 0x0D
00102 #define ALS2_ADCMUX                 0x0E
00103 #define ALS3_ADCMUX                 0x0F
00104 #define ALS_VIS_ADC_COUNTER         0x10
00105 #define ALS_VIS_ADC_GAIN            0x11
00106 #define ALS_VIS_ADC_MISC            0x12
00107 #define ALS_HYST                    0x16
00108 #define PS_HYST                     0x17
00109 #define PS_HISTORY                  0x18
00110 #define ALS_HISTORY                 0x19
00111 #define ADC_OFFSET                  0x1A
00112 #define SLEEP_CTRL                  0x1B
00113 #define LED_REC                     0x1C
00114 #define ALS_IR_ADC_COUNTER          0x1D
00115 #define ALS_IR_ADC_GAIN             0x1E
00116 #define ALS_IR_ADC_MISC             0x1F
00117 
00118 // Measurement Channel List
00119 
00120 #define PS1_TASK                    0x01
00121 #define PS2_TASK                    0x02
00122 #define PS3_TASK                    0x04
00123 #define ALS_VIS_TASK                0x10
00124 #define ALS_IR_TASK                 0x20
00125 #define AUX_TASK                    0x40
00126 
00127 // SI1142 Sensor.
00128 
00129 // Restart device.
00130 void restart(void);
00131 
00132 // Wait for the device to respond, then send it a specific command.
00133 void command(char cmd);
00134 
00135 // Send a test command.
00136 void command_test();
00137 
00138 // Send a non-RESET command.
00139 int command2(char cmd);
00140 
00141 // Send a non-RESET command another way.
00142 void command3(char cmd);
00143 
00144 /**
00145  * Read a register from the device.
00146  */
00147 char read_reg(/*unsigned*/ char address, int num_data);
00148 
00149 // Read 4 registers in a row
00150 char read_reg2(/*unsigned*/ char address);
00151 
00152 // Write to a register on Si1142.
00153 void write_reg(char address, char num_data);
00154 
00155 void Init_Accel ();
00156 
00157 void Get_Accel_Register (char Reg_Num);
00158 
00159 void Get_Accel_Reg_6 (char Reg_Num); // Read 6 registers
00160 
00161 #endif