Driver for the AKM AK9752 IR sensor device.

Dependents:   AKDP-RevD7_014

Library for the AK9752 Ultra-Small IR Sensor with I2C Interface. Includes integrated temperature sensor (0 - 50C) and 16-bit ADC.

Revision:
5:a979c36482fc
Parent:
4:2f4c8e641ce9
Child:
6:254b7e5820e7
--- a/AK9752.cpp	Wed Nov 02 00:14:52 2016 +0000
+++ b/AK9752.cpp	Wed Nov 02 17:34:13 2016 +0000
@@ -27,24 +27,27 @@
 }
 
 AK9752::Status AK9752::checkConnection() {
-    //AK9752::Status status = AK9752::SUCCESS;
     
     // Gets the WIA register value - ID and ID2
     char buf[2];
     if ((AK9752::read(AK9752_REG_ADDR_WIA1, buf, 2)) != AK9752::SUCCESS) {
-        MSG("Read of WIA1 failed.\r\n");
+        MSG("WIA1/WIA2 Read Operation Failed.\r\n");
         return AK9752::ERROR;
     }
 
-    // Checks the obtained value equals to the supposed value.
-    if ( (buf1 != AK9752_REG_VALUE_WIA1) ||  (buf2 != AK9752_REG_VALUE_WIA2) ) {
+    // Manufacturer is AKM _and_ device is AK9752 _or_ device is AK9752-Prototype
+    if ( (buf[0] == AK9752_REG_VALUE_WIA1) &&
+        ((buf[1] == AK9752_REG_VALUE_WIA2) || (buf[1] == AK9752_REG_VALUE_WIA2P)) ) {
+        
+        MSG("Manufacturer and Device ID Check Passed.\r\n");
+        return AK9752::SUCCESS;
+    }
+    else {
         MSG("ID check failed.\r\n");
         MSG("WIA1: %d\r\n", buf[0]);
         MSG("WIA2: %d\r\n", buf[1]);
-     //   return AK9752::ERROR;
+        return AK9752::ERROR;
     }
-    
-    return AK9752::SUCCESS;
 }
 
 AK9752::Status AK9752::read(char registerAddress, char *buf, int length) {