43#define CHIP_NAME "AMS TCS34725"
44#define MANUFACTURER_NAME "AMS"
45#define SUPPLY_VOLTAGE_MIN 2.7f
46#define SUPPLY_VOLTAGE_MAX 3.6f
47#define MAX_CURRENT 20.0f
48#define TEMPERATURE_MIN -40.0f
49#define TEMPERATURE_MAX 85.0f
50#define DRIVER_VERSION 2000
55#define TCS34725_REG_ENABLE 0x80
56#define TCS34725_REG_ATIME 0x81
57#define TCS34725_REG_WTIME 0x83
58#define TCS34725_REG_AILTL 0xA4
59#define TCS34725_REG_AILTH 0xA5
60#define TCS34725_REG_AIHTL 0xA6
61#define TCS34725_REG_AIHTH 0xA7
62#define TCS34725_REG_PERS 0x8C
63#define TCS34725_REG_CONFIG 0x8D
64#define TCS34725_REG_CONTROL 0x8F
65#define TCS34725_REG_ID 0x92
66#define TCS34725_REG_STATUS 0x93
67#define TCS34725_REG_CDATAL 0xB4
68#define TCS34725_REG_CDATAH 0xB5
69#define TCS34725_REG_RDATAL 0xB6
70#define TCS34725_REG_RDATAH 0xB7
71#define TCS34725_REG_GDATAL 0xB8
72#define TCS34725_REG_GDATAH 0xB9
73#define TCS34725_REG_BDATAL 0xBA
74#define TCS34725_REG_BDATAH 0xBB
75#define TCS34725_REG_CLEAR 0xE6
80#define TCS34725_ADDRESS (0x29 << 1)
109 handle->
debug_print(
"tcs34725: read register failed.\n");
118 handle->
debug_print(
"tcs34725: write register failed.\n");
153 handle->
debug_print(
"tcs34725: read register failed.\n");
190 handle->
debug_print(
"tcs34725: read register failed.\n");
199 handle->
debug_print(
"tcs34725: write register failed.\n");
234 handle->
debug_print(
"tcs34725: read register failed.\n");
271 handle->
debug_print(
"tcs34725: read register failed.\n");
280 handle->
debug_print(
"tcs34725: write register failed.\n");
315 handle->
debug_print(
"tcs34725: read register failed.\n");
352 handle->
debug_print(
"tcs34725: read register failed.\n");
361 handle->
debug_print(
"tcs34725: write register failed.\n");
396 handle->
debug_print(
"tcs34725: read register failed.\n");
433 handle->
debug_print(
"tcs34725: write register failed.\n");
468 handle->
debug_print(
"tcs34725: write register failed.\n");
489 uint8_t res, prev, bit;
503 handle->
debug_print(
"tcs34725: read register failed.\n");
507 bit = (t & 0x100) >> 8;
513 handle->
debug_print(
"tcs34725: write register failed.\n");
521 handle->
debug_print(
"tcs34725: write register failed.\n");
542 uint8_t res, prev, bit;
556 handle->
debug_print(
"tcs34725: read register failed.\n");
561 bit = (prev >> 1) & 0x01;
565 handle->
debug_print(
"tcs34725: read register failed.\n");
599 buf[0] = threshold & 0xFF;
600 buf[1] = (threshold >> 8) & 0xFF;
604 handle->
debug_print(
"tcs34725: write register failed.\n");
636 memset(buf, 0,
sizeof(uint8_t) * 2);
640 handle->
debug_print(
"tcs34725: read register failed.\n");
644 *threshold = ((uint16_t)buf[1] << 8) | buf[0];
674 buf[0] = threshold & 0xFF;
675 buf[1] = (threshold >> 8) & 0xFF;
679 handle->
debug_print(
"tcs34725: write register failed.\n");
711 memset(buf, 0,
sizeof(uint8_t) * 2);
715 handle->
debug_print(
"tcs34725: read register failed.\n");
719 *threshold = ((uint16_t)buf[1] << 8) | buf[0];
751 handle->
debug_print(
"tcs34725: read register failed.\n");
760 handle->
debug_print(
"tcs34725: write register failed.\n");
795 handle->
debug_print(
"tcs34725: read register failed.\n");
832 handle->
debug_print(
"tcs34725: read register failed.\n");
841 handle->
debug_print(
"tcs34725: write register failed.\n");
876 handle->
debug_print(
"tcs34725: read register failed.\n");
917 handle->
debug_print(
"tcs34725: read register failed.\n");
921 if ((prev & (1 << 4)) != 0)
926 handle->
debug_print(
"tcs34725: clear interrupt failed.\n");
931 if ((prev & 0x01) != 0)
940 *clear = ((uint16_t)buf[1] << 8) | buf[0];
941 *red = ((uint16_t)buf[3] << 8) | buf[2];
942 *green = ((uint16_t)buf[5] << 8) | buf[4];
943 *blue = ((uint16_t)buf[7] << 8) | buf[6];
949 handle->
debug_print(
"tcs34725: data not ready.\n");
985 handle->
debug_print(
"tcs34725: read register failed.\n");
989 if ((prev & (1 << 4)) != 0)
994 handle->
debug_print(
"tcs34725: clear interrupt failed.\n");
999 if ((prev & 0x01) != 0)
1008 *red = ((uint16_t)buf[3] << 8) | buf[2];
1009 *green = ((uint16_t)buf[5] << 8) | buf[4];
1010 *blue = ((uint16_t)buf[7] << 8) | buf[6];
1016 handle->
debug_print(
"tcs34725: data not ready.\n");
1050 handle->
debug_print(
"tcs34725: read register failed.\n");
1054 if ((prev & (1 << 4)) != 0)
1059 handle->
debug_print(
"tcs34725: clear interrupt failed.\n");
1064 if ((prev & 0x01) != 0)
1073 *clear = ((uint16_t)buf[1] << 8) | buf[0];
1079 handle->
debug_print(
"tcs34725: data not ready.\n");
1109 handle->
debug_print(
"tcs34725: iic_init is null.\n");
1115 handle->
debug_print(
"tcs34725: iic_deinit is null.\n");
1121 handle->
debug_print(
"tcs34725: iic_read is null.\n");
1127 handle->
debug_print(
"tcs34725: iic_write is null.\n");
1133 handle->
debug_print(
"tcs34725: delay_ms is null.\n");
1140 handle->
debug_print(
"tcs34725: iic init failed.\n");
1147 handle->
debug_print(
"tcs34725: read id failed.\n");
1152 if ((
id != 0x44) && (
id != 0x4D))
1190 handle->
debug_print(
"tcs34725: read register failed.\n");
1197 handle->
debug_print(
"tcs34725: write register failed.\n");
1203 handle->
debug_print(
"tcs34725: iic deinit failed.\n");
1241 handle->
debug_print(
"tcs34725: write register failed.\n");
1278 handle->
debug_print(
"tcs34725: read register failed.\n");
#define TCS34725_REG_CONFIG
#define TCS34725_REG_ENABLE
chip register definition
#define TCS34725_REG_STATUS
#define TCS34725_REG_CDATAL
#define TCS34725_REG_WTIME
#define TCS34725_REG_AIHTL
#define SUPPLY_VOLTAGE_MAX
#define TCS34725_REG_PERS
#define TCS34725_REG_CONTROL
#define TCS34725_ADDRESS
iic address definition
#define TCS34725_REG_ATIME
#define TCS34725_REG_CLEAR
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define TCS34725_REG_AILTL
#define CHIP_NAME
chip information definition
driver tcs34725 header file
uint8_t tcs34725_set_rgbc_integration_time(tcs34725_handle_t *handle, tcs34725_integration_time_t t)
set the rgbc adc integration time
uint8_t tcs34725_get_power_on(tcs34725_handle_t *handle, tcs34725_bool_t *enable)
get the power status
uint8_t tcs34725_deinit(tcs34725_handle_t *handle)
close the chip
struct tcs34725_info_s tcs34725_info_t
tcs34725 information structure definition
uint8_t tcs34725_set_gain(tcs34725_handle_t *handle, tcs34725_gain_t gain)
set the adc gain
uint8_t tcs34725_set_rgbc(tcs34725_handle_t *handle, tcs34725_bool_t enable)
enable or disable the rgbc adc
uint8_t tcs34725_set_wait_time(tcs34725_handle_t *handle, tcs34725_wait_time_t t)
set the wait time
tcs34725_bool_t
tcs34725 bool enumeration definition
uint8_t tcs34725_set_power_on(tcs34725_handle_t *handle, tcs34725_bool_t enable)
enable or disable the power
uint8_t tcs34725_get_wait_time(tcs34725_handle_t *handle, tcs34725_wait_time_t *t)
get the wait time
uint8_t tcs34725_get_wait(tcs34725_handle_t *handle, tcs34725_bool_t *enable)
get the wait time
uint8_t tcs34725_get_rgbc(tcs34725_handle_t *handle, tcs34725_bool_t *enable)
get the rgbc status
uint8_t tcs34725_info(tcs34725_info_t *info)
get chip information
uint8_t tcs34725_get_gain(tcs34725_handle_t *handle, tcs34725_gain_t *gain)
get the adc gain
uint8_t tcs34725_read_rgb(tcs34725_handle_t *handle, uint16_t *red, uint16_t *green, uint16_t *blue)
read the rgb data
struct tcs34725_handle_s tcs34725_handle_t
tcs34725 handle structure definition
tcs34725_wait_time_t
tcs34725 wait time enumeration definition
tcs34725_gain_t
tcs34725 gain enumeration definition
uint8_t tcs34725_init(tcs34725_handle_t *handle)
initialize the chip
uint8_t tcs34725_read_rgbc(tcs34725_handle_t *handle, uint16_t *red, uint16_t *green, uint16_t *blue, uint16_t *clear)
read the rgbc data
tcs34725_integration_time_t
tcs34725 integration time enumeration definition
uint8_t tcs34725_set_wait(tcs34725_handle_t *handle, tcs34725_bool_t enable)
enable or disable the wait time
uint8_t tcs34725_read_c(tcs34725_handle_t *handle, uint16_t *clear)
read the clear data
uint8_t tcs34725_get_rgbc_integration_time(tcs34725_handle_t *handle, tcs34725_integration_time_t *t)
get the rgbc adc integration time
uint8_t tcs34725_get_reg(tcs34725_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t tcs34725_set_reg(tcs34725_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t tcs34725_get_rgbc_clear_high_interrupt_threshold(tcs34725_handle_t *handle, uint16_t *threshold)
get the rgbc clear high interrupt threshold
tcs34725_interrupt_mode_t
tcs34725 interrupt mode enumeration definition
uint8_t tcs34725_set_rgbc_clear_high_interrupt_threshold(tcs34725_handle_t *handle, uint16_t threshold)
set the rgbc clear high interrupt threshold
uint8_t tcs34725_get_rgbc_clear_low_interrupt_threshold(tcs34725_handle_t *handle, uint16_t *threshold)
get the rgbc clear low interrupt threshold
uint8_t tcs34725_get_rgbc_interrupt(tcs34725_handle_t *handle, tcs34725_bool_t *enable)
get the rgbc interrupt
uint8_t tcs34725_get_interrupt_mode(tcs34725_handle_t *handle, tcs34725_interrupt_mode_t *mode)
get the interrupt mode
uint8_t tcs34725_set_rgbc_interrupt(tcs34725_handle_t *handle, tcs34725_bool_t enable)
enable or disable the rgbc interrupt
uint8_t tcs34725_set_rgbc_clear_low_interrupt_threshold(tcs34725_handle_t *handle, uint16_t threshold)
set the rgbc clear low interrupt threshold
uint8_t tcs34725_set_interrupt_mode(tcs34725_handle_t *handle, tcs34725_interrupt_mode_t mode)
set the interrupt mode
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v