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
Diff: testSensor.cpp
- Revision:
- 17:514f67d94d12
- Parent:
- 14:1e6e4fdf90d0
- Child:
- 18:ee6f43cbfcc1
--- a/testSensor.cpp Tue Mar 28 04:43:23 2017 +0000 +++ b/testSensor.cpp Wed Sep 13 05:23:18 2017 +0000 @@ -32,6 +32,12 @@ int test_loop = TEST_LOOP ; int interval = 100 ; /* ms wait interval */ +void doSWReset(void) +{ + printf("Software Reset\n") ; + SCB->AIRCR = 0x05FA0004 ; +} + void doClose(void) { if (i2c != 0) { @@ -131,6 +137,7 @@ printf("status : print current status\n") ; printf("demo : mulitple sensor demo\n") ; printf("help : print this help\n") ; + printf("zzz : cause software reset\n") ; printf("\nPlease set local-echo to see what you are typing.\n") ; printf("\n") ; } @@ -170,12 +177,7 @@ for (address = 1; address < 127 ; address++) { i2c = new DUMB_I2C(PIN_SDA, PIN_SCL, address) ; -// result = i2c->read(address, &data, 1) ; - if (address == 0x10) { - num_data = 2 ; - } else { - num_data = 1 ; - } + num_data = 2 ; result = i2c->read(0, data, num_data) ; if (result == 0) { printf("%02X : ", address) ; @@ -269,6 +271,8 @@ setTestInterval() ; break ; case 'b': case 'B': /* Bus Scan */ doBusScan() ; break ; + case 'z': case 'Z': /* Software Reset */ + doSWReset() ; break ; default: doHelp() ; break ; }