MAX44000 Ambient and Infrared Proximity Sensor
Dependents: test_MAX44000 testSensor PMK2022_Agriculture
MAX44000.h
00001 /** MAX44000 Ambient and Infrared Proximity Sensor 00002 * I2C 7bit address: 0x4A 00003 * 00004 */ 00005 00006 #ifndef _MAX44000_H_ 00007 #define _MAX44000_H_ 00008 00009 #include "mbed.h" 00010 00011 /** @code 00012 * Registers 00013 * addr : R/W : Rst : Register 00014 * 0x00 : R : 0x04 : Interrupt Status 00015 * 0x01 : R/W : 0x24 : Main Configuration 00016 * 0x02 : R/W : 0x00 : Receive Configuration 00017 * 0x03 : R/W : 0x00 : Transmit Configuration 00018 * 0x04 : R : 0x00 : ADC High Byte (ALS) 00019 * 0x05 : R : 0x00 : ADC Low Byte (ALS) 00020 * 0x16 : R : 0x00 : ADC Byte (PROX) 00021 * 0x06 : R/W : 0x00 : ALS Upper Threshold (High Byte) 00022 * 0x07 : R/W : 0x00 : ALS Upper Threshold (Low Byte) 00023 * 0x08 : R/W : 0x00 : ALS Lower Threshold (High Byte) 00024 * 0x09 : R/W : 0x00 : ALS Lower Threshold (Low Byte) 00025 * 0x0A : R/W : 0x00 : Threshold Persist Timer 00026 * 0x0B : R/W : 0x00 : PROX Threshold Indicator 00027 * 0x0C : R/W : 0x00 : PROX Threshold 00028 * 0x0F : R/W : 0x80 : Digital Gain Trim of Green Channel 00029 * 0x10 : R/W : 0x80 : Digital Gain Trim of Infrared Channel 00030 * 00031 * 0x00 : R : 0x04 : Interrupt Status 00032 * Bit[7:3] : (reserved) 00033 * Bit[2] : PWRON : if set, indicates that a power-on-reset (POR) condition has occurred, 00034 * and any user-programmed thresholds cannot be valid anymore. 00035 * Bit[1] : PRXINTS : indicates that an ambient light nterrupt condition occurred. 00036 * BIt[0] : ALSINTS : indicates that a proximity receive interrupt condition occurred. 00037 * 00038 * 0x01 : R/W : 0x24 : Main Configuration 00039 * Bit[7:6] : (reserved) 00040 * Bit[5] : TRIM 00041 * 0: Use bytes written to TRIM_GAIN_GREEN[7:0] and TRIM_GAIN_IR[7:0] registers 00042 * to set the fine-trim gain of the green and IR gain channels. 00043 * 1: Use factory-programmed gains for green and IR channels. 00044 * Ignore bytes written to TRIM_GAIN_GEEN[7:0] and TRIM_GAIN_IR[7:0] registers. 00045 * Bit[4:2] : mode 00046 * 000: Shutdown : Analog circuits are shut down, but the digital register retains values. 00047 * 001: ALS G-IR : Standard ALS mode stores the difference between green and infrared channel readings. 00048 * Proximity channel operation and updates are disabled. 00049 * 010: ALS G : ALS green channel only. Proximity channel operation and updates are disabled. 00050 * 011: ALS IR : Infrared channel only. Proximity channel operation and updates are disabled. 00051 * 100: ALS/PROX : ALS and PROX are interleaved continuously. 00052 * 101: PROX Only : PROX only continuously. ALS channel operation and updates are disabled. 00053 * 110: (reserved) 00054 * 111: (reserved) 00055 * Bit[1] : PRXINTE : 00056 * 0 : The PRXINTS bit remains unasserted, and proximity channel readings 00057 * are not compared with interrupt thresholds. 00058 * 1 : Detection of a proxmity interrupt event triggers a hardware interrupt (/INT pin is pulled low) 00059 * and sets the PRXINTS bit (register 0x00, B1). Proximity channel readings are compared with 00060 * proximity interrupt threshold settings and proximity persist timer. 00061 * Bit[0] : ALSINTE 00062 * 0 : The ALSINTS bit reamins unasserted, and ALS channel readings are not compared with interrupt thresholds. 00063 * 1 : Detection of an ambient light interrupt event triggers a hardware interrupt (/INT pin is pullued low) 00064 * and sets the ALSINTS bit (register 0x00, B0). ALS channel readings are compared with ALS interrupt 00065 * threshold settings and ALS persist timer. 00066 * 00067 * 0x02 : R/W : 0x00 : Receive Configuration 00068 * Bit[7:4] : (reserved) 00069 * Bit[3:2] : ALSTIM : Ambient ADC Conversion Time 00070 * | Intergration Time (ms) | Full-Scale ADC counts | Bit Resolution | Relative LSB Size | 00071 * 00 | 100 | 16,384 | 14 | 1x | 00072 * 01 | 25 | 4,096 | 12 | 4x | 00073 * 10 | 6.25 | 1,024 | 10 | 16x | 00074 * 11 | 1.5625 | 256 | 8 | 64x | 00075 * Bit[1:0] : ALSPGA : Ambient Light Measurement Gain 00076 * | LUX/LSB | Relative LSB Size | 00077 * 00 | 0.03125 | 1x | 00078 * 01 | 0.125 | 4x | 00079 * 10 | 0.5 | 16x | 00080 * 11 | 4 | 128x | 00081 * 00082 * 0x03 | R/W | 0x00 | Transmit Configuration 00083 * 0x04 | R | 0x00 | ADC High Byte (ALS) 00084 * 0x05 | R | 0x00 | ADC Low Byte (ALS) 00085 * 0x16 | R | 0x00 | ADC Byte (PROX) 00086 @endcode 00087 */ 00088 00089 00090 00091 class MAX44000 00092 { 00093 public: 00094 /** 00095 * constructor 00096 * 00097 * @param sda SDA pin 00098 * @param scl SCL pin 00099 * @param addr address of the I2C peripheral 00100 */ 00101 MAX44000(PinName sda, PinName scl, int addr) ; 00102 00103 /** 00104 * destructor 00105 */ 00106 ~MAX44000() ; 00107 00108 /* 00109 * some member functions here (yet to be written) 00110 */ 00111 00112 /** 00113 * Get Interrupt Status 00114 * @param uint8_t *data pointer to receive the 8bit register value. 00115 */ 00116 void getIntStatus(uint8_t *data) ; 00117 /** 00118 * Get Main Configuration 00119 * @param uint8_t *conf pointer to receive the 8bit register value. 00120 */ 00121 void getMainConfig(uint8_t *conf) ; 00122 /** 00123 * Set Mein Configuration 00124 * @param conf uint8_t to specify the 8bit register value. 00125 */ 00126 void setMainConfig(uint8_t newConf) ; 00127 void getRxConfig(uint8_t *conf) ; 00128 void setRxConfig(uint8_t newConf) ; 00129 void getTxConfig(uint8_t *conf) ; 00130 void setTxConfig(uint8_t newConf) ; 00131 /** 00132 * Get ALS 00133 * 00134 * @param uint8_t *ofl overflow indicator 00135 * @param uint16_t *value ALS value 00136 */ 00137 void getALS(uint8_t *ofl, uint16_t *value) ; 00138 /** 00139 * Get PROX 00140 * 00141 * @param uint8_t *value PROX value 00142 */ 00143 void getProx(uint8_t *value) ; 00144 /** 00145 * Get ADC value(s) 00146 * 00147 * @param uint8_t *ofl overfolow indicator 00148 * @param uint16_t *als ALS data 00149 * @param uint8_t *prox PROX data 00150 */ 00151 void getADC(uint8_t *ofl, uint16_t *als, uint8_t *prox) ; 00152 void getUPTHR(uint16_t *thr) ; 00153 void setUPTHR(uint16_t newThr) ; 00154 void getLOTHR(uint16_t *thr) ; 00155 void setLOTHR(uint16_t newThr) ; 00156 void getTHRPT(uint8_t *data) ; 00157 void setTHRPT(uint8_t newData) ; 00158 void getPRXTHR_IND(uint8_t *value) ; 00159 void setPRXTHR_IND(uint8_t newValue) ; 00160 void getPRX_THR(uint8_t *data) ; 00161 void setPRX_THR(uint8_t newValue) ; 00162 void getTRM_GAING(uint8_t *data) ; 00163 void setTRM_GAING(uint8_t newValue) ; 00164 void getTRM_GAINIR(uint8_t *data) ; 00165 void setTRM_GAINIR(uint8_t newValue) ; 00166 00167 private: 00168 I2C m_i2c; 00169 int m_addr; 00170 void readRegs(int addr, uint8_t *data, int len) ; 00171 void writeRegs(uint8_t *data, int len) ; 00172 } ; 00173 #endif /* _MAX44000_H_ */
Generated on Wed Jul 13 2022 10:32:28 by
![doxygen](doxygen.png)