CPS-Lab* / Mbed 2 deprecated lab6

Dependencies:   ADXL362 mbed MPL3115A2

Files at this revision

API Documentation at this revision

Comitter:
htdoughe
Date:
Thu Mar 01 14:58:46 2018 +0000
Parent:
22:1cd3cb77ec07
Child:
24:a3370a714978
Commit message:
compiles successfully; time to test

Changed in this revision

MPL3115A2.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/MPL3115A2.lib	Tue Feb 27 15:44:40 2018 +0000
+++ b/MPL3115A2.lib	Thu Mar 01 14:58:46 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/sophtware/code/MPL3115A2/#7c7c1ea6fc33
+http://os.mbed.com/teams/MSS/code/MPL3115A2/#b38d33be07ea
--- a/main.cpp	Tue Feb 27 15:44:40 2018 +0000
+++ b/main.cpp	Thu Mar 01 14:58:46 2018 +0000
@@ -184,9 +184,11 @@
 // Interface pulled from ADXL362.cpp
 // ADXL362::ADXL362(PinName CS, PinName MOSI, PinName MISO, PinName SCK) :
 ADXL362 adxl362(PA_0,PA_7,PA_6,PA_1);
-Serial pc(USBTX, USBRX);
-I2C i2c(PB_7, PB_6);
-MPL3115A2 MPL3115A2(&i2c, &pc);
+
+// Selects SDA as I2C1_SDA on pin PB_7
+// Selects SCL on I2C1_SCL on pin PB_6
+// The I2C address of the pressure sensor is fixed at 0x60. 
+MPL3115A2 pressure(PB_7, PB_6, 0x60);
 
 int adxl362_reg_print(int s, int l){
     //check s is between 0x00 and 0x2E
@@ -271,9 +273,9 @@
         return -1;
     } else {
         //else do stuff
-        uint8_t wai = MPL3115A2::whoAmI();
-        printf("whoami = 0x%01x", wai);
-        if(wai != 0xC4) {
+        uint8_t id = pressure.getID();
+        printf("whoami = 0x%01x", id);
+        if(id != 0xC4) {
             printf("error: WHO_AM_I is not 0xC4; exiting\n");
             return -1;
         } else {
@@ -292,8 +294,9 @@
             while(in < stop) {
                 //get register name
                 char * name = mregnames[in]; //GET NAME
-                char reg = mregids[in];
-                uint8_t val = MPL3115A2::i2cRead((char) reg); //GET REG VAL
+                int reg = mregids[in];
+                uint8_t val;
+                pressure.readRegs(reg,&val,sizeof(uint8_t)); //GET REG VAL
                 //print val
                 printf("0x%01x: %s=0x%01x\r\n", mregids[in], name, val);
                 in++;