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

Revision:
0:a051df82fcdf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commHeaders/I2CcommFunctions.h	Mon Jun 25 21:14:10 2018 +0000
@@ -0,0 +1,102 @@
+#define I2Cmode                                     //Used to check if the sensor is in I2C mode or SPI mode.
+#define I2C_Slave_ID 0x57                           //Slave ID is 0x57 only if p22 and p23 are both HIGH.
+
+//=========================================================================
+//Communication pinouts for serial COM port, I2C, and interrupts
+//=========================================================================
+static Serial pc(USBTX, USBRX);                     //PC comm
+static I2C i2c(p26, p27);                           //SDA, SCL
+static DigitalOut cs(p22);                          //CS pin for selecting slave address
+static DigitalOut MOSI(p23);                        //MOSI pin for selecting slave address
+static DigitalOut shutdown(p20);                    //Shutdown pin
+static DigitalOut IO_sel(p19);                      //IO interface selection pin (I2C and SPI)
+
+
+//=========================================================================
+//Variables and arrays used for communications and data storage
+//=========================================================================
+int8_t deltaX, deltaY;                              //Stores the value of one individual motion report.
+int totalX, totalY = 0;                          //Stores the total deltaX and deltaY moved during runtime.
+
+
+//=========================================================================
+//Functions used to communicate with the sensor and grab/print data
+//=========================================================================
+uint8_t readRegister(uint8_t addr);
+//This function takes an 8-bit address in the form 0x00 and returns an 8-bit value in the form 0x00.
+
+void writeRegister(uint8_t addr, uint8_t data);
+//This function takes an 8-bit address and 8-bit data. Writes the given data to the given address.
+
+void load(const uint8_t array[][2], uint8_t arraySize);
+//Takes an array of registers/data (found in registerArrays.h) and their size and writes in all the values.
+
+void grabData(void);
+//Grabs the deltaX and deltaY information from the proper registers and formats it into the proper format.
+
+void printData(void);
+//Prints the data out to a serial terminal.
+
+
+
+
+
+//=========================================================================
+//Functions definitions
+//=========================================================================
+uint8_t readRegister(uint8_t addr)
+{
+    uint8_t data;
+    i2c.write((I2C_Slave_ID << 1), (const char*)&addr, 1, 0);   //Send the address to the chip
+    i2c.read((I2C_Slave_ID << 1), (char*)&data, 1, 0);          //Send the memory address where you want to store the read data
+    return(data);
+}
+
+
+//=========================================================================
+void writeRegister(uint8_t addr, uint8_t data)
+{
+    char data_write[2];             //Create an array to store the address/data to pass them at the same time.
+    data_write[0] = addr;           //Store the address in the first byte
+    data_write[1] = data;           //Store the data in the second byte
+    i2c.write((I2C_Slave_ID << 1), data_write, 2, 0);   //Send both over at once
+    
+    pc.printf("R:%2X, D:%2X\n\r", addr, readRegister(addr));
+            //Uncomment this line for debugging. Prints every register write operation.
+}
+
+
+//=========================================================================
+void load(const uint8_t array[][2], uint8_t arraySize)
+{
+    for(uint8_t q = 0; q < arraySize; q++)
+    {
+        writeRegister(array[q][0], array[q][1]);    //Writes the given array of registers/data.
+    }
+}
+
+
+//=========================================================================
+void grabData(void)
+{
+    deltaX = readRegister(0x03);        //Grabs data from the proper registers.
+    deltaY = readRegister(0x04);
+    writeRegister(0x02, 0x00);          //Clear EVENT and motion registers.
+}
+
+
+//=========================================================================
+void printData(void)
+{
+    if((deltaX != 0) || (deltaY != 0))      //If there is deltaX or deltaY movement, print the data.
+    {
+        totalX += deltaX;
+        totalY += deltaY;
+        
+        pc.printf("deltaX: %d\t\t\tdeltaY: %d\n\r", deltaX, deltaY);    //Prints each individual count of deltaX and deltaY.
+        pc.printf("X-axis Counts: %d\t\tY-axis Counts: %d\n\r", totalX, totalY);  //Prints the total movement made during runtime.
+    }
+    
+    deltaX = 0;                             //Resets deltaX and Y values to zero, otherwise previous data is stored until overwritten.
+    deltaY = 0;
+}