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
IQS62x.h@4:60e891546590, 2017-02-08 (annotated)
- Committer:
- AzqDev
- Date:
- Wed Feb 08 01:24:14 2017 +0000
- Revision:
- 4:60e891546590
- Parent:
- 3:e26d7c502309
- Child:
- 5:653138b5cae9
Comment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AzqDev | 0:ce75ae1e8fc7 | 1 | // A class library for Azoteq IQS62x devices |
AzqDev | 3:e26d7c502309 | 2 | |
AzqDev | 3:e26d7c502309 | 3 | // More info on IQS624 sensor IC: http://bit.ly/IQS624_info |
AzqDev | 3:e26d7c502309 | 4 | |
AzqDev | 0:ce75ae1e8fc7 | 5 | #include "mbed.h" |
AzqDev | 0:ce75ae1e8fc7 | 6 | |
AzqDev | 0:ce75ae1e8fc7 | 7 | // Verify these 3 pin definitions if your hardware is not on the list of tested boards |
AzqDev | 0:ce75ae1e8fc7 | 8 | |
AzqDev | 1:2f08ab339e17 | 9 | #if defined (TARGET_LPC1768) || defined (TARGET_LPC11U24) |
AzqDev | 2:c16cb655d4a4 | 10 | #define IQS_I2C_CLOCK_PIN p27 /* on LPC1768/LPC11U24 this is marked as p10 */ |
AzqDev | 2:c16cb655d4a4 | 11 | #define IQS_I2C_DATA_PIN p28 /* on LPC1768/LPC11U24 this is marked as p9 */ |
AzqDev | 2:c16cb655d4a4 | 12 | #define IQS_READY_PIN p26 /* on LPC1768/LPC11U24 this is marked as p8 */ |
AzqDev | 2:c16cb655d4a4 | 13 | |
AzqDev | 1:2f08ab339e17 | 14 | #else |
AzqDev | 4:60e891546590 | 15 | // If your board has an Arduino interface the definitions below will likely work, also works for Teensy |
AzqDev | 0:ce75ae1e8fc7 | 16 | #define IQS_I2C_CLOCK_PIN I2C_SCL /* on NUCLEO boards this is marked as SCL/D15 on CN5 */ |
AzqDev | 0:ce75ae1e8fc7 | 17 | #define IQS_I2C_DATA_PIN I2C_SDA /* on NUCLEO boards this is marked as SDA/D14 on CN5 */ |
AzqDev | 0:ce75ae1e8fc7 | 18 | #define IQS_READY_PIN D2 /* on NUCLEO boards this is marked as D2 on CN9 */ |
AzqDev | 1:2f08ab339e17 | 19 | #endif |
AzqDev | 0:ce75ae1e8fc7 | 20 | |
AzqDev | 0:ce75ae1e8fc7 | 21 | #define I2C_ADR (0x44 << 1) /* I2C address of IQS62x */ |
AzqDev | 0:ce75ae1e8fc7 | 22 | #define I2CSPEED 100000 /* I2C clock speed */ |
AzqDev | 0:ce75ae1e8fc7 | 23 | #define NUMBER_OF_REGISTERS 224 /* number of registers to read from IQS62x */ |
AzqDev | 0:ce75ae1e8fc7 | 24 | #define I2CBufferSize 256 /* size of I2C read buffer */ |
AzqDev | 0:ce75ae1e8fc7 | 25 | |
AzqDev | 0:ce75ae1e8fc7 | 26 | class IQS62xIO { // basic IQS62x block read and write |
AzqDev | 0:ce75ae1e8fc7 | 27 | public: |
AzqDev | 0:ce75ae1e8fc7 | 28 | I2C i2c; // I2C interface |
AzqDev | 0:ce75ae1e8fc7 | 29 | DigitalIn IQSready; // ready pin |
AzqDev | 0:ce75ae1e8fc7 | 30 | const static int I2Cspeed = I2CSPEED; // I2C clock rate |
AzqDev | 0:ce75ae1e8fc7 | 31 | int I2CErrorCount; // number of I2C errors |
AzqDev | 0:ce75ae1e8fc7 | 32 | char I2CBuffer [I2CBufferSize]; // I2C read buffer |
AzqDev | 0:ce75ae1e8fc7 | 33 | char * registers; // pointer to I2C read buffer |
AzqDev | 0:ce75ae1e8fc7 | 34 | IQS62xIO(); // constructor |
AzqDev | 0:ce75ae1e8fc7 | 35 | |
AzqDev | 0:ce75ae1e8fc7 | 36 | void configure(); // write configuration registers of the IQS62x |
AzqDev | 0:ce75ae1e8fc7 | 37 | void readAll(); // read all registers from the IQS62x |
AzqDev | 0:ce75ae1e8fc7 | 38 | void waitForReady(); // wait for IQS62x ready signal |
AzqDev | 0:ce75ae1e8fc7 | 39 | }; |