Ultra Low Power (5uA) I2C Sensor With Ambient Light Sensing (ALS) + Capacitive Proximity/Touch + Hall Effect Sensor + Inductive Proximity (Metal Detect)

Dependencies:   IQS621DisplayTerminal IQS62x mbed

Hello World! From Azoteq's IQS621 Ultra Low Power Multi-Sensor

This is a demo program for the Azoteq IQS621 ultra low power multi function sensor.

Components / IQS621
Azoteq IQS621 ultra low power sensor for ambient light, magnetic field, capacitance and inductive proximity. Empowers next-generation user interfaces.


Low Cost Evaluation Board For Azoteq IQS621ultra low power I2C sensor for ambient light, magnetic field, capacitance, inductive proximity and temperature.

main.cpp

Committer:
AzqDev
Date:
2017-05-13
Revision:
10:3d189e1c9eeb
Parent:
9:37cf595b0f7d
Child:
11:6258c43f559f

File content as of revision 10:3d189e1c9eeb:

// IQS621-HelloWorld.cpp

// Hello World program for Azoteq IQS621 ultra low power sensor for ambient light, magnetic field, capacitive touch and inductive proximity.

// More info on IQS621 sensor IC: http://bit.ly/IQS621-Info

// Video: http://bit.ly/IQS621-Youtube-Video

// Copyright 2017 Azoteq. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// Output is via the USB debug serial port to a terminal program

// Tested on the following MBED hardware - mostly using Azoteq-to-Arduino Adapter Boards
// Note: When compiling for new hardware, use "Compile All" to rebuild everything

//  1. ST Micro Nucleo-L152RE   Azoteq Adapter Boards: AZP694A02, AZP690A02
//  2. ST Micro Nucleo-F401RE   Azoteq Adapter Boards: AZP694A02, AZP690A02
//  3. ST Micro Nucleo-L476RG   Azoteq Adapter Boards: AZP694A02, AZP690A02
//  4. ST Micro Nucleo-L053R8   Azoteq Adapter Boards: AZP694A02, AZP690A02
//  5. ST Micro Nucleo-F446RE   Azoteq Adapter Boards: AZP694A02, AZP690A02
//  6. ST Micro Disco-F746NG    Azoteq Adapter Boards: AZP694A02, AZP690A02
//  7. Freescale FRDM-KL46Z     Azoteq Adapter Boards: AZP694A02, AZP690A02
//  8. Freescale FRDM-KL25Z     Azoteq Adapter Boards: AZP694A02, AZP690A02
//  9. mbed LPC1768             Azoteq adapter AZP690A02 [SDA,SCL,RDY] wired to LPC1768 [p28,p27,p26]
// 10. mbed LPC11U24            Azoteq adapter AZP690A02 [SDA,SCL,RDY] wired to LPC11U24 [p28,p27,p26]

// These two boards additionally require the USBDevice library: https://developer.mbed.org/users/mbed_official/code/USBDevice/
// 11. Teensy 3.1               Azoteq adapter AZP690A02 [SDA,SCL,RDY] wired to Teensy 3.1 [p18,p19,p2] 
// 12. Teensy 3.2               Azoteq adapter AZP690A02 [SDA,SCL,RDY] wired to Teensy 3.2 [p18,p19,p2] 

// Direct wiring of ST Micro Nucleo boards to AZP690A02 (IQS621-EVAL-1 board)
// CN10-3 = SCL, CN10-5 = SDA, CN10-33 = RDY, CN11 = GND, CN7-16 = 3.3V

#include "mbed.h"
#include "IQS62x.h"
#include "IQS621DisplayTerminal.h"

IQS621Display terminal;   // class to display IQS62x registers on a terminal
IQS62xIO iqs62x;          // class for basic IQS62x block read and write

int main() {
    terminal.helloMessage(false); // say hello but don't wait for a keypress
    wait(3);
    iqs62x.configure(); // configure the IC
    while(1) {
        iqs62x.readIqsRegisters(0,NUMBER_OF_REGISTERS); // read all the registers
        terminal.showStatus(iqs62x.I2Cspeed,iqs62x.I2CErrorCount); // show heading and number of I2C errors
    
        char * highlightTable; // a highlight table contains 1 byte for every register
        // if a byte in a highlight table is nonzero, the corresponding register value will be highlighted during display
        highlightTable = 0;                    // use a NULL table to make all registers print plain with no highlighting
        highlightTable = iqs62x.readChanges;   // special table to highlight all registers that changed since the previous read
        highlightTable = iqs62x.readChangesEver; // table that highlights all registers that ever changed since the previous read
        highlightTable = iqs62x.writeFlag;     // special table to highlight all registers that were initialized - can be used to verify configure()
        highlightTable = iqs62x.writeChanges;  // special table to highlight all registers that were written/configured but now contain a different value
        
        terminal.showRegisters(iqs62x.registers, highlightTable); // display the registers and highlight the ones marked in the table

    }    
}

// end of IQS621_HelloWorld.cpp