43#define CHIP_NAME "STMicroelectronics UVIS25"
44#define MANUFACTURER_NAME "STMicroelectronics"
45#define SUPPLY_VOLTAGE_MIN 1.7f
46#define SUPPLY_VOLTAGE_MAX 3.6f
47#define MAX_CURRENT 0.01f
48#define TEMPERATURE_MIN -20.0f
49#define TEMPERATURE_MAX 85.0f
50#define DRIVER_VERSION 2000
55#define UVIS25_REG_WHO_AM_I 0x0F
56#define UVIS25_REG_CTRL_REG1 0x20
57#define UVIS25_REG_CTRL_REG2 0x21
58#define UVIS25_REG_CTRL_REG3 0x22
59#define UVIS25_REG_INT_CFG 0x23
60#define UVIS25_REG_INT_SOURCE 0x24
61#define UVIS25_REG_THS_UV 0x25
62#define UVIS25_REG_STATUS_REG 0x27
63#define UVIS25_REG_UV_OUT_REG 0x28
68#define UVIS25_IIC_ADDRESS 0x8E
81static uint8_t a_uvis25_iic_spi_read(
uvis25_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
107 if (handle->
spi_read(reg, buf, len) != 0)
129static uint8_t a_uvis25_iic_spi_write(
uvis25_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
153 if (handle->
spi_write(reg, buf, len) != 0)
180 handle->
iic_spi = (uint8_t)interface;
234 handle->
debug_print(
"uvis25: read register failed.\n");
272 handle->
debug_print(
"uvis25: read register failed.\n");
309 handle->
debug_print(
"uvis25: read register failed.\n");
347 handle->
debug_print(
"uvis25: read register failed.\n");
384 handle->
debug_print(
"uvis25: read register failed.\n");
389 prev |= (!enable) << 4;
422 handle->
debug_print(
"uvis25: read register failed.\n");
459 handle->
debug_print(
"uvis25: read register failed.\n");
497 handle->
debug_print(
"uvis25: read register failed.\n");
534 handle->
debug_print(
"uvis25: read register failed.\n");
572 handle->
debug_print(
"uvis25: read register failed.\n");
609 handle->
debug_print(
"uvis25: read register failed.\n");
614 prev |= pin_type << 6;
647 handle->
debug_print(
"uvis25: read register failed.\n");
684 handle->
debug_print(
"uvis25: read register failed.\n");
688 prev &= ~(0x03 << 0);
722 handle->
debug_print(
"uvis25: read register failed.\n");
759 handle->
debug_print(
"uvis25: read register failed.\n");
763 prev &= ~(0x01 << 3);
797 handle->
debug_print(
"uvis25: read register failed.\n");
834 handle->
debug_print(
"uvis25: read register failed.\n");
838 prev &= ~(0x01 << 2);
872 handle->
debug_print(
"uvis25: read register failed.\n");
909 handle->
debug_print(
"uvis25: read register failed.\n");
913 prev &= ~(0x01 << 1);
947 handle->
debug_print(
"uvis25: read register failed.\n");
984 handle->
debug_print(
"uvis25: read register failed.\n");
988 prev &= ~(0x01 << 0);
1022 handle->
debug_print(
"uvis25: read register failed.\n");
1053 return a_uvis25_iic_spi_write(handle,
UVIS25_REG_THS_UV, (uint8_t *)&threshold, 1);
1078 return a_uvis25_iic_spi_read(handle,
UVIS25_REG_THS_UV, (uint8_t *)threshold, 1);
1107 handle->
debug_print(
"uvis25: read register failed.\n");
1111 if ((prev & (1 << 2)) != 0)
1118 if ((prev & (1 << 1)) != 0)
1125 if ((prev & (1 << 0)) != 0)
1159 *reg = (uint8_t )(uv * 16.0f);
1187 *uv = (float)reg / 16.0f;
1216 handle->
debug_print(
"uvis25: iic_init is null.\n");
1222 handle->
debug_print(
"uvis25: iic_deinit is null.\n");
1228 handle->
debug_print(
"uvis25: iic_read is null.\n");
1234 handle->
debug_print(
"uvis25: iic_write is null.\n");
1240 handle->
debug_print(
"uvis25: spi_init is null.\n");
1246 handle->
debug_print(
"uvis25: spi_deinit is null.\n");
1252 handle->
debug_print(
"uvis25: spi_read is null.\n");
1258 handle->
debug_print(
"uvis25: spi_write is null.\n");
1264 handle->
debug_print(
"uvis25: delay_ms is null.\n");
1273 handle->
debug_print(
"uvis25: iic init failed.\n");
1282 handle->
debug_print(
"uvis25: spi init failed.\n");
1347 handle->
debug_print(
"uvis25: read register failed.\n");
1351 prev &= ~(0x01 << 7);
1356 handle->
debug_print(
"uvis25: write register failed.\n");
1365 handle->
debug_print(
"uvis25: iic deinit failed.\n");
1375 handle->
debug_print(
"uvis25: spi deinit failed.\n");
1415 handle->
debug_print(
"uvis25: read register failed.\n");
1423 handle->
debug_print(
"uvis25: write register failed.\n");
1430 handle->
debug_print(
"uvis25: read register failed.\n");
1439 handle->
debug_print(
"uvis25: write register failed.\n");
1450 handle->
debug_print(
"uvis25: read register failed.\n");
1454 if ((prev & 0x01) != 0)
1463 *uv = (float)(*raw) / 16.0f;
1467 else if (timeout < 100)
1476 handle->
debug_print(
"uvis25: data is not available.\n");
1510 handle->
debug_print(
"uvis25: read register failed.\n");
1519 handle->
debug_print(
"uvis25: write register failed.\n");
1526 handle->
debug_print(
"uvis25: read register failed.\n");
1534 handle->
debug_print(
"uvis25: write register failed.\n");
1569 handle->
debug_print(
"uvis25: read register failed.\n");
1577 handle->
debug_print(
"uvis25: write register failed.\n");
1584 handle->
debug_print(
"uvis25: read register failed.\n");
1592 handle->
debug_print(
"uvis25: write register failed.\n");
1629 handle->
debug_print(
"uvis25: read register failed.\n");
1633 if ((prev & 0x01) != 0)
1642 *uv = (float)(*raw) / 16.0f;
1648 handle->
debug_print(
"uvis25: data is not available.\n");
1678 return a_uvis25_iic_spi_write(handle, reg, buf, len);
1705 return a_uvis25_iic_spi_read(handle, reg, buf, len);
#define UVIS25_REG_INT_SOURCE
#define UVIS25_REG_THS_UV
#define UVIS25_REG_UV_OUT_REG
#define UVIS25_REG_STATUS_REG
#define UVIS25_REG_CTRL_REG3
#define SUPPLY_VOLTAGE_MAX
#define UVIS25_REG_CTRL_REG1
#define UVIS25_REG_CTRL_REG2
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip register definition
#define UVIS25_IIC_ADDRESS
iic address definition
#define UVIS25_REG_WHO_AM_I
chip register definition
#define UVIS25_REG_INT_CFG
driver uvis25 header file
uvis25_interface_t
uvis25 interface enumeration definition
uint8_t uvis25_get_iic(uvis25_handle_t *handle, uvis25_bool_t *enable)
get the chip iic status
uint8_t uvis25_set_boot(uvis25_handle_t *handle, uvis25_boot_mode_t mode)
set the boot mode
uint8_t uvis25_set_spi_wire(uvis25_handle_t *handle, uvis25_spi_wire_t wire)
set the spi wire
uint8_t uvis25_init(uvis25_handle_t *handle)
initialize the chip
uint8_t uvis25_set_iic(uvis25_handle_t *handle, uvis25_bool_t enable)
enable or disable the chip iic
uint8_t uvis25_continuous_read(uvis25_handle_t *handle, uint8_t *raw, float *uv)
read data continuously
uint8_t uvis25_deinit(uvis25_handle_t *handle)
close the chip
uint8_t uvis25_irq_handler(uvis25_handle_t *handle)
irq handler
uint8_t uvis25_set_interface(uvis25_handle_t *handle, uvis25_interface_t interface)
set the chip interface
uint8_t uvis25_get_boot(uvis25_handle_t *handle, uvis25_boot_mode_t *mode)
get the boot mode
uvis25_boot_mode_t
uvis25 boot enumeration definition
uint8_t uvis25_get_interface(uvis25_handle_t *handle, uvis25_interface_t *interface)
get the chip interface
uint8_t uvis25_single_read(uvis25_handle_t *handle, uint8_t *raw, float *uv)
read data once
struct uvis25_info_s uvis25_info_t
uvis25 information structure definition
struct uvis25_handle_s uvis25_handle_t
uvis25 handle structure definition
uint8_t uvis25_info(uvis25_info_t *info)
get chip's information
uvis25_spi_wire_t
uvis25 spi wire enumeration definition
uint8_t uvis25_get_block_data_update(uvis25_handle_t *handle, uvis25_bool_t *enable)
get blocking data update status
uint8_t uvis25_set_block_data_update(uvis25_handle_t *handle, uvis25_bool_t enable)
enable or disable blocking data update
uvis25_bool_t
uvis25 bool enumeration definition
uint8_t uvis25_start_continuous_read(uvis25_handle_t *handle)
start reading
uint8_t uvis25_stop_continuous_read(uvis25_handle_t *handle)
stop reading
uint8_t uvis25_get_spi_wire(uvis25_handle_t *handle, uvis25_spi_wire_t *wire)
get the spi wire
uint8_t uvis25_set_reg(uvis25_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t uvis25_get_reg(uvis25_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t uvis25_get_threshold(uvis25_handle_t *handle, uint8_t *threshold)
get the interrupt threshold
uint8_t uvis25_set_interrupt_low_threshold(uvis25_handle_t *handle, uvis25_bool_t enable)
enable or disable the low threshold interrupt
uvis25_interrupt_pin_type_t
uvis25 interrupt pin type enumeration definition
uint8_t uvis25_set_interrupt_high_threshold(uvis25_handle_t *handle, uvis25_bool_t enable)
enable or disable the high threshold interrupt
uint8_t uvis25_get_interrupt_type(uvis25_handle_t *handle, uvis25_interrupt_type_t *type)
get the interrupt type
uint8_t uvis25_get_interrupt_low_threshold(uvis25_handle_t *handle, uvis25_bool_t *enable)
get the low threshold interrupt status
uint8_t uvis25_set_interrupt_pin_type(uvis25_handle_t *handle, uvis25_interrupt_pin_type_t pin_type)
set the interrupt pin type
uint8_t uvis25_set_threshold(uvis25_handle_t *handle, uint8_t threshold)
set the interrupt threshold
uvis25_interrupt_active_level_t
uvis25 interrupt active level enumeration definition
uint8_t uvis25_set_interrupt_active_level(uvis25_handle_t *handle, uvis25_interrupt_active_level_t level)
set the interrupt active level
uint8_t uvis25_get_latch_interrupt(uvis25_handle_t *handle, uvis25_bool_t *enable)
get the latching interrupt status
uint8_t uvis25_threshold_convert_to_register(uvis25_handle_t *handle, float uv, uint8_t *reg)
convert a uv index to a raw register data
uint8_t uvis25_get_interrupt_pin_type(uvis25_handle_t *handle, uvis25_interrupt_pin_type_t *pin_type)
get the interrupt pin type
uint8_t uvis25_get_interrupt_high_threshold(uvis25_handle_t *handle, uvis25_bool_t *enable)
get the high threshold interrupt status
uint8_t uvis25_set_latch_interrupt(uvis25_handle_t *handle, uvis25_bool_t enable)
enable or disable latching interrupt
uint8_t uvis25_get_interrupt(uvis25_handle_t *handle, uvis25_bool_t *enable)
get the chip interrupt status
uint8_t uvis25_set_interrupt_type(uvis25_handle_t *handle, uvis25_interrupt_type_t type)
set the interrupt type
uint8_t uvis25_threshold_convert_to_data(uvis25_handle_t *handle, uint8_t reg, float *uv)
convert a raw register data to a converted uv index
uint8_t uvis25_set_interrupt(uvis25_handle_t *handle, uvis25_bool_t enable)
enable or disable the chip interrupt
uvis25_interrupt_type_t
uvis25 interrupt type enumeration definition
uint8_t uvis25_get_interrupt_active_level(uvis25_handle_t *handle, uvis25_interrupt_active_level_t *level)
get the interrupt active level
@ UVIS25_INTERRUPT_HIGHER
@ UVIS25_INTERRUPT_ACTIVE
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* receive_callback)(uint8_t type)
uint8_t(* spi_write)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* spi_deinit)(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