Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:c8a2256e02c2
- Child:
- 1:782127a132a3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Apr 03 20:04:39 2018 +0000
@@ -0,0 +1,55 @@
+// PAA5100JE-Q: Optical Tracking Chip reference code.
+// Version: 1.0
+// Latest Revision Date: 4 Apr. 2018
+// By PixArt Imaging Inc.
+// Primary Engineer: Vincent Yeh (PixArt USA)
+
+/*
+//=======================
+//Revision History
+//=======================
+Version 1.0 -- 4 Apr. 2018
+First release.
+*/
+
+#include "mbed.h"
+#include "SPIcommFunctions.h"
+
+int main()
+{
+ pc.baud(115200); // Set baud rate to 115200. Remember to sync serial terminal baud rate to the same value.
+
+ spi.format(8,3); // Set SPI to 8 bits with inverted polarity and phase-shifted to second edge.
+ spi.frequency(1000000); // Set frequency for SPI communication.
+ cs = 1; // Initialize chip select as inactive.
+
+ 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) != 0x49)
+ {
+ pc.printf("Communication protocol error! Terminating program.\n\r");
+ return 0;
+ }
+
+
+ startupCheck();
+ if(startupFail == 3)
+ {
+ pc.printf("Start-up failed! Power cycle the chip and try again.\n\r");
+ return 0;
+ }
+
+ initializeSensor();
+
+ 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();
+ }
+ }
+}
PAA5100 | Robotics Sensor With Cliff And Soft/Hard Surface Detection