42#define CHIP_NAME "STMicroelectronic STTS22H"
43#define MANUFACTURER_NAME "STMicroelectronic"
44#define SUPPLY_VOLTAGE_MIN 1.5f
45#define SUPPLY_VOLTAGE_MAX 3.6f
46#define MAX_CURRENT 0.18f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 125.0f
49#define DRIVER_VERSION 1000
54#define STTS22H_REG_WHOAMI 0x01
55#define STTS22H_REG_TEMP_H_LIMIT 0x02
56#define STTS22H_REG_TEMP_L_LIMIT 0x03
57#define STTS22H_REG_CTRL 0x04
58#define STTS22H_REG_STATUS 0x05
59#define STTS22H_REG_TEMP_L_OUT 0x06
60#define STTS22H_REG_TEMP_H_OUT 0x07
73static uint8_t a_stts22h_read(
stts22h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
86 for (i = 0; i < len; i++)
109static uint8_t a_stts22h_write(
stts22h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
122 for (i = 0; i < len; i++)
150 handle->
iic_addr = (uint8_t)addr_pin;
205 handle->
debug_print(
"stts22h: write temperature high limit failed.\n");
241 handle->
debug_print(
"stts22h: read temperature high limit failed.\n");
279 handle->
debug_print(
"stts22h: write temperature low limit failed.\n");
315 handle->
debug_print(
"stts22h: read temperature low limit failed.\n");
352 handle->
debug_print(
"stts22h: read control failed.\n");
369 handle->
debug_print(
"stts22h: write control failed.\n");
405 handle->
debug_print(
"stts22h: read control failed.\n");
410 if (((prev >> 7) & 0x01) != 0)
450 handle->
debug_print(
"stts22h: read control failed.\n");
459 handle->
debug_print(
"stts22h: write control failed.\n");
495 handle->
debug_print(
"stts22h: read control failed.\n");
532 handle->
debug_print(
"stts22h: read control failed.\n");
541 handle->
debug_print(
"stts22h: write control failed.\n");
578 handle->
debug_print(
"stts22h: read control failed.\n");
615 handle->
debug_print(
"stts22h: read control failed.\n");
624 handle->
debug_print(
"stts22h: write control failed.\n");
660 handle->
debug_print(
"stts22h: read control failed.\n");
697 handle->
debug_print(
"stts22h: read status failed.\n");
738 handle->
debug_print(
"stts22h: read control failed.\n");
748 handle->
debug_print(
"stts22h: write control failed.\n");
759 handle->
debug_print(
"stts22h: read status failed.\n");
763 if ((prev & 0x01) == 0)
784 *raw = (int16_t)((uint16_t)((uint16_t)buf[1] << 8) | buf[0]);
785 *celsius_deg = (float)(*raw) / 100.0f;
817 handle->
debug_print(
"stts22h: read control failed.\n");
826 handle->
debug_print(
"stts22h: write control failed.\n");
861 handle->
debug_print(
"stts22h: read control failed.\n");
870 handle->
debug_print(
"stts22h: write control failed.\n");
912 *raw = (int16_t)((uint16_t)((uint16_t)buf[1] << 8) | buf[0]);
913 *celsius_deg = (float)(*raw) / 100.0f;
945 handle->
debug_print(
"stts22h: read status failed.\n");
989 *reg = (uint8_t)(celsius_deg / 0.64f) + 63;
1016 *celsius_deg = ((float)(reg) - 63.0f) * 0.64f;
1048 handle->
debug_print(
"stts22h: iic_init is null.\n");
1054 handle->
debug_print(
"stts22h: iic_deinit is null.\n");
1060 handle->
debug_print(
"stts22h: iic_read is null.\n");
1066 handle->
debug_print(
"stts22h: iic_write is null.\n");
1072 handle->
debug_print(
"stts22h: delay_ms is null.\n");
1078 handle->
debug_print(
"stts22h: receive_callback is null.\n");
1085 handle->
debug_print(
"stts22h: iic init failed.\n");
1093 handle->
debug_print(
"stts22h: read who am i failed.\n");
1109 handle->
debug_print(
"stts22h: read control failed.\n");
1119 handle->
debug_print(
"stts22h: write control failed.\n");
1158 handle->
debug_print(
"stts22h: read control failed.\n");
1168 handle->
debug_print(
"stts22h: write control failed.\n");
1175 handle->
debug_print(
"stts22h: iic deinit failed.\n");
1208 return a_stts22h_write(handle, reg, buf, len);
1235 return a_stts22h_read(handle, reg, buf, len);
#define STTS22H_REG_TEMP_L_OUT
#define STTS22H_REG_TEMP_H_LIMIT
#define STTS22H_REG_WHOAMI
chip register definition
#define SUPPLY_VOLTAGE_MAX
#define STTS22H_REG_STATUS
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define STTS22H_REG_TEMP_L_LIMIT
#define CHIP_NAME
chip information definition
driver stts22h header file
uint8_t stts22h_init(stts22h_handle_t *handle)
initialize the chip
uint8_t stts22h_set_temperature_low_limit(stts22h_handle_t *handle, uint8_t raw)
set temperature low limit
uint8_t stts22h_get_temperature_high_limit(stts22h_handle_t *handle, uint8_t *raw)
get temperature high limit
uint8_t stts22h_get_temperature_low_limit(stts22h_handle_t *handle, uint8_t *raw)
get temperature low limit
uint8_t stts22h_stop_continuous_read(stts22h_handle_t *handle)
stop the chip reading
uint8_t stts22h_get_status(stts22h_handle_t *handle, uint8_t *status)
get status
uint8_t stts22h_get_addr_pin(stts22h_handle_t *handle, stts22h_address_t *addr_pin)
get the iic address pin
stts22h_bool_t
stts22h bool enumeration definition
uint8_t stts22h_set_iic_address_auto_increment(stts22h_handle_t *handle, stts22h_bool_t enable)
enable or disable iic address auto increment
uint8_t stts22h_set_temperature_high_limit(stts22h_handle_t *handle, uint8_t raw)
set temperature high limit
struct stts22h_handle_s stts22h_handle_t
stts22h handle structure definition
uint8_t stts22h_get_disable_smbus_timeout(stts22h_handle_t *handle, stts22h_bool_t *enable)
get disable smbus timeout status
uint8_t stts22h_temperature_convert_to_data(stts22h_handle_t *handle, uint8_t reg, float *celsius_deg)
convert the register raw data to the temperature
uint8_t stts22h_set_addr_pin(stts22h_handle_t *handle, stts22h_address_t addr_pin)
set the iic address pin
uint8_t stts22h_set_output_data_rate(stts22h_handle_t *handle, stts22h_output_data_rate_t rate)
set output data rate
uint8_t stts22h_deinit(stts22h_handle_t *handle)
close the chip
uint8_t stts22h_get_iic_address_auto_increment(stts22h_handle_t *handle, stts22h_bool_t *enable)
get iic address auto increment status
uint8_t stts22h_get_block_data_update(stts22h_handle_t *handle, stts22h_bool_t *enable)
get block data update status
uint8_t stts22h_info(stts22h_info_t *info)
get chip's information
uint8_t stts22h_set_block_data_update(stts22h_handle_t *handle, stts22h_bool_t enable)
enable or disable block data update
uint8_t stts22h_irq_handler(stts22h_handle_t *handle)
irq handler
uint8_t stts22h_set_disable_smbus_timeout(stts22h_handle_t *handle, stts22h_bool_t enable)
enable or disable disable smbus timeout
uint8_t stts22h_continuous_read(stts22h_handle_t *handle, int16_t *raw, float *celsius_deg)
read data from the chip continuously
uint8_t stts22h_temperature_convert_to_register(stts22h_handle_t *handle, float celsius_deg, uint8_t *reg)
convert the temperature to the register raw data
stts22h_address_t
stts22h address enumeration definition
uint8_t stts22h_start_continuous_read(stts22h_handle_t *handle)
start the chip reading
uint8_t stts22h_single_read(stts22h_handle_t *handle, int16_t *raw, float *celsius_deg)
read data from the chip once
struct stts22h_info_s stts22h_info_t
stts22h information structure definition
uint8_t stts22h_get_output_data_rate(stts22h_handle_t *handle, stts22h_output_data_rate_t *rate)
get output data rate
stts22h_output_data_rate_t
stts22h output data rate enumeration definition
@ STTS22H_STATUS_OVER_HIGH_LIMIT
@ STTS22H_STATUS_UNDER_LOW_LIMIT
@ STTS22H_OUTPUT_DATA_RATE_1HZ
uint8_t stts22h_get_reg(stts22h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t stts22h_set_reg(stts22h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
void(* delay_ms)(uint32_t ms)
void(* receive_callback)(uint8_t type)
void(* debug_print)(const char *const fmt,...)
uint8_t iic_addr_auto_inc
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