Interface to access to Avago ADNS-9500 laser mouse sensors.

Dependencies:   mbed

Revision:
15:096f5e07d159
Parent:
14:dc9badf3c6e9
Child:
16:0f8e730f3272
--- a/adns9500.cpp	Wed Oct 17 12:27:40 2012 +0000
+++ b/adns9500.cpp	Fri Apr 19 14:39:45 2013 +0000
@@ -129,7 +129,7 @@
 
         enabled_ = true;
 
-        if (firmware) {
+        if (firmware != NULL) {
             sromDownload(firmware);
             enableLaser();
         }
@@ -208,7 +208,7 @@
 
         // we expect a line per byte in hex without 0x prefix
         FILE *fp = fopen(filename, "r");
-        if (! fp)
+        if (fp == NULL)
             error("ADNS9500::sromDownload : file %s could not be opened\n", filename);
 
         unsigned int byte;
@@ -223,6 +223,8 @@
         if (ferror(fp))
             error("ADNS9500::sromDownload : error reading from file: %s\n", filename);
 
+        fclose(fp);
+
         // test if SROM was downloaded successfully
         wait_us(160);
         ncs_.write(0);
@@ -233,7 +235,7 @@
         WAIT_TSCLKNCS();
         ncs_.write(1);
         
-        if (! srom_id)
+        if (srom_id == 0x00)
             error("ADNS9500::sromDownload : the firmware was not successful downloaded\n");
 
         // test laser fault condition