Library which provides functions to control a TAOS TSL2561 Light-To-Digital Converter via I2C.

Dependents:   TweetTest NetworkThermometer GR-PEACH_TAMORI mDot_LoRa_Connect_ABPA_Lux ... more

Committer:
karlmaxwell67
Date:
Wed Apr 16 10:57:57 2014 +0000
Revision:
5:93782eb646de
Parent:
TCS3472_I2C.h@4:5d1f8d7d81ff
Child:
6:17fef2caa563
_

Who changed what in which revision?

UserRevisionLine numberNew contents of line
karlmaxwell67 5:93782eb646de 1 #ifndef TSL2561_I2C_H
karlmaxwell67 5:93782eb646de 2 #define TSL2561_I2C_H
karlmaxwell67 0:453a43c8bf2b 3 #include "mbed.h"
karlmaxwell67 0:453a43c8bf2b 4
karlmaxwell67 1:70d7d9f1af01 5 //Defines
karlmaxwell67 5:93782eb646de 6 #define TSL_SLAVE_ADDRESS 0x39
karlmaxwell67 2:38d5187a4e7b 7
karlmaxwell67 5:93782eb646de 8 #define TSL_CONTROL 0x00
karlmaxwell67 5:93782eb646de 9 #define TSL_TIMING 0x01
karlmaxwell67 5:93782eb646de 10 #define TSL_THRESHLOWLOW 0x02
karlmaxwell67 5:93782eb646de 11 #define TSL_THRESHHIGHLOW 0x04
karlmaxwell67 5:93782eb646de 12 #define TSL_INTERRUPT 0x06
karlmaxwell67 5:93782eb646de 13 #define TSL_ID 0x0A
karlmaxwell67 5:93782eb646de 14 #define TSL_DATA0LOW 0x0C
karlmaxwell67 5:93782eb646de 15 #define TSL_DATA1LOW 0x0E
karlmaxwell67 1:70d7d9f1af01 16
karlmaxwell67 5:93782eb646de 17 class TSL2561_I2C {
karlmaxwell67 0:453a43c8bf2b 18 public:
karlmaxwell67 5:93782eb646de 19 TSL2561_I2C( PinName sda, PinName scl );
karlmaxwell67 1:70d7d9f1af01 20
karlmaxwell67 5:93782eb646de 21 int getVisibleAndIR();
karlmaxwell67 5:93782eb646de 22 int getIROnly();
karlmaxwell67 5:93782eb646de 23 float getLux();
karlmaxwell67 3:6a89ac4a1979 24
karlmaxwell67 3:6a89ac4a1979 25 int enablePower();
karlmaxwell67 3:6a89ac4a1979 26 int disablePower();
karlmaxwell67 4:5d1f8d7d81ff 27 bool isPowerEnabled();
karlmaxwell67 5:93782eb646de 28
karlmaxwell67 5:93782eb646de 29 int readGain();
karlmaxwell67 5:93782eb646de 30 int setGain( const int gain ); // gain must be either 1 or 16
karlmaxwell67 5:93782eb646de 31 float readIntegrationTime(); // in ms
karlmaxwell67 5:93782eb646de 32 int setIntegrationTime( const float itime ); // itime (in ms) should be 13.7, 101 or 402.
karlmaxwell67 3:6a89ac4a1979 33 int readLowInterruptThreshold();
karlmaxwell67 3:6a89ac4a1979 34 int readHighInterruptThreshold();
karlmaxwell67 3:6a89ac4a1979 35 int setLowInterruptThreshold( const int threshold );
karlmaxwell67 3:6a89ac4a1979 36 int setHighInterruptThreshold( const int threshold );
karlmaxwell67 3:6a89ac4a1979 37 int readInterruptPersistence();
karlmaxwell67 5:93782eb646de 38 int setInterruptPersistence( const int persistence ); // 0: interrupt every ADC cycle, 1-15: corresponding number of cycles until interrupt
karlmaxwell67 5:93782eb646de 39 int readInterruptControl();
karlmaxwell67 5:93782eb646de 40 int setInterruptControl( const int persistence ); // 0: interrupt output disabled, 1: Level Interrupt, 2: SMBAlert compliant, 3: Test Mode
karlmaxwell67 5:93782eb646de 41 int clearInterrupt(); // writes 0b11000000 to command register to clear interrupt
karlmaxwell67 5:93782eb646de 42 int getPartNumber(); // 0: TSL2560, 1: TSL2561
karlmaxwell67 5:93782eb646de 43 int getRevisionNumber();
karlmaxwell67 0:453a43c8bf2b 44
karlmaxwell67 0:453a43c8bf2b 45 private:
karlmaxwell67 3:6a89ac4a1979 46 I2C i2c;
karlmaxwell67 1:70d7d9f1af01 47
karlmaxwell67 1:70d7d9f1af01 48 int writeSingleRegister( char address, char data );
karlmaxwell67 3:6a89ac4a1979 49 int writeMultipleRegisters( char address, char* data, int quantity );
karlmaxwell67 1:70d7d9f1af01 50 char readSingleRegister( char address );
karlmaxwell67 1:70d7d9f1af01 51 int readMultipleRegisters( char address, char* output, int quantity );
karlmaxwell67 0:453a43c8bf2b 52 };
karlmaxwell67 0:453a43c8bf2b 53
karlmaxwell67 1:70d7d9f1af01 54 #endif