diff --git a/common/dev/emc1413.c b/common/dev/emc1413.c index 07b5674887..14f8ae830b 100644 --- a/common/dev/emc1413.c +++ b/common/dev/emc1413.c @@ -443,6 +443,28 @@ bool emc1413_clear_temp_status(sensor_cfg *cfg) return true; } +bool emc1413_get_temp_open_status(sensor_cfg *cfg, uint8_t *temp_status) +{ + CHECK_NULL_ARG_WITH_RETURN(cfg, false); + + I2C_MSG i2c_msg = { 0 }; + uint8_t retry = 5; + i2c_msg.bus = cfg->port; + i2c_msg.target_addr = cfg->target_addr; + i2c_msg.tx_len = 1; + i2c_msg.rx_len = 1; + i2c_msg.data[0] = EMC1413_OPEN_STATUS_REG; + + if (i2c_master_read(&i2c_msg, retry)) { + LOG_ERR("TMP[0x%x] get open status reg[0x%d] failed.", cfg->num, + EMC1413_OPEN_STATUS_REG); + return false; + } + *temp_status = i2c_msg.data[0]; + + return true; +} + uint8_t emc1413_init(sensor_cfg *cfg) { CHECK_NULL_ARG_WITH_RETURN(cfg, SENSOR_INIT_UNSPECIFIED_ERROR); diff --git a/common/dev/include/emc1413.h b/common/dev/include/emc1413.h index ef251ca457..19088fc861 100644 --- a/common/dev/include/emc1413.h +++ b/common/dev/include/emc1413.h @@ -50,6 +50,7 @@ enum EMC1413_REIGSTER_MAP { EMC1413_INTERNAL_THERM_LIMIT_REG = 0x20, EMC1413_EXTERNAL_1_THERM_LIMIT_REG = 0x19, EMC1413_EXTERNAL_2_THERM_LIMIT_REG = 0x1A, + EMC1413_OPEN_STATUS_REG = 0x1B, EMC1413_REG_MAX, }; @@ -59,5 +60,6 @@ bool emc1413_set_temp_threshold(sensor_cfg *cfg, uint8_t temp_threshold_index, uint32_t *millidegree_celsius); bool emc1413_set_comparator_mode(sensor_cfg *cfg); bool emc1413_set_therm_hysteresis(sensor_cfg *cfg, uint8_t temp_therm_hysteresis_val); +bool emc1413_get_temp_open_status(sensor_cfg *cfg, uint8_t *temp_status); #endif