Library to read and write Azoteq IQS6xx device registers via I2C.

Dependents:   IQS620_HelloWorld IQS622_HelloWorld IQS624_HelloWorld IQS621_HelloWorld ... more

Library: IQS62x

Library to read and write Azoteq IQS6xx device registers via I2C.

Supported Devices

Components / IQS620A
Ultra low power sensor for magnetic field, capacitive touch and inductive proximity. Empowers next-generation user interfaces.

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

Components / IQS622
Azoteq IQS622 ultra low power sensor for ambient light, active (reflective) IR, magnetic field, capacitance and inductive proximity. Empowers next-generation user interfaces.

Components / IQS624
Ultra low power sensor for rotating magnetic field, capacitive touch, and inductive proximity. Empowers next-generation user interfaces.

Handy Table of ProxFusion Device Features


ALS = Ambient Light Sensor PIR = Passive Infrared

/media/uploads/AzqDev/mbed-azoteq-proxfusion-handy-table-of-product-features.jpg

Revision:
7:5e7ea07265d9
Parent:
6:89bdb6f6a5c1
Child:
8:f9c71b39c602
--- a/IQS62x.cpp	Wed Feb 08 02:13:58 2017 +0000
+++ b/IQS62x.cpp	Fri May 12 01:36:05 2017 +0000
@@ -2,7 +2,7 @@
 
 // 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.
 
-// More info on IQS624 sensor IC: http://bit.ly/IQS624_info
+// More info on IQS624 sensor IC: http://www.azoteq.com/products/proxfusion/iqs624?mbed
 
 // IQS624 1-minute youtube video: http://bit.ly/IQS624Video
 
@@ -18,16 +18,23 @@
     i2c.frequency( I2Cspeed ); // I2C clock frequency
 }    
 
-// write some configuration data to the IQS62x
-void IQS62xIO::configure() {
-    const static char system_register_setup_data [] = { 0xd0, 0x40 }; 
-    int numberOfBytes = sizeof( system_register_setup_data );
+// write a single byte to an IQS62x register
+void IQS62xIO::writeRegister(int address, int data) {
+    char twoBytes [2];
+    int numberOfBytes = 2;
+    twoBytes[0] = address & 0xff;
+    twoBytes[1] = data & 0xff;
     waitForReady();
-    // clear the reset bit in register 0xd0
-    if(0!=i2c.write(I2C_ADR,system_register_setup_data,numberOfBytes,false)) 
+    if(0!=i2c.write(I2C_ADR,twoBytes,numberOfBytes,false)) 
         I2CErrorCount++;
 }
 
+// configure the IQS62x
+// declared __weak so we can override it with more complex configuration routines.
+__weak void IQS62xIO::configure() {
+    writeRegister(0xd0,0x40); // simplest config : just acknowledge/clear the reset flag
+}
+
 // read all registers from the IQS62x
 void IQS62xIO::readAll() {
     waitForReady();