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.
main.cpp
00001 // PAA5100JE-Q: Optical Tracking Chip reference code. 00002 // Version: 1.1 00003 // Latest Revision Date: 18 July 2018 00004 // By PixArt Imaging Inc. 00005 // Primary Engineer: Vincent Yeh (PixArt USA) 00006 00007 // Copyright [2018] [Vincent Yeh] 00008 // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: 00009 // http://www.apache.org/licenses/LICENSE-2.0 00010 00011 00012 /* 00013 //======================= 00014 //Revision History 00015 //======================= 00016 Version 1.1 -- 18 July 2018 00017 Added apache license notice. 00018 00019 Version 1.0 -- 4 Apr. 2018 00020 First release. 00021 */ 00022 00023 #include "mbed.h" 00024 #include "SPIcommFunctions.h" 00025 00026 int main() 00027 { 00028 pc.baud(115200); // Set baud rate to 115200. Remember to sync serial terminal baud rate to the same value. 00029 00030 spi.format(8,3); // Set SPI to 8 bits with inverted polarity and phase-shifted to second edge. 00031 spi.frequency(1000000); // Set frequency for SPI communication. 00032 cs = 1; // Initialize chip select as inactive. 00033 00034 pc.printf("Program START\n\r"); 00035 00036 pc.printf("ID Check: %2X\n\r", readRegister(0x00)); //Checks product ID to make sure communication protocol is working properly. 00037 if(readRegister(0x00) != 0x49) 00038 { 00039 pc.printf("Communication protocol error! Terminating program.\n\r"); 00040 return 0; 00041 } 00042 00043 00044 startupCheck(); 00045 if(startupFail == 3) 00046 { 00047 pc.printf("Start-up failed! Power cycle the chip and try again.\n\r"); 00048 return 0; 00049 } 00050 00051 initializeSensor(); 00052 00053 while(1) 00054 { 00055 //pc.printf("MOTION bit: %2X\n\r", (readRegister(0x02) & 0x80) >> 7); //Prints motion bit for debugging. 1 = motion detected. 0 = no motion detected. 00056 00057 if(readRegister(0x02) & 0x80) 00058 { 00059 grabData(); 00060 printData(); 00061 } 00062 } 00063 }
Generated on Fri Jul 15 2022 11:20:26 by
1.7.2
PAA5100 | Robotics Sensor With Cliff And Soft/Hard Surface Detection