Ovidiu Cincheza / Mbed 2 deprecated NucleoMGC3130

Dependencies:   MGC3130 mbed

Files at this revision

API Documentation at this revision

Comitter:
ovicin
Date:
Tue Oct 13 10:53:07 2015 +0000
Parent:
0:41f53df528da
Commit message:
first commit, not working

Changed in this revision

MGC3130.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 41f53df528da -r a6f1d535bbdb MGC3130.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MGC3130.lib	Tue Oct 13 10:53:07 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/yangcq88517/code/MGC3130/#4666b36a738d
diff -r 41f53df528da -r a6f1d535bbdb main.cpp
--- a/main.cpp	Fri Feb 21 13:02:09 2014 +0000
+++ b/main.cpp	Tue Oct 13 10:53:07 2015 +0000
@@ -1,68 +1,48 @@
 #include "mbed.h"
- 
-#define LM75_REG_TEMP (0x00) // Temperature Register
-#define LM75_REG_CONF (0x01) // Configuration Register
-#define LM75_ADDR     (0x90) // LM75 address
- 
-I2C i2c(I2C_SDA, I2C_SCL);
- 
+#include "MGC3130.h"
+
 DigitalOut myled(LED1);
  
 Serial pc(SERIAL_TX, SERIAL_RX);
  
-volatile char TempCelsiusDisplay[] = "+abc.d C";
+    /** 
+    * IS2 is available for address selection and enables the user to connect up to two MGC3X30 devices on the same bus without address conflict.
+    * The MGC3X30 I2C addresses are 0x42 and 0x43. They are given as device addresses without the R/W bit.
+    * In addition, MGC3X30 requires a dedicated transfer status line (TS), which features a
+    * data transfer status function. The TS is used by both I2C Master and Slave to control
+    * the data flow. I2C SCL, I2C SDA and TS lines require an open-drain connection on
+    * MGC3X30 and the connected host controller. To function properly, I2C SCL and I2C
+    * SDA need to be pulled up to VCC with 1.8 kΩ resistors and the TS line needs to be
+    * pulled up to VCC with a 10 kΩ resistor.
+    *
+    * @param sda I2C sda signal
+    * @param scl I2C scl signal
+    * @param EI0 transfer status line
+    * @param IS2 High->true, Low->false
+    *
+    */
+     
+MGC3130 gestic(I2C_SDA, I2C_SCL, PB_1, false ); 
+
+SensorData *data;
+
  
 int main()
 {
  
-    char data_write[2];
-    char data_read[2];
- 
-    /* Configure the Temperature sensor device STLM75:
-    - Thermostat mode Interrupt
-    - Fault tolerance: 0
-    */
-    data_write[0] = LM75_REG_CONF;
-    data_write[1] = 0x02;
-    int status = i2c.write(LM75_ADDR, data_write, 2, 0);
-    if (status != 0) { // Error
-        while (1) {
-            myled = !myled;
-            wait(0.2);
-        }
-    }
+    pc.printf("Hello World !\r\n");
  
     while (1) {
-        // Read temperature register
-        data_write[0] = LM75_REG_TEMP;
-        i2c.write(LM75_ADDR, data_write, 1, 1); // no stop
-        i2c.read(LM75_ADDR, data_read, 2, 0);
- 
-        // Calculate temperature value in Celcius
-        int tempval = (int)((int)data_read[0] << 8) | data_read[1];
-        tempval >>= 7;
-        if (tempval <= 256) {
-            TempCelsiusDisplay[0] = '+';
-        } else {
-            TempCelsiusDisplay[0] = '-';
-            tempval = 512 - tempval;
-        }
- 
-        // Decimal part (0.5°C precision)
-        if (tempval & 0x01) {
-            TempCelsiusDisplay[5] = 0x05 + 0x30;
-        } else {
-            TempCelsiusDisplay[5] = 0x00 + 0x30;
-        }
- 
-        // Integer part
-        tempval >>= 1;
-        TempCelsiusDisplay[1] = (tempval / 100) + 0x30;
-        TempCelsiusDisplay[2] = ((tempval % 100) / 10) + 0x30;
-        TempCelsiusDisplay[3] = ((tempval % 100) % 10) + 0x30;
+        data = gestic.readSensorData();
+        if (data == NULL){
+            pc.printf("Data not avail\r\n");
+            }
+            else{
+                if (NULL != data->getxyzPosition())
+                    pc.printf("Got position data \r\n");
+                }
  
         // Display result
-        pc.printf("temp = %s\n", TempCelsiusDisplay);
         myled = !myled;
         wait(1.0);
     }
diff -r 41f53df528da -r a6f1d535bbdb mbed.bld
--- a/mbed.bld	Fri Feb 21 13:02:09 2014 +0000
+++ b/mbed.bld	Tue Oct 13 10:53:07 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/ed8466a608b4
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file