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

Committer:
PixArtVY
Date:
20 months ago
Revision:
1:67d6484416a6
Parent:
0:a051df82fcdf

File content as of revision 1:67d6484416a6:

// ADBM-A350: Finger navigation chip.
// Version: 1.1
// Latest Revision Date: 18 July 2018
// By PixArt Imaging Inc.
// Primary Engineer: Vincent Yeh (PixArt USA)

// Copyright [2018] [Vincent Yeh]
// 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:
// http://www.apache.org/licenses/LICENSE-2.0


/*
//=======================
//Revision History
//=======================
Version 1.1 -- 18 July 2018
Added apache license notice.

Version 1.0 -- 14 June 2018
First release.
*/

#include "mbed.h"
#include "registerArrays.h"
//#include "I2CcommFunctions.h"
#include "SPIcommFunctions.h"
//Make sure you only have one of either SPIcommFunctions or I2CcommFunctions enabled. You cannot include both headers.

int main()
{
    pc.baud(115200);                    // Set baud rate to 115200. Remember to sync serial terminal baud rate to the same value.

    #ifdef SPImode
    IO_sel = 1;                         // Set IO_select pin to be HIGH for SPI.
    spi.format(8,3);                    // Set SPI to 8 bits with inverted polarity and phase-shifted to second edge.
    spi.frequency(100000);             // Set frequency for SPI communication.
    cs = 1;                             // Initialize chip select as inactive.
    #endif
    
    #ifdef I2Cmode
    IO_sel = 0;                         // Set IO_select pin to be LOW for I2C.
    i2c.frequency(400000);              // Set frequency for I2C communication.
    cs = 1;                             // These two pins are used to determine the device's slave ID.
    MOSI = 1;
    #endif
    
    shutdown = 0;
    writeRegister(0x3A, 0x5A);          //Soft-reset the chip.
    
    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) != 0x88)
    {
        pc.printf("Communication protocol error! Terminating program.\n\r");
        return 0;
    }
    
    load(initialize, initialize_size);  //Load register settings from the "initialize" array (see registerArrays.h)
    
    while(1)
    {
        //pc.printf("MOTION bit: %2X\n\r", readRegister(0x02));   //Prints EVENT register for debugging.
        
        if(readRegister(0x02) & 0x80)
        {
            grabData();
            printData();
        }
    }
}