mbed library for the TCA9548 mux

Fork of libTCS34725 by Michael Wilkens

TCS34725.h

Committer:
mwilkens241
Date:
2017-01-19
Revision:
0:4796574af790
Child:
1:06c9bbbdb8b0

File content as of revision 0:4796574af790:

// TCS34725 RGB Color I2C Sensor breakout library for F030R8 Nucleo board

//These pins should be the only piece specific to the F030R8
#define SCL            PB_8
#define SDA            PB_9

//I2C Address

#define SENSOR_ADDR 0x29

//Important Registers

#define TCS34725_ENABLE                  (0x00) //for turning on the device
#define TCS34725_ATIME                   (0x01)  //for integration time
#define TCS34725_CONTROL                 (0x0F)  //for setting the gain
#define TCS34725_CDATAL                  (0x14)    /* Clear channel data */
#define TCS34725_CDATAH                  (0x15)
#define TCS34725_RDATAL                  (0x16)    /* Red channel data */
#define TCS34725_RDATAH                  (0x17)
#define TCS34725_GDATAL                  (0x18)    /* Green channel data */
#define TCS34725_GDATAH                  (0x19)
#define TCS34725_BDATAL                  (0x1A)    /* Blue channel data */
#define TCS34725_BDATAH                  (0x1B)

//Configuration Bits

#define TCS34725_ENABLE_AEN              (0x02)    /* RGBC Enable - Writing 1 actives the ADC, 0 disables it */
#define TCS34725_ENABLE_PON              (0x01) /* Power on - Writing 1 activates the internal oscillator, 0 disables it */
#define TCS34725_INTEGRATIONTIME_2_4MS    0xFF   /**<  2.4ms - 1 cycle    - Max Count: 1024  */
#define TCS34725_INTEGRATIONTIME_24MS     0xF6   /**<  24ms  - 10 cycles  - Max Count: 10240 */
#define TCS34725_INTEGRATIONTIME_50MS     0xEB   /**<  50ms  - 20 cycles  - Max Count: 20480 */
#define TCS34725_INTEGRATIONTIME_101MS    0xD5   /**<  101ms - 42 cycles  - Max Count: 43008 */
#define TCS34725_INTEGRATIONTIME_154MS    0xC0   /**<  154ms - 64 cycles  - Max Count: 65535 */
#define TCS34725_INTEGRATIONTIME_700MS    0x00   /**<  700ms - 256 cycles - Max Count: 65535 */
#define TCS34725_GAIN_1X                  0x00   /**<  No gain  */
#define TCS34725_GAIN_4X                  0x01   /**<  4x gain  */
#define TCS34725_GAIN_16X                 0x02   /**<  16x gain */
#define TCS34725_GAIN_60X                 0x03   /**<  60x gain */

void i2cWrite8(uint8_t addr, char reg, char data);
uint8_t i2cRead8(uint8_t addr, char reg);
uint16_t i2cRead16(uint8_t addr, char reg);

TCS34725_init(char intTime, char gain);
TCS34725_config(char intTime, char gain);
TCS34725_getColor(uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c);