Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions common/dev/emc1413.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions common/dev/include/emc1413.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand All @@ -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
Loading