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
Revision 19:dfd1f76515c5, committed 2017-12-28
- Comitter:
- Rhyme
- Date:
- Thu Dec 28 07:32:28 2017 +0000
- Parent:
- 18:ee6f43cbfcc1
- Commit message:
- test of AK9752, AK9753, AK009970N added
Changed in this revision
--- a/AK009970N.lib Wed Dec 27 08:31:24 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -AK009970N#0d5779fc90fe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AK09970N.lib Thu Dec 28 07:32:28 2017 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/MSS/code/AK09970N/#2b2ead3e4efc
--- a/AK9752.lib Wed Dec 27 08:31:24 2017 +0000 +++ b/AK9752.lib Thu Dec 28 07:32:28 2017 +0000 @@ -1,1 +1,1 @@ -AK9752#d177a32f8f36 +https://os.mbed.com/teams/MSS/code/AK9752/#d177a32f8f36
--- a/AK9753.lib Wed Dec 27 08:31:24 2017 +0000 +++ b/AK9753.lib Thu Dec 28 07:32:28 2017 +0000 @@ -1,1 +1,1 @@ -AK9753#2eb87b5feaab +https://os.mbed.com/teams/MSS/code/AK9753/#2eb87b5feaab
--- a/MSU.cpp Wed Dec 27 08:31:24 2017 +0000 +++ b/MSU.cpp Thu Dec 28 07:32:28 2017 +0000 @@ -20,7 +20,7 @@ #include "VCNL4100.h" #include "AK9752.h" #include "AK9753.h" -#include "AK009970N.h" +#include "AK09970N.h" extern int test_loop ; extern int interval ; /* wait interval ms */ @@ -48,7 +48,7 @@ {MSU_VCNL4100_I2C_ADDRESS, "VCNL4100", testVCNL4100}, {MSU_AK9752_I2C_ADDRESS, "AK9752", testAK9752}, {MSU_AK9753_I2C_ADDRESS, "AK9753", testAK9753}, - {MSU_AK009970N_I2C_ADDRESS, "AK009970N", testAK009970N}, + {MSU_AK09970N_I2C_ADDRESS, "AK09970N", testAK09970N}, {0x00, 0, 0} } ; @@ -743,6 +743,35 @@ delete ak9753 ; } -void testAK009970N(void) +void testAK09970N(void) { + uint16_t companyID, deviceID ; + uint16_t status ; + float x, y, z ; + int result ; + + AK09970N *ak09970n = 0 ; + ak09970n = new AK09970N(PIN_SDA, PIN_SCL, MSU_AK09970N_I2C_ADDRESS) ; + ak09970n->software_reset() ; + ak09970n->getID(&companyID, &deviceID) ; + printf("=== AK09970N ===\n") ; + printf("Company ID = 0x%02X (expected 0x48)\n", companyID) ; + printf("Device ID = 0x%02X (expected 0xC0)\n", deviceID) ; + printf(" X Y Z\n") ; +// status = ak09970n->getStatus() ; +// printf("Status = 0x%04X\n", status) ; + + for (int i = 0 ; i < test_loop ; i++ ) { +// result = ak09970n->setConfig(0x08) ; /* 10Hz continuous mode */ + result = ak09970n->singleShot() ; + status = ak09970n->getStatus() ; + while((status & 0x01) != 0x01) { /* wait for data ready */ + wait_ms(10) ; + status = ak09970n->getStatus() ; + } + ak09970n->getX_Y_Z(&status, &x, &y, &z) ; + printf("%2.4f %2.4f %2.4f\n", x, y, z) ; + wait_ms(100) ; + } + delete ak09970n ; } \ No newline at end of file
--- a/MSU.h Wed Dec 27 08:31:24 2017 +0000 +++ b/MSU.h Thu Dec 28 07:32:28 2017 +0000 @@ -19,7 +19,7 @@ #define MSU_S11059_ADDRESS 0x2A #define MAX30101_I2C_ADDRESS 0x57 #define MSU_VCNL4100_I2C_ADDRESS 0x60 -#define MSU_AK009970N_I2C_ADDRESS 0x0C +#define MSU_AK09970N_I2C_ADDRESS 0x0C #define MSU_AK9752_I2C_ADDRESS 0x64 #define MSU_AK9753_I2C_ADDRESS 0x66 @@ -52,7 +52,7 @@ void testMAX30101(void) ; void testAK9752(void) ; void testAK9753(void) ; -void testAK009970N(void) ; +void testAK09970N(void) ; extern i2c_sensor_type i2c_sensor[] ; #endif \ No newline at end of file