Reference firmware for PixArt's ADBM-A350 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.
Welcome to the code repository for PixArt's ADBM-A350 sensor and evaluation board.
For general information about this product, please visit this product's components page here:
https://os.mbed.com/components/ADBM-A350-Finger-Navigation-Optical-Sens/
For guides and tips on how to setup and evaluate the ADBM-A350 sensor with the Nordic nRF52-DK microcontroller using this reference code, please visit this guide:
https://os.mbed.com/teams/PixArt/code/ADBM-A350_referenceCode/wiki/Guide-for-nRF52-DK-Platform
For guides and tips on how to setup and evaluate the ADBM-A350 sensor with any mBed-supported microcontroller using this reference code, please visit this guide:
https://os.mbed.com/teams/PixArt/code/ADBM-A350_referenceCode/wiki/Guide-for-Any-Platform
main.cpp@1:67d6484416a6, 2018-10-30 (annotated)
- Committer:
- PixArtVY
- Date:
- Tue Oct 30 21:14:15 2018 +0000
- Revision:
- 1:67d6484416a6
- Parent:
- 0:a051df82fcdf
First public release.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
PixArtVY | 0:a051df82fcdf | 1 | // ADBM-A350: Finger navigation chip. |
PixArtVY | 1:67d6484416a6 | 2 | // Version: 1.1 |
PixArtVY | 1:67d6484416a6 | 3 | // Latest Revision Date: 18 July 2018 |
PixArtVY | 0:a051df82fcdf | 4 | // By PixArt Imaging Inc. |
PixArtVY | 0:a051df82fcdf | 5 | // Primary Engineer: Vincent Yeh (PixArt USA) |
PixArtVY | 0:a051df82fcdf | 6 | |
PixArtVY | 1:67d6484416a6 | 7 | // Copyright [2018] [Vincent Yeh] |
PixArtVY | 1:67d6484416a6 | 8 | // 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: |
PixArtVY | 1:67d6484416a6 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
PixArtVY | 1:67d6484416a6 | 10 | |
PixArtVY | 1:67d6484416a6 | 11 | |
PixArtVY | 0:a051df82fcdf | 12 | /* |
PixArtVY | 0:a051df82fcdf | 13 | //======================= |
PixArtVY | 0:a051df82fcdf | 14 | //Revision History |
PixArtVY | 0:a051df82fcdf | 15 | //======================= |
PixArtVY | 1:67d6484416a6 | 16 | Version 1.1 -- 18 July 2018 |
PixArtVY | 1:67d6484416a6 | 17 | Added apache license notice. |
PixArtVY | 1:67d6484416a6 | 18 | |
PixArtVY | 0:a051df82fcdf | 19 | Version 1.0 -- 14 June 2018 |
PixArtVY | 0:a051df82fcdf | 20 | First release. |
PixArtVY | 0:a051df82fcdf | 21 | */ |
PixArtVY | 0:a051df82fcdf | 22 | |
PixArtVY | 0:a051df82fcdf | 23 | #include "mbed.h" |
PixArtVY | 0:a051df82fcdf | 24 | #include "registerArrays.h" |
PixArtVY | 0:a051df82fcdf | 25 | //#include "I2CcommFunctions.h" |
PixArtVY | 0:a051df82fcdf | 26 | #include "SPIcommFunctions.h" |
PixArtVY | 0:a051df82fcdf | 27 | //Make sure you only have one of either SPIcommFunctions or I2CcommFunctions enabled. You cannot include both headers. |
PixArtVY | 0:a051df82fcdf | 28 | |
PixArtVY | 0:a051df82fcdf | 29 | int main() |
PixArtVY | 0:a051df82fcdf | 30 | { |
PixArtVY | 0:a051df82fcdf | 31 | pc.baud(115200); // Set baud rate to 115200. Remember to sync serial terminal baud rate to the same value. |
PixArtVY | 0:a051df82fcdf | 32 | |
PixArtVY | 0:a051df82fcdf | 33 | #ifdef SPImode |
PixArtVY | 0:a051df82fcdf | 34 | IO_sel = 1; // Set IO_select pin to be HIGH for SPI. |
PixArtVY | 0:a051df82fcdf | 35 | spi.format(8,3); // Set SPI to 8 bits with inverted polarity and phase-shifted to second edge. |
PixArtVY | 0:a051df82fcdf | 36 | spi.frequency(100000); // Set frequency for SPI communication. |
PixArtVY | 0:a051df82fcdf | 37 | cs = 1; // Initialize chip select as inactive. |
PixArtVY | 0:a051df82fcdf | 38 | #endif |
PixArtVY | 0:a051df82fcdf | 39 | |
PixArtVY | 0:a051df82fcdf | 40 | #ifdef I2Cmode |
PixArtVY | 0:a051df82fcdf | 41 | IO_sel = 0; // Set IO_select pin to be LOW for I2C. |
PixArtVY | 0:a051df82fcdf | 42 | i2c.frequency(400000); // Set frequency for I2C communication. |
PixArtVY | 0:a051df82fcdf | 43 | cs = 1; // These two pins are used to determine the device's slave ID. |
PixArtVY | 0:a051df82fcdf | 44 | MOSI = 1; |
PixArtVY | 0:a051df82fcdf | 45 | #endif |
PixArtVY | 0:a051df82fcdf | 46 | |
PixArtVY | 0:a051df82fcdf | 47 | shutdown = 0; |
PixArtVY | 0:a051df82fcdf | 48 | writeRegister(0x3A, 0x5A); //Soft-reset the chip. |
PixArtVY | 0:a051df82fcdf | 49 | |
PixArtVY | 0:a051df82fcdf | 50 | pc.printf("Program START\n\r"); |
PixArtVY | 0:a051df82fcdf | 51 | |
PixArtVY | 0:a051df82fcdf | 52 | pc.printf("ID Check: %2X\n\r", readRegister(0x00)); //Checks product ID to make sure communication protocol is working properly. |
PixArtVY | 0:a051df82fcdf | 53 | if(readRegister(0x00) != 0x88) |
PixArtVY | 0:a051df82fcdf | 54 | { |
PixArtVY | 0:a051df82fcdf | 55 | pc.printf("Communication protocol error! Terminating program.\n\r"); |
PixArtVY | 0:a051df82fcdf | 56 | return 0; |
PixArtVY | 0:a051df82fcdf | 57 | } |
PixArtVY | 0:a051df82fcdf | 58 | |
PixArtVY | 0:a051df82fcdf | 59 | load(initialize, initialize_size); //Load register settings from the "initialize" array (see registerArrays.h) |
PixArtVY | 0:a051df82fcdf | 60 | |
PixArtVY | 0:a051df82fcdf | 61 | while(1) |
PixArtVY | 0:a051df82fcdf | 62 | { |
PixArtVY | 0:a051df82fcdf | 63 | //pc.printf("MOTION bit: %2X\n\r", readRegister(0x02)); //Prints EVENT register for debugging. |
PixArtVY | 0:a051df82fcdf | 64 | |
PixArtVY | 0:a051df82fcdf | 65 | if(readRegister(0x02) & 0x80) |
PixArtVY | 0:a051df82fcdf | 66 | { |
PixArtVY | 0:a051df82fcdf | 67 | grabData(); |
PixArtVY | 0:a051df82fcdf | 68 | printData(); |
PixArtVY | 0:a051df82fcdf | 69 | } |
PixArtVY | 0:a051df82fcdf | 70 | } |
PixArtVY | 0:a051df82fcdf | 71 | } |