Reference firmware for PixArt's PMT9123 sensor and evaluation board. "Hello World" and "Library" contain the exact same files. Please import just one of the two into your mBed compiler as a new program and not as a library.

Revision:
0:71ff24e8c21e
Child:
1:1d99f5c9581f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Apr 10 20:17:47 2018 +0000
@@ -0,0 +1,46 @@
+// PMT9123QS: Low Power Right-Angle Optical Track Sensor
+// Version: 1.0
+// Latest Revision Date: 9 Apr. 2018
+// By PixArt Imaging Inc.
+// Primary Engineer: Vincent Yeh (PixArt USA)
+
+/*
+//=======================
+//Revision History
+//=======================
+Version 1.0 -- 9 Apr. 2018
+First release.
+*/
+
+#include "mbed.h"
+#include "registerArrays.h"
+#include "I2CcommFunctions.h"
+
+int main()
+{
+    pc.baud(115200);                    // Set baud rate to 115200. Remember to sync serial terminal baud rate to the same value.
+    i2c.frequency(400000);              // Set frequency for I2C communication.
+    startup();
+        
+    pc.printf("Program START\n\r");
+    pc.printf("ID Check: %2X\n\r", readRegister(0x00)); //Checks product ID to make sure communication protocol is working properly.
+    if(readRegister(0x00) != 0x41)
+    {
+        pc.printf("Communication protocol error! Terminating program.\n\r");
+        return 0;
+    }
+    
+    initialize();
+    load(optimize, optimize_size);  //Load register settings from the "initialize" array
+    
+    while(1)
+    {
+        //pc.printf("MOTION bit: %2X\n\r", (readRegister(0x02) & 0x80) >> 7);   //Prints motion bit for debugging. 1 = motion detected. 0 = no motion detected.
+        
+        if(readRegister(0x02) & 0x80)
+        {
+            grabData();
+            printData();
+        }
+    }
+}
\ No newline at end of file