Skip to content

Commit

Permalink
organize init process for Hex
Browse files Browse the repository at this point in the history
  • Loading branch information
macphyter committed Feb 7, 2024
1 parent e6a3c80 commit f21b0b2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SRCS
"EMC2101.c"
"EMC2302.c"
"TPS546.c"
"TMP1075.c"
"fonts.c"
"INA260.c"
"led_controller.c"
Expand Down
6 changes: 3 additions & 3 deletions main/TMP1075.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ bool TMP1075_installed(int device_index)
esp_err_t result = ESP_OK;

// read the configuration register
ESP_LOGI(TAG, "Reading configuration register");
//ESP_LOGI(TAG, "Reading configuration register");
ESP_ERROR_CHECK(register_read(TMP1075_I2CADDR_DEFAULT + device_index, TMP1075_CONFIG_REG, data, 2));
ESP_LOGI(TAG, "Configuration[%d] = %02X %02X", device_index, data[0], data[1]);
//ESP_LOGI(TAG, "Configuration[%d] = %02X %02X", device_index, data[0], data[1]);

return (result == ESP_OK?true:false);
}
Expand All @@ -56,7 +56,7 @@ uint8_t TMP1075_read_temperature(int device_index)

ESP_ERROR_CHECK(register_read(TMP1075_I2CADDR_DEFAULT + device_index, TMP1075_TEMP_REG, data, 2));
//ESP_LOGI(TAG, "Raw Temperature = %02X %02X", data[0], data[1]);
ESP_LOGI(TAG, "Temperature[%d] = %d", device_index, data[0]);
//ESP_LOGI(TAG, "Temperature[%d] = %d", device_index, data[0]);
return data[0];
}

3 changes: 2 additions & 1 deletion main/TPS546.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int TPS546_init(void)
float vin;
float iout;
float vout;
uint8_t read_mfr_revision[3];
uint8_t read_mfr_revision[4];
int temp;
uint8_t comp_config[5];

Expand All @@ -388,6 +388,7 @@ int TPS546_init(void)
smb_read_block(PMBUS_IC_DEVICE_ID, data, 6);
ESP_LOGI(TAG, "Device ID: %02x %02x %02x %02x %02x %02x", data[0], data[1],
data[2], data[3], data[4], data[5]);
/* There's two different known device IDs observed so far */
if ( (memcmp(data, DEVICE_ID1, 6) != 0) && (memcmp(data, DEVICE_ID2, 6) != 0) )
{
ESP_LOGI(TAG, "ERROR- cannot find TPS546 regulator");
Expand Down
18 changes: 13 additions & 5 deletions main/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "TPS546.h"
#include "EMC2101.h"
#include "EMC2302.h"
#include "TMP1075.h"
#include "INA260.h"
#include "adc.h"
#include "connect.h"
Expand Down Expand Up @@ -77,7 +78,7 @@ static void _init_system(GlobalState * global_state, SystemModule * module)

ADC_init();

/* perform platform init based on the device name */
/* perform device init based on the device name */
/* TODO add other platforms besides HEX */
switch (global_state->board_version) {
case 201: /* ULTRA */
Expand All @@ -93,10 +94,17 @@ static void _init_system(GlobalState * global_state, SystemModule * module)
case 302: /* HEX */
// Initialize the core voltage regulator
TPS546_init();
// Fan Tests
EMC2302_init(nvs_config_get_u16(NVS_CONFIG_INVERT_FAN_POLARITY, 1));
EMC2302_set_fan_speed(0, (float) nvs_config_get_u16(NVS_CONFIG_FAN_SPEED, 100) / 100);
EMC2302_set_fan_speed(1, (float) nvs_config_get_u16(NVS_CONFIG_FAN_SPEED, 100) / 100);
// Fan config - Hex has two fans
//EMC2302_init(nvs_config_get_u16(NVS_CONFIG_INVERT_FAN_POLARITY, 1));
//EMC2302_set_fan_speed(0, (float) nvs_config_get_u16(NVS_CONFIG_FAN_SPEED, 100) / 100);
//EMC2302_set_fan_speed(1, (float) nvs_config_get_u16(NVS_CONFIG_FAN_SPEED, 100) / 100);
// temperature sensors - Hex has two sensors
if (TMP1075_installed(0)) {
ESP_LOGI(TAG, "Temperature sensor 0: %d", TMP1075_read_temperature(0));
}
if (TMP1075_installed(1)) {
ESP_LOGI(TAG, "Temperature sensor 1: %d", TMP1075_read_temperature(1));
}
break;
default:
ESP_LOGI(TAG, "ERROR- invalid board version");
Expand Down

0 comments on commit f21b0b2

Please sign in to comment.