Zigbee Module Examples

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
hal_AMS_TCS3414_color_sensor.h File Reference

Hardware Abstraction Layer (HAL) file for AMS TCS3414 Color Sensor. More...

`#include <stdint.h>`

## Data Structures
struct | ColorReading

## Macros
#define | COLOR_SENSOR_I2C_ADDRESS (0x39)
#define | TCS3414_DELAY_MS 13
#define | TCS3414_READ_ADDRESS (0x73)
#define | TCS3414_COMMAND_BIT (0x80)
#define | TCS3414_WORD_BIT (0x20)
#define | TCS3414_REGISTER_CONTROL (0x00)
#define | TCS3414_REGISTER_TIMING (0x01)
#define | TCS3414_REGISTER_INTERRUPT (0x02)
#define | TCS3414_REGISTER_INTSOURCE (0x03)
#define | TCS3414_REGISTER_PARTNO_REVID (0x04)
#define | TCS3414_REGISTER_GAIN (0x07)
#define | TCS3414_REGISTER_LOWTHRESHOLD_LOWBYTE (0x08)
#define | TCS3414_REGISTER_LOWTHRESHOLD_HIGHBYTE (0x09)
#define | TCS3414_REGISTER_HIGHTHRESHOLD_LOWBYTE (0x0A)
#define | TCS3414_REGISTER_HIGHTHRESHOLD_HIGHBYTE (0x0B)
#define | TCS3414_REGISTER_GREENLOW (0x10)
#define | TCS3414_REGISTER_GREENHIGH (0x11)
#define | TCS3414_REGISTER_REDLOW (0x12)
#define | TCS3414_REGISTER_REDHIGH (0x13)
#define | TCS3414_REGISTER_BLUELOW (0x14)
#define | TCS3414_REGISTER_BLUEHIGH (0x15)
#define | TCS3414_REGISTER_CLEARLOW (0x16)
#define | TCS3414_REGISTER_CLEARHIGH (0x17)
#define | TCS3414_CONTROL_POWERON (0x01)
#define | TCS3414_CONTROL_POWEROFF (0x00)
#define | TCS3414_CONTROL_ADC_EN (0x02)
#define | TCS3414_CONTROL_ADC_VALID (0x10)
#define | TCS3414_GAIN_GAINMASK (0x30)
#define | TCS3414_GAIN_PRESCALARMASK (0x07)
#define | TCS3414_GAIN_1X (0x00)
#define | TCS3414_GAIN_4X (0x10)
#define | TCS3414_GAIN_16X (0x20)
#define | TCS3414_GAIN_64X (0x30)
#define | TCS3414_INTEGRATION_TIME_MASK (0x03)
#define | TCS3414_INTEGRATION_TIME_12MS (0x00)
#define | TCS3414_INTEGRATION_TIME_100MS (0x01)
#define | TCS3414_INTEGRATION_TIME_400MS (0x02)

## Functions
void | colorSensorInit ()
struct ColorReading | getColor (void)
uint16_t | convertRGBToCCT (uint16_t red, uint16_t green, uint16_t blue)

## Detailed Description

Hardware Abstraction Layer (HAL) file for AMS TCS3414 Color Sensor.

Rev:
  1528

Author:
  dsmith

Date:
  2012-08-30 15:58:08 -0700 (Thu, 30 Aug 2012)

# Support

Please refer to the wiki at www.anaren.com/air-wiki-zigbee for more information. Additional support is available via email at the following addresses:

- Questions on how to use the product: AIR@a.nosp@m.nare.nosp@m.n.com
- Feature requests, comments, and improvements: featu.nosp@m.rere.nosp@m.quest.nosp@m.s@te.nosp@m.slaco.nosp@m.ntro.nosp@m.ls.co.nosp@m.m
- Consulting engagements: sales.nosp@m.@tes.nosp@m.lacon.nosp@m.trol.nosp@m.s.com

# License

Copyright (c) 2012 Anaren Microwave. All rights reserved. This Software may only be used with an Anaren A2530E24AZ1, A2530E24CZ1, A2530R24AZ1, or A2530R24CZ1 module. Redistribution and use in source and binary forms, with or without modification, are subject to the Software License Agreement in the file "anaren_eula.txt"

YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL ANAREN MICROWAVE OR TESLA CONTROLS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSE INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

## Macro Definition Documentation

#define COLOR_SENSOR_I2C_ADDRESS (0x39)

    The I2C address of the TCS3414 color sensor. Note that this is the "correct" I2C address and does

not include read vs. write; that is set by the I2C driver.

#define TCS3414_READ_ADDRESS (0x73)

SMBus interface requires repeating the I2C address

## Function Documentation

void colorSensorInit | ( |  | ) |

    Configures the color sensor. Turns it on and configures the integration time. Also reads back the ID register.

Precondition:
  I2C interface on microcontroller was configured correctly

Note:
  Part maximum baud rate 400kHz for I2C.
  On powerup, the sensor is powered down and needs to be turned on before use.

uint16_t convertRGBToCCT | ( | uint16_t | red,
|  | uint16_t | green,
|  | uint16_t | blue
| ) |  |

Converts RGB values to Correlated Color Temperature (CCT). CCT is measured in Kelvin (K) and describes whether the ambient light is more warm (low CCT) or cool (high CCT). Typical CCT values are:

- Incandescent lamp: 3200K
- Cool White fluorescent lamp: 5000
- Overcast sky: 6500
  See also:
    http://en.wikipedia.org/wiki/Color_Temperature
    "Calculating Color Temperature and Illuminance using the TAOS TCS3414 Digital Color Sensor"
  Returns:
    color temperature in K

struct ColorReading getColor | ( | void |  | ) |
| read

    Read color values from the tcs3414 color sensor.

Returns:
  ColorReading structure containing values for Red, Green, Blue, and Clear sensor readings.

Precondition:
  I2C bus was configured properly and color sensor was initialized with colorSensorInit().