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
Handy Table of ProxFusion Device Features
ALS = Ambient Light Sensor PIR = Passive Infrared
Revision 20:7eb08a52b954, committed 2018-03-21
- Comitter:
- mventer
- Date:
- Wed Mar 21 05:56:22 2018 +0000
- Parent:
- 19:f0675a3150c7
- Commit message:
- For use with IQS621_DualPIR_ALS_Temp. Added output line to toggle and corrected spelling in some comments.
Changed in this revision
IQS62x.cpp | Show annotated file Show diff for this revision Revisions of this file |
IQS62x.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r f0675a3150c7 -r 7eb08a52b954 IQS62x.cpp --- a/IQS62x.cpp Thu May 18 15:23:40 2017 +0000 +++ b/IQS62x.cpp Wed Mar 21 05:56:22 2018 +0000 @@ -7,6 +7,7 @@ // ProxFusion 5-minute YouTube video: http://bit.ly/proxfusion-video #include "IQS62x.h" +DigitalOut toggle(PB_3); // constructor IQS62xIO::IQS62xIO() : @@ -19,9 +20,9 @@ i2c.frequency( I2Cspeed ); // I2C clock frequency // this uses memory but is very handy in diagnostics - memset(writeFlag, 0, I2CBufferSize); // a table to remmber if we wrote to a register + memset(writeFlag, 0, I2CBufferSize); // a table to remember if we wrote to a register memset(lastWrite, 0, I2CBufferSize); // a table to remember what we wrote to a register - memset(lastRead, 0, I2CBufferSize); // a table to remmber what we read the previous read cycle + memset(lastRead, 0, I2CBufferSize); // a table to remember what we read the previous read cycle memset(readChanges, 0, I2CBufferSize); // a table to mark up any registers that changed since the previous read memset(readChangesEver, 0, I2CBufferSize); // a table to mark up any registers that changed BUT never forget memset(writeChanges, 0, I2CBufferSize); // a table to mark up any registers that differ from what was written to it @@ -30,6 +31,7 @@ // write a single byte to an IQS62x register void IQS62xIO::writeRegister(int address, int data) { + toggle = !toggle; writeFlag[ address & 0xff ] = 1; // remember which registers we changed lastWrite[ address & 0xff ] = data & 0xff; // remember what we wrote char twoBytes [2]; @@ -69,13 +71,13 @@ if(0!=i2c.read(I2C_ADR,I2CBuffer,numberOfBytes,false)) I2CErrorCount++; -#define PLEASE_CHECK_FOR_IQS_CHANGES 1 +#define DONT_CHECK_FOR_IQS_CHANGES 1 #ifndef DONT_CHECK_FOR_IQS_CHANGES // this is optional but handy diagnostics // we build six tables: - //writeFlag - a table to remmber if we wrote to a register + //writeFlag - a table to remember if we wrote to a register //lastWrite - a table to remember what we wrote to a register - //lastRead - a table to remmber what we read the previous read cycle + //lastRead - a table to remember what we read the previous read cycle //readChanges - a table to mark up any registers that changed since the previous read //readChangesEver - a table to mark up any registers that changed BUT never forget //writeChanges - a table to mark up any registers that differ from what was written to it
diff -r f0675a3150c7 -r 7eb08a52b954 IQS62x.h --- a/IQS62x.h Thu May 18 15:23:40 2017 +0000 +++ b/IQS62x.h Wed Mar 21 05:56:22 2018 +0000 @@ -16,8 +16,11 @@ #else // If your board has an Arduino interface the definitions below will likely work, also works for Teensy #define IQS_I2C_CLOCK_PIN I2C_SCL /* on NUCLEO boards this is marked as SCL/D15 on CN5 */ +//#define IQS_I2C_CLOCK_PIN PA_9 /* on NUCLEO boards this is marked as SCL/D15 on CN5 */ #define IQS_I2C_DATA_PIN I2C_SDA /* on NUCLEO boards this is marked as SDA/D14 on CN5 */ +//#define IQS_I2C_DATA_PIN PA_10 /* on NUCLEO boards this is marked as SDA/D14 on CN5 */ #define IQS_READY_PIN D2 /* on NUCLEO boards this is marked as D2 on CN9 */ +//#define IQS_READY_PIN PA_12 /* on NUCLEO boards this is marked as D2 on CN9 */ #endif #define I2C_ADR (0x44 << 1) /* I2C address of IQS62x */