I2C sensor test program, derived from testI2C program. Simple test for FXOS8700CQ, HIH6130, MAG3110, MMA8451Q, MMA8452Q, MPL3115A2, MAX44000, MAX44005, MAX44008, MAX30101 included beside simple I2C read/write from testI2C.

Dependencies:   FXOS8700CQ HIH6130 IS31SE5000 MAG3110 MAX44000 MAX44005 MAX44008 MMA8451Q MMA8452Q MPL3115A2 VEML6040 VEML6075 mbed vt100 LM75B FXAS21002 MAX30101 VCNL4020 VCNL4100

Committer:
Rhyme
Date:
Fri Feb 24 04:25:10 2017 +0000
Revision:
12:b3dff3bbb1eb
Parent:
10:710ba5364779
Child:
14:1e6e4fdf90d0
test now accept address of sensor, but only the one found first at specified address will be tested.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:d4bbd473a83c 1 #include "mbed.h"
Rhyme 0:d4bbd473a83c 2 #include "vt100.h"
Rhyme 0:d4bbd473a83c 3 #include "MSS.h"
Rhyme 0:d4bbd473a83c 4 #include "MSU.h"
Rhyme 0:d4bbd473a83c 5 #include "MMA8451Q.h"
Rhyme 0:d4bbd473a83c 6 #include "MMA8452Q.h"
Rhyme 0:d4bbd473a83c 7 #include "MAG3110.h"
Rhyme 0:d4bbd473a83c 8 #include "HIH6130.h"
Rhyme 0:d4bbd473a83c 9 #include "FXOS8700CQ.h"
Rhyme 0:d4bbd473a83c 10 #include "MAX44000.h"
Rhyme 0:d4bbd473a83c 11 #include "MAX44005.h"
Rhyme 0:d4bbd473a83c 12 #include "MAX44008.h"
Rhyme 0:d4bbd473a83c 13 #include "MPL3115A2.h"
Rhyme 0:d4bbd473a83c 14 #include "VEML6040.h"
Rhyme 0:d4bbd473a83c 15 #include "VEML6075.h"
Rhyme 3:be01d9e0fa3e 16 #include "LM75B.h"
Rhyme 7:8f438094f8cc 17 #include "FXAS21002.h"
Rhyme 10:710ba5364779 18 #include "S11059.h"
Rhyme 0:d4bbd473a83c 19
Rhyme 0:d4bbd473a83c 20
Rhyme 0:d4bbd473a83c 21 extern int test_loop ;
Rhyme 9:d4f76e6fa35f 22 extern int interval ; /* wait interval ms */
Rhyme 0:d4bbd473a83c 23
Rhyme 0:d4bbd473a83c 24 extern vt100 *tty ;
Rhyme 0:d4bbd473a83c 25
Rhyme 0:d4bbd473a83c 26 i2c_sensor_type i2c_sensor[] = {
Rhyme 0:d4bbd473a83c 27 {MSU_MMA8451Q_ADDRESS, "MMA8451Q", testMMA8451Q},
Rhyme 0:d4bbd473a83c 28 {MSU_MMA8452Q_ADDRESS, "MMA8452Q", testMMA8452Q},
Rhyme 0:d4bbd473a83c 29 {MSU_MAG3110_ADDRESS, "MAG3110", testMAG3110},
Rhyme 0:d4bbd473a83c 30 {MSU_HIH6130_ADDRESS, "HIH6130", testHIH6130},
Rhyme 0:d4bbd473a83c 31 {MSU_FXOS8700CQ_ADDRESS, "FXOS8700CQ", testFXOS8700CQ},
Rhyme 0:d4bbd473a83c 32 {MSU_MAX44000_ADDRESS, "MAX44000", testMAX44000},
Rhyme 0:d4bbd473a83c 33 {MSU_MAX44005_ADDRESS, "MAX44005", testMAX44005},
Rhyme 0:d4bbd473a83c 34 {MSU_MAX44008_ADDRESS, "MAX44008", testMAX44008},
Rhyme 0:d4bbd473a83c 35 {MSU_MAX30101_ADDRESS, "MAX30101", testMAX30101},
Rhyme 0:d4bbd473a83c 36 {MSU_MPL3115A2_ADDRESS, "MPL3115A2", testMPL3115A2},
Rhyme 0:d4bbd473a83c 37 {MSU_IS31SE5000_ADDRESS, "IS31SE5000", testIS31SE5000},
Rhyme 0:d4bbd473a83c 38 {MSU_VEML6040A_ADDRESS, "VEML6040A", testVEML6040A},
Rhyme 0:d4bbd473a83c 39 {MSU_VEML6075A_ADDRESS, "VEML6075A", testVEML6075A},
Rhyme 3:be01d9e0fa3e 40 {MSU_LM75B_ADDRESS, "LM75B", testLM75B},
Rhyme 7:8f438094f8cc 41 {MSU_FXAS21002_ADDRESS, "FXAS21002", testFXAS21002},
Rhyme 10:710ba5364779 42 {MSU_S11059_ADDRESS, "S11059", testS11059},
Rhyme 0:d4bbd473a83c 43 {0x00, 0, 0}
Rhyme 0:d4bbd473a83c 44 } ;
Rhyme 0:d4bbd473a83c 45
Rhyme 3:be01d9e0fa3e 46 void testLM75B(void)
Rhyme 3:be01d9e0fa3e 47 {
Rhyme 3:be01d9e0fa3e 48 int8_t itemp = 0 ;
Rhyme 3:be01d9e0fa3e 49 float ftemp = 0.0 ;
Rhyme 3:be01d9e0fa3e 50 printf("test LM75B\n") ;
Rhyme 3:be01d9e0fa3e 51 LM75B *lm75b = new LM75B(PIN_SDA, PIN_SCL, MSU_LM75B_ADDRESS) ;
Rhyme 3:be01d9e0fa3e 52 for (int i = 0 ; i < test_loop ; i++ ) {
Rhyme 3:be01d9e0fa3e 53 itemp = lm75b->temp() ;
Rhyme 3:be01d9e0fa3e 54 lm75b->getTemp(&ftemp) ;
Rhyme 3:be01d9e0fa3e 55 printf("Temp = %d C degree, %.3f C degree\n", itemp, ftemp) ;
Rhyme 9:d4f76e6fa35f 56 wait_ms(interval) ;
Rhyme 3:be01d9e0fa3e 57 }
Rhyme 7:8f438094f8cc 58 delete lm75b ;
Rhyme 3:be01d9e0fa3e 59 }
Rhyme 3:be01d9e0fa3e 60
Rhyme 7:8f438094f8cc 61 void testFXAS21002(void)
Rhyme 7:8f438094f8cc 62 {
Rhyme 7:8f438094f8cc 63 int16_t data[3] ;
Rhyme 7:8f438094f8cc 64
Rhyme 7:8f438094f8cc 65 printf("test FXAS21002\n") ;
Rhyme 7:8f438094f8cc 66 FXAS21002 *fxas = new FXAS21002(PIN_SDA, PIN_SCL, MSU_FXAS21002_ADDRESS) ;
Rhyme 7:8f438094f8cc 67 fxas->activate(true) ;
Rhyme 7:8f438094f8cc 68
Rhyme 7:8f438094f8cc 69 for (int i = 0 ; i < test_loop ; i++ ) {
Rhyme 7:8f438094f8cc 70 data[0] = fxas->getX() ;
Rhyme 7:8f438094f8cc 71 data[1] = fxas->getY() ;
Rhyme 7:8f438094f8cc 72 data[2] = fxas->getZ() ;
Rhyme 7:8f438094f8cc 73 printf("X[%6d], Y[%6d], Z[%6d]\n",
Rhyme 7:8f438094f8cc 74 data[0], data[1], data[2]) ;
Rhyme 9:d4f76e6fa35f 75 wait_ms(interval) ;
Rhyme 7:8f438094f8cc 76 }
Rhyme 7:8f438094f8cc 77 delete fxas ;
Rhyme 7:8f438094f8cc 78 }
Rhyme 7:8f438094f8cc 79
Rhyme 0:d4bbd473a83c 80 void testMMA8451Q(void)
Rhyme 0:d4bbd473a83c 81 {
Rhyme 0:d4bbd473a83c 82 uint16_t ix, iy, iz ;
Rhyme 0:d4bbd473a83c 83 float fx, fy, fz ;
Rhyme 0:d4bbd473a83c 84
Rhyme 0:d4bbd473a83c 85 printf("test MMA8451Q\n") ;
Rhyme 0:d4bbd473a83c 86 MMA8451Q *acc = new MMA8451Q(PIN_SDA, PIN_SCL, MSU_MMA8451Q_ADDRESS) ;
Rhyme 0:d4bbd473a83c 87 for(int i = 0 ; i < test_loop ; i++) {
Rhyme 0:d4bbd473a83c 88 ix = acc->getRawX() ;
Rhyme 0:d4bbd473a83c 89 iy = acc->getRawY() ;
Rhyme 0:d4bbd473a83c 90 iz = acc->getRawZ() ;
Rhyme 0:d4bbd473a83c 91 fx = acc->getAccX() ;
Rhyme 0:d4bbd473a83c 92 fy = acc->getAccY() ;
Rhyme 0:d4bbd473a83c 93 fz = acc->getAccZ() ;
Rhyme 0:d4bbd473a83c 94 printf("X = %d [ %.2f ], Y = %d [ %.2f ], Z = %d [ %.2f ]\n",
Rhyme 0:d4bbd473a83c 95 ix, fx, iy, fy, iz, fz ) ;
Rhyme 9:d4f76e6fa35f 96 wait_ms(interval) ;
Rhyme 0:d4bbd473a83c 97 }
Rhyme 0:d4bbd473a83c 98 delete acc ;
Rhyme 0:d4bbd473a83c 99 }
Rhyme 0:d4bbd473a83c 100
Rhyme 0:d4bbd473a83c 101 void testMMA8452Q(void)
Rhyme 0:d4bbd473a83c 102 {
Rhyme 0:d4bbd473a83c 103 float x, y, z ;
Rhyme 0:d4bbd473a83c 104 printf("test MMA8452Q\n") ;
Rhyme 0:d4bbd473a83c 105 MMA8452Q *acc = new MMA8452Q(PIN_SDA, PIN_SCL, MSU_MMA8452Q_ADDRESS) ;
Rhyme 0:d4bbd473a83c 106 for(int i = 0 ; i < test_loop ; i++) {
Rhyme 0:d4bbd473a83c 107 x = acc->getAccX() ;
Rhyme 0:d4bbd473a83c 108 y = acc->getAccY() ;
Rhyme 0:d4bbd473a83c 109 z = acc->getAccZ() ;
Rhyme 0:d4bbd473a83c 110 printf("X[%.2f] Y[%.2f] Z[%.2f]\n",x, y, z) ;
Rhyme 9:d4f76e6fa35f 111 wait_ms(interval) ;
Rhyme 0:d4bbd473a83c 112 }
Rhyme 0:d4bbd473a83c 113 delete acc ;
Rhyme 0:d4bbd473a83c 114 }
Rhyme 0:d4bbd473a83c 115
Rhyme 0:d4bbd473a83c 116 void testMAG3110(void)
Rhyme 0:d4bbd473a83c 117 {
Rhyme 0:d4bbd473a83c 118 uint8_t status = 0 ;
Rhyme 0:d4bbd473a83c 119 int16_t mX, mY, mZ ;
Rhyme 0:d4bbd473a83c 120 float fx, fy, fz ;
Rhyme 0:d4bbd473a83c 121 int x = 10 ;
Rhyme 0:d4bbd473a83c 122 int y = 5 ;
Rhyme 0:d4bbd473a83c 123 MAG3110 *mag = new MAG3110(PIN_SDA, PIN_SCL, MSU_MAG3110_ADDRESS) ;
Rhyme 0:d4bbd473a83c 124 mag->activate() ;
Rhyme 0:d4bbd473a83c 125 tty->cls() ;
Rhyme 0:d4bbd473a83c 126 printf("test MAG3110\n") ;
Rhyme 0:d4bbd473a83c 127 for (int i = 0 ; i < test_loop ; i++) {
Rhyme 9:d4f76e6fa35f 128 wait_ms(interval) ;
Rhyme 0:d4bbd473a83c 129 status = mag->getStatus() ;
Rhyme 0:d4bbd473a83c 130 while((status & 0x80) == 0) { // wait for ZYXOW
Rhyme 0:d4bbd473a83c 131 wait(0.01) ;
Rhyme 0:d4bbd473a83c 132 status = mag->getStatus() ;
Rhyme 0:d4bbd473a83c 133 }
Rhyme 0:d4bbd473a83c 134
Rhyme 0:d4bbd473a83c 135 tty->locate(x+5, y) ;
Rhyme 0:d4bbd473a83c 136 printf("--- MAG3110 ---") ;
Rhyme 0:d4bbd473a83c 137 tty->locate(x, y+4) ;
Rhyme 0:d4bbd473a83c 138 printf("Temperature: %02X",mag->getTemp()) ;
Rhyme 0:d4bbd473a83c 139 tty->locate(x, y+5) ;
Rhyme 0:d4bbd473a83c 140 printf("status: 0x%02X",mag->getStatus()) ;
Rhyme 0:d4bbd473a83c 141 tty->locate(x, y+6) ;
Rhyme 0:d4bbd473a83c 142 printf("ctrl reg1: 0x%02X ", mag->getCtrlReg1()) ;
Rhyme 0:d4bbd473a83c 143 printf("reg2: 0x%02X", mag->getCtrlReg2()) ;
Rhyme 0:d4bbd473a83c 144 mX = mag->getX() ; // here reset takes place!
Rhyme 0:d4bbd473a83c 145 mY = mag->getY() ;
Rhyme 0:d4bbd473a83c 146 mZ = mag->getZ() ;
Rhyme 0:d4bbd473a83c 147 fx = 10000 * (float)mX / (float)0x7FFF ;
Rhyme 0:d4bbd473a83c 148 fy = 10000 * (float)mY / (float)0x7FFF ;
Rhyme 0:d4bbd473a83c 149 fz = 10000 * (float)mZ / (float)0x7FFF ;
Rhyme 0:d4bbd473a83c 150 tty->locate(x, y+1) ;
Rhyme 0:d4bbd473a83c 151 printf("X : ") ;
Rhyme 0:d4bbd473a83c 152 if (fx >= 0) { printf(" ") ; }
Rhyme 0:d4bbd473a83c 153 printf("%.2f uT : 0x%08X ", fx, mX) ;
Rhyme 0:d4bbd473a83c 154
Rhyme 0:d4bbd473a83c 155 tty->locate(x, y+2) ;
Rhyme 0:d4bbd473a83c 156 printf("Y : ") ;
Rhyme 0:d4bbd473a83c 157 if (fy >= 0) { printf(" ") ; }
Rhyme 0:d4bbd473a83c 158 printf("%.2f uT : 0x%08X ", fy, mY) ;
Rhyme 0:d4bbd473a83c 159
Rhyme 0:d4bbd473a83c 160 tty->locate(x, y+3) ;
Rhyme 0:d4bbd473a83c 161 printf("Z : ") ;
Rhyme 0:d4bbd473a83c 162 if (fz >= 0) { printf(" ") ; }
Rhyme 0:d4bbd473a83c 163 printf("%.2f uT : 0x%08X ", fz, mZ) ;
Rhyme 0:d4bbd473a83c 164 }
Rhyme 0:d4bbd473a83c 165 tty->locate(0, 20) ;
Rhyme 0:d4bbd473a83c 166 mag->standby() ;
Rhyme 0:d4bbd473a83c 167 delete mag ;
Rhyme 0:d4bbd473a83c 168 }
Rhyme 0:d4bbd473a83c 169
Rhyme 0:d4bbd473a83c 170 void testHIH6130(void)
Rhyme 0:d4bbd473a83c 171 {
Rhyme 0:d4bbd473a83c 172 uint16_t result = 0 ;
Rhyme 0:d4bbd473a83c 173 float humidity = 0 ;
Rhyme 0:d4bbd473a83c 174 float temperature = 0 ;
Rhyme 0:d4bbd473a83c 175 HIH6130 *hih = new HIH6130(PIN_SDA, PIN_SCL, MSU_HIH6130_ADDRESS) ;
Rhyme 0:d4bbd473a83c 176 printf("test HIH6130\n") ;
Rhyme 0:d4bbd473a83c 177 for (int i = 0 ; i < test_loop ; i++) {
Rhyme 0:d4bbd473a83c 178 result = hih->getValue(&humidity, &temperature) ;
Rhyme 0:d4bbd473a83c 179 printf("Temp %.1f C Humidity %.1f %%\n", temperature, humidity) ;
Rhyme 9:d4f76e6fa35f 180 wait_ms(interval) ;
Rhyme 0:d4bbd473a83c 181 }
Rhyme 0:d4bbd473a83c 182 }
Rhyme 0:d4bbd473a83c 183
Rhyme 0:d4bbd473a83c 184 void testFXOS8700CQ(void)
Rhyme 0:d4bbd473a83c 185 {
Rhyme 0:d4bbd473a83c 186 int16_t accData[3], mgnData[3] ;
Rhyme 0:d4bbd473a83c 187
Rhyme 0:d4bbd473a83c 188 printf("test FXOS8700CQ\n") ;
Rhyme 0:d4bbd473a83c 189 FXOS8700CQ *fxos = new FXOS8700CQ(PIN_SDA, PIN_SCL, MSU_FXOS8700CQ_ADDRESS) ;
Rhyme 0:d4bbd473a83c 190 fxos->init() ;
Rhyme 0:d4bbd473a83c 191
Rhyme 0:d4bbd473a83c 192 for (int i = 0 ; i < test_loop ; i++) {
Rhyme 0:d4bbd473a83c 193 fxos->readAccMgnData(accData, mgnData) ;
Rhyme 0:d4bbd473a83c 194 printf("ACC X[%d], Y[%d], Z[%d], MGN X[%d], Y[%d], Z[%d]\n",
Rhyme 0:d4bbd473a83c 195 accData[0], accData[1], accData[2],
Rhyme 0:d4bbd473a83c 196 mgnData[0], mgnData[1], mgnData[2]) ;
Rhyme 9:d4f76e6fa35f 197 wait_ms(interval) ;
Rhyme 0:d4bbd473a83c 198 }
Rhyme 0:d4bbd473a83c 199 delete fxos ;
Rhyme 0:d4bbd473a83c 200 }
Rhyme 0:d4bbd473a83c 201
Rhyme 1:9450e20cf688 202 void testMAX44000(void)
Rhyme 1:9450e20cf688 203 {
Rhyme 1:9450e20cf688 204 uint8_t mode ;
Rhyme 1:9450e20cf688 205 uint8_t txdata, rxdata ;
Rhyme 1:9450e20cf688 206 uint16_t als ;
Rhyme 1:9450e20cf688 207 uint8_t prox, overflow ;
Rhyme 1:9450e20cf688 208 int x = 10 ;
Rhyme 1:9450e20cf688 209 int y = 5 ;
Rhyme 1:9450e20cf688 210
Rhyme 1:9450e20cf688 211 tty->cls() ;
Rhyme 1:9450e20cf688 212 printf("test MAX44000\n") ;
Rhyme 1:9450e20cf688 213 MAX44000 *max44000 = new MAX44000(PIN_SDA, PIN_SCL, MSU_MAX44000_ADDRESS) ;
Rhyme 1:9450e20cf688 214
Rhyme 1:9450e20cf688 215 rxdata = 0xF1 ;
Rhyme 1:9450e20cf688 216 max44000->setRxConfig(rxdata) ;
Rhyme 6:897f32c6ef7d 217 txdata = 0x0F ; /* light LED! */
Rhyme 1:9450e20cf688 218 max44000->setTxConfig(txdata) ;
Rhyme 6:897f32c6ef7d 219 mode = 0x30 ; // ALS & PROX mode
Rhyme 1:9450e20cf688 220 max44000->setMainConfig(mode) ;
Rhyme 1:9450e20cf688 221
Rhyme 1:9450e20cf688 222 for (int i = 0 ; i < test_loop ; i++ ) {
Rhyme 1:9450e20cf688 223 max44000->getADC(&overflow, &als, &prox) ;
Rhyme 1:9450e20cf688 224 printf("ALS[ %04X ]", als) ;
Rhyme 1:9450e20cf688 225 if (overflow) {
Rhyme 5:cdac8329b22c 226 printf(" overflow ") ;
Rhyme 1:9450e20cf688 227 } else {
Rhyme 5:cdac8329b22c 228 printf(" ") ;
Rhyme 1:9450e20cf688 229 }
Rhyme 5:cdac8329b22c 230 printf("PRX[ %02X ]\n", prox) ;
Rhyme 9:d4f76e6fa35f 231 wait_ms(interval) ;
Rhyme 1:9450e20cf688 232 }
Rhyme 6:897f32c6ef7d 233 txdata = 0x00 ; /* dim LED! */
Rhyme 6:897f32c6ef7d 234 max44000->setTxConfig(txdata) ;
Rhyme 1:9450e20cf688 235 delete max44000 ;
Rhyme 1:9450e20cf688 236 }
Rhyme 1:9450e20cf688 237
Rhyme 1:9450e20cf688 238 void testMAX44005(void)
Rhyme 1:9450e20cf688 239 {
Rhyme 1:9450e20cf688 240 uint16_t amb_c, amb_r, amb_g, amb_b, amb_ir, amb_ircomp, amb_temp ;
Rhyme 1:9450e20cf688 241 MAX44005 *max44005 = new MAX44005(PIN_SDA, PIN_SCL, MSU_MAX44005_ADDRESS) ;
Rhyme 1:9450e20cf688 242 max44005->enableTEMP() ;
Rhyme 1:9450e20cf688 243 max44005->setMode(0x04) ;
Rhyme 1:9450e20cf688 244 printf("test MAX44005\n") ;
Rhyme 1:9450e20cf688 245
Rhyme 1:9450e20cf688 246 for (int i = 0 ; i < test_loop ; i++ ) {
Rhyme 1:9450e20cf688 247 amb_c = max44005->getAMB_CLEAR() ;
Rhyme 1:9450e20cf688 248 amb_r = max44005->getAMB_RED() ;
Rhyme 1:9450e20cf688 249 amb_g = max44005->getAMB_GREEN() ;
Rhyme 1:9450e20cf688 250 amb_b = max44005->getAMB_BLUE() ;
Rhyme 1:9450e20cf688 251 amb_ir = max44005->getIR() ;
Rhyme 1:9450e20cf688 252 amb_ircomp = max44005->getIRCOMP() ;
Rhyme 1:9450e20cf688 253 amb_temp = max44005->getTEMP() ;
Rhyme 1:9450e20cf688 254 printf("--- MAX44005 ---\n") ;
Rhyme 1:9450e20cf688 255 printf(" C[ %04X ]\n", amb_c) ;
Rhyme 1:9450e20cf688 256 printf("R[ %04X ] G[ %04X ] B[ %04X ]\n",amb_r, amb_g, amb_b) ;
Rhyme 1:9450e20cf688 257 printf("IR[ %04X ] IRCOMP [ %04X ]\n",amb_ir, amb_ircomp) ;
Rhyme 1:9450e20cf688 258 printf(" TEMP [ %04X ]\n",amb_temp) ;
Rhyme 1:9450e20cf688 259 printf("\n") ;
Rhyme 9:d4f76e6fa35f 260 wait_ms(interval) ;
Rhyme 1:9450e20cf688 261 }
Rhyme 1:9450e20cf688 262 delete max44005 ;
Rhyme 1:9450e20cf688 263 }
Rhyme 1:9450e20cf688 264
Rhyme 1:9450e20cf688 265 #define MODE_CLEAR_RGB_IR 0x02
Rhyme 1:9450e20cf688 266 void testMAX44008(void)
Rhyme 1:9450e20cf688 267 {
Rhyme 1:9450e20cf688 268 uint16_t amb_c, amb_r, amb_g, amb_b, amb_ir, amb_ircomp, amb_temp ;
Rhyme 1:9450e20cf688 269
Rhyme 1:9450e20cf688 270 MAX44008 *max44008 = new MAX44008(PIN_SDA, PIN_SCL, MSU_MAX44008_ADDRESS) ;
Rhyme 1:9450e20cf688 271 max44008->setMode(MODE_CLEAR_RGB_IR) ;
Rhyme 1:9450e20cf688 272 printf("test MAX44008\n") ;
Rhyme 1:9450e20cf688 273
Rhyme 1:9450e20cf688 274 for (int i = 0 ; i < test_loop ; i++ ) {
Rhyme 1:9450e20cf688 275 amb_c = max44008->getAMB_CLEAR() ;
Rhyme 1:9450e20cf688 276 amb_r = max44008->getAMB_RED() ;
Rhyme 1:9450e20cf688 277 amb_g = max44008->getAMB_GREEN() ;
Rhyme 1:9450e20cf688 278 amb_b = max44008->getAMB_BLUE() ;
Rhyme 1:9450e20cf688 279 amb_ir = max44008->getIR() ;
Rhyme 1:9450e20cf688 280 amb_ircomp = max44008->getIRCOMP() ;
Rhyme 1:9450e20cf688 281 amb_temp = max44008->getTEMP() ;
Rhyme 1:9450e20cf688 282 printf("--- MAX44008 ---\n") ;
Rhyme 1:9450e20cf688 283 printf(" C[ %04X ]\n", amb_c) ;
Rhyme 1:9450e20cf688 284 printf("R[ %04X ] G[ %04X ] B[ %04X ]\n",amb_r, amb_g, amb_b) ;
Rhyme 1:9450e20cf688 285 printf("IR[ %04X ] IRCOMP [ %04X ]\n",amb_ir, amb_ircomp) ;
Rhyme 1:9450e20cf688 286 printf(" TEMP [ %04X ]\n",amb_temp) ;
Rhyme 1:9450e20cf688 287 printf("\n") ;
Rhyme 9:d4f76e6fa35f 288 wait_ms(interval) ;
Rhyme 1:9450e20cf688 289 }
Rhyme 1:9450e20cf688 290 delete max44008 ;
Rhyme 1:9450e20cf688 291 }
Rhyme 1:9450e20cf688 292
Rhyme 1:9450e20cf688 293 void testMAX30101(void)
Rhyme 1:9450e20cf688 294 {
Rhyme 1:9450e20cf688 295 printf("test MAX30101\n") ;
Rhyme 1:9450e20cf688 296 printf("Sorry not implemented yet\n") ;
Rhyme 1:9450e20cf688 297 }
Rhyme 1:9450e20cf688 298
Rhyme 1:9450e20cf688 299 void testMPL3115A2(void)
Rhyme 1:9450e20cf688 300 {
Rhyme 1:9450e20cf688 301 uint32_t data, alt, bar, tmp ;
Rhyme 1:9450e20cf688 302 uint16_t sample_time ;
Rhyme 1:9450e20cf688 303 MPL3115A2 *mpl = new MPL3115A2(PIN_SDA, PIN_SCL, MSU_MPL3115A2_ADDRESS) ;
Rhyme 1:9450e20cf688 304
Rhyme 1:9450e20cf688 305 printf("test MPL3115A2\n") ;
Rhyme 1:9450e20cf688 306 for (int i = 0 ; i < test_loop ; i++) {
Rhyme 1:9450e20cf688 307 mpl->modeAlt() ;
Rhyme 1:9450e20cf688 308 sample_time = mpl->OneShot() ;
Rhyme 1:9450e20cf688 309 wait(((double)sample_time)/1000.0) ;
Rhyme 1:9450e20cf688 310 alt = mpl->getAltitude() ;
Rhyme 1:9450e20cf688 311 mpl->modeBar() ;
Rhyme 1:9450e20cf688 312 sample_time = mpl->OneShot() ;
Rhyme 1:9450e20cf688 313 wait(((double)sample_time)/1000.0) ;
Rhyme 1:9450e20cf688 314 bar = mpl->getPressure() ;
Rhyme 1:9450e20cf688 315 tmp = mpl->getTemperature() ;
Rhyme 1:9450e20cf688 316 printf("Altitude: %d, Pressure: %d, Temperature: %d\n",
Rhyme 1:9450e20cf688 317 (alt >> 16)&0xFFFF,
Rhyme 1:9450e20cf688 318 (bar >> 6),
Rhyme 1:9450e20cf688 319 (tmp >> 8) ) ;
Rhyme 9:d4f76e6fa35f 320 wait_ms(interval) ;
Rhyme 1:9450e20cf688 321 }
Rhyme 1:9450e20cf688 322 delete mpl ;
Rhyme 1:9450e20cf688 323 }
Rhyme 1:9450e20cf688 324
Rhyme 1:9450e20cf688 325 void testIS31SE5000(void)
Rhyme 1:9450e20cf688 326 {
Rhyme 1:9450e20cf688 327 printf("test ISI31SE5000\n") ;
Rhyme 1:9450e20cf688 328 printf("Sorry not implemented yet\n") ;
Rhyme 1:9450e20cf688 329 }
Rhyme 1:9450e20cf688 330
Rhyme 1:9450e20cf688 331 void testVEML6040A(void)
Rhyme 1:9450e20cf688 332 {
Rhyme 9:d4f76e6fa35f 333 uint16_t uR, uG, uB, uW ;
Rhyme 9:d4f76e6fa35f 334 VEML6040 *veml = new VEML6040(PIN_SDA, PIN_SCL, MSU_VEML6040A_ADDRESS) ;
Rhyme 9:d4f76e6fa35f 335
Rhyme 9:d4f76e6fa35f 336 for (int i = 0 ; i < test_loop ; i++ ) {
Rhyme 9:d4f76e6fa35f 337 veml->setCOLORConf(0x04) ; /* one time trigger, other wise write 0 */
Rhyme 9:d4f76e6fa35f 338 wait(0.1) ;
Rhyme 9:d4f76e6fa35f 339 veml->getRData(&uR) ;
Rhyme 9:d4f76e6fa35f 340 veml->getGData(&uG) ;
Rhyme 9:d4f76e6fa35f 341 veml->getBData(&uB) ;
Rhyme 9:d4f76e6fa35f 342 veml->getWData(&uW) ;
Rhyme 9:d4f76e6fa35f 343 printf("VEML6040A R[%d], G[%d], B[%d], W[%d]\n", uR, uG, uB, uW) ;
Rhyme 9:d4f76e6fa35f 344 wait_ms(interval) ;
Rhyme 9:d4f76e6fa35f 345 }
Rhyme 10:710ba5364779 346 delete veml ;
Rhyme 1:9450e20cf688 347 }
Rhyme 1:9450e20cf688 348
Rhyme 1:9450e20cf688 349 void testVEML6075A(void)
Rhyme 1:9450e20cf688 350 {
Rhyme 1:9450e20cf688 351 printf("test VEML6075A\n") ;
Rhyme 1:9450e20cf688 352 printf("Sorry not implemented yet\n") ;
Rhyme 10:710ba5364779 353 }
Rhyme 10:710ba5364779 354
Rhyme 10:710ba5364779 355 void testS11059(void)
Rhyme 10:710ba5364779 356 {
Rhyme 12:b3dff3bbb1eb 357 uint16_t uR, uG, uB, uIR ;
Rhyme 10:710ba5364779 358 uint8_t ctrl ;
Rhyme 10:710ba5364779 359 S11059 *s11059 = new S11059(PIN_SDA, PIN_SCL, MSU_S11059_ADDRESS) ;
Rhyme 10:710ba5364779 360
Rhyme 10:710ba5364779 361 for (int i = 0 ; i < test_loop ; i++ ) {
Rhyme 10:710ba5364779 362 ctrl = 0x89 ; /* ADC reset, High Gain, integration time 1.4ms */
Rhyme 10:710ba5364779 363 s11059->setControl(ctrl) ;
Rhyme 10:710ba5364779 364 ctrl = 0x09 ; /* Release ADC reset, High Gain, integration time 1.4ms */
Rhyme 10:710ba5364779 365 s11059->setControl(ctrl) ; /* start measure */
Rhyme 10:710ba5364779 366 wait(0.02) ;
Rhyme 10:710ba5364779 367 s11059->getRData(&uR) ;
Rhyme 10:710ba5364779 368 s11059->getGData(&uG) ;
Rhyme 10:710ba5364779 369 s11059->getBData(&uB) ;
Rhyme 12:b3dff3bbb1eb 370 s11059->getIRData(&uIR) ;
Rhyme 12:b3dff3bbb1eb 371 printf("S11059 R[%d], G[%d], B[%d], IR[%d]\n", uR, uG, uB, uIR) ;
Rhyme 10:710ba5364779 372 wait_ms(interval) ;
Rhyme 10:710ba5364779 373 }
Rhyme 10:710ba5364779 374 delete s11059 ;
Rhyme 1:9450e20cf688 375 }