A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SI1143.h Source File

SI1143.h

Go to the documentation of this file.
00001 /**
00002  * @file SI1143.h
00003  *
00004  * @author Adrian
00005  * @date 02.06.2016
00006  *
00007  */
00008 #ifndef SI1143_H_
00009 #define SI1143_H_
00010 
00011 #include "mbed.h"
00012 #include "I2C_RT.h "
00013 #include "SI1143Config.h "
00014 
00015 
00016 #define SI1143_IR_ADDRESS                  0x5A
00017 #define SI1143_HW_KEY_VAL0                 0x17    //Value to write into the HW Key register
00018 
00019 // Register Addresses
00020 
00021 #define SI1143_PART_ID                     0x00
00022 #define SI1143_REV_ID                      0x01
00023 #define SI1143_SEQ_ID                      0x02    //Si114x-A11 (MAJOR_SEQ=1, MINOR_SEQ=1)
00024 #define SI1143_INT_CFG                     0x03
00025 #define SI1143_IRQ_ENABLE                  0x04
00026 #define SI1143_IRQ_MODE1                   0x05
00027 #define SI1143_IRQ_MODE2                   0x06
00028 #define SI1143_HW_KEY                      0x07
00029 
00030 #define SI1143_MEAS_RATE                   0x08
00031 #define SI1143_ALS_RATE                    0x09
00032 #define SI1143_PS_RATE                     0x0A
00033 
00034 #define SI1143_ALS_LOW_TH0                 0x0B
00035 #define SI1143_ALS_LOW_TH1                 0x0C
00036 #define SI1143_ALS_HI_TH0                  0x0D
00037 #define SI1143_ALS_HI_TH1                  0x0E
00038 
00039 #define SI1143_PS_LED21                    0x0F
00040 #define SI1143_PS_LED3                     0x10
00041 
00042 #define SI1143_PS1_TH0                     0x11
00043 #define SI1143_PS1_TH1                     0x12
00044 #define SI1143_PS2_TH0                     0x13
00045 #define SI1143_PS2_TH1                     0x14
00046 #define SI1143_PS3_TH0                     0x15
00047 
00048 #define SI1143_PS3_TH1                     0x16
00049 #define SI1143_PARAM_WR                    0x17
00050 #define SI1143_COMMAND                     0x18
00051 
00052 #define SI1143_RESPONSE                    0x20
00053 #define SI1143_IRQ_STATUS                  0x21
00054 
00055 #define SI1143_ALS_VIS_DATA0               0x22
00056 #define SI1143_ALS_VIS_DATA1               0x23
00057 #define SI1143_ALS_IR_DATA0                0x24
00058 #define SI1143_ALS_IR_DATA1                0x25
00059 
00060 #define SI1143_PS1_DATA0                   0x26
00061 #define SI1143_PS1_DATA1                   0x27
00062 #define SI1143_PS2_DATA0                   0x28
00063 #define SI1143_PS2_DATA1                   0x29
00064 #define SI1143_PS3_DATA0                   0x2A
00065 #define SI1143_PS3_DATA1                   0x2B
00066 
00067 
00068 #define SI1143_AUX_DATA0                   0x2C
00069 #define SI1143_AUX_DATA1                   0x2D
00070 
00071 #define SI1143_PARAM_RD                    0x2E
00072 #define SI1143_CHIP_STAT                   0x30
00073 #define SI1143_ANA_IN_KEY                  0x3B
00074 
00075 // Command Register Values
00076 
00077 #define SI1143_PARAM_QUERY                 0x80    //Value is ORed with Parameter Offset
00078 #define SI1143_PARAM_SET                   0xA0    //Value is ORed with Parameter Offset
00079 #define SI1143_PARAM_AND                   0xC0    //Value is ORed with Parameter Offset
00080 #define SI1143_PARAM_OR                    0xE0    //Value is ORed with Parameter Offset
00081 #define SI1143_NOP                         0x00
00082 #define SI1143_RESET                       0x01
00083 #define SI1143_BUSADDR                     0x02
00084 #define SI1143_PS_FORCE                    0x05
00085 #define SI1143_ALS_FORCE                   0x06
00086 #define SI1143_PSALS_FORCE                 0x07
00087 #define SI1143_PS_PAUSE                    0x09
00088 #define SI1143_ALS_PAUSE                   0x0A
00089 #define SI1143_PSALS_PAUSE                 0x0B
00090 #define SI1143_PS_AUTO                     0x0D
00091 #define SI1143_ALS_AUTO                    0x0E
00092 #define SI1143_PSALS_AUTO                  0x0F
00093 
00094 // Ram Addresses
00095 
00096 #define SI1143_I2C_ADDR                    0x00
00097 #define SI1143_CHLIST                      0x01
00098 #define SI1143_PSLED12_SELECT              0x02
00099 #define SI1143_PSLED3_SELECT               0x03
00100 #define SI1143_FILTER_EN                   0x04
00101 #define SI1143_PS_ENCODING                 0x05
00102 #define SI1143_ALS_ENCODING                0x06
00103 #define SI1143_PS1_ADCMUX                  0x07
00104 #define SI1143_PS2_ADCMUX                  0x08
00105 #define SI1143_PS3_ADCMUX                  0x09
00106 #define SI1143_PS_ADC_COUNTER              0x0A
00107 #define SI1143_PS_ADC_GAIN                 0x0B
00108 #define SI1143_PS_ADC_MISC                 0x0C
00109 #define SI1143_ALS1_ADCMUX                 0x0D
00110 #define SI1143_ALS2_ADCMUX                 0x0E
00111 #define SI1143_ALS3_ADCMUX                 0x0F
00112 #define SI1143_ALS_VIS_ADC_COUNTER         0x10
00113 #define SI1143_ALS_VIS_ADC_GAIN            0x11
00114 #define SI1143_ALS_VIS_ADC_MISC            0x12
00115 #define SI1143_ALS_HYST                    0x16
00116 #define SI1143_PS_HYST                     0x17
00117 #define SI1143_PS_HISTORY                  0x18
00118 #define SI1143_ALS_HISTORY                 0x19
00119 #define SI1143_ADC_OFFSET                  0x1A
00120 #define SI1143_SLEEP_CTRL                  0x1B
00121 #define SI1143_LED_REC                     0x1C
00122 #define SI1143_ALS_IR_ADC_COUNTER          0x1D
00123 #define SI1143_ALS_IR_ADC_GAIN             0x1E
00124 #define SI1143_ALS_IR_ADC_MISC             0x1F
00125 
00126 // Measurement Channel List
00127 
00128 #define SI1143_PS1_TASK                    0x01
00129 #define SI1143_PS2_TASK                    0x02
00130 #define SI1143_PS3_TASK                    0x04
00131 #define SI1143_ALS_VIS_TASK                0x10
00132 #define SI1143_ALS_IR_TASK                 0x20
00133 #define SI1143_AUX_TASK                    0x40
00134 
00135 
00136 /**
00137  * @class SI1143
00138  * @brief Provides Functionality to control  the SI1143 Sensor on the Sensbert
00139  */
00140 
00141 class SI1143
00142 {
00143     public:
00144         SI1143(I2C_RT*);
00145 
00146 
00147         /**
00148          * @brief Initializes the SI1143 according to the desired SI1143_MODE
00149          * @param desiredMode the desired Mode depending on which the SI1143 has
00150          * to be configured
00151          */
00152         void init(SI1143_MODE desiredMode);
00153         /**
00154          * @brief Restarts the Sensor and its functionality
00155          */
00156         void restart(void);
00157 
00158 
00159         /**
00160          * @brief Get the actual proximity that has been measured
00161          * @param repeat how many time the measurement has been taken to get an average
00162          * proximity value
00163          * @return
00164          */
00165         int getProximity(int repeat);
00166 
00167         /**
00168          * @brief Get the actual ambient light that has been measured
00169          * @param repeat how many time the measurement has been taken to get an average
00170          * ambient light value
00171          * @return
00172          */
00173         int getAmbientLight(int repeat);
00174 
00175         /**
00176          * @brief Get the actual infrared light that has been measured
00177          * @param repeat how many time the measurement has been taken to get an average
00178          * infrared light value
00179          * @return
00180          */
00181         int getInfraRedLight(int repeat);
00182 
00183 
00184     private:
00185 
00186         I2C* i2c_;
00187         I2C_RT* i2c;
00188         int bias1,bias2,bias3;
00189 
00190         SI1143Config* config;
00191 
00192         /**
00193          * @brief Sends commands via i2c to the command register.
00194          * Is used to control the Sensor
00195          * @param cmd command to be sent to the command register
00196          */
00197         void command(uint8_t cmd);
00198 
00199         /**
00200          * @brief Configure SI1143 Interrupts internally
00201          * according to its SI1143Config
00202          */
00203         void configureInterrupts();
00204 
00205         /**
00206          * @brief Sets the proximity sensing threshold of led 1
00207          * according to its SI1143Config
00208          */
00209         void setProximitySensing1Threshold();
00210 
00211 };
00212 
00213 #endif /* SI1143_H_ */