Skip to content

Commit

Permalink
cleanup self_test.c
Browse files Browse the repository at this point in the history
  • Loading branch information
skot authored and Benjamin Wilson committed Nov 16, 2024
1 parent 121d3a6 commit 9b0cfac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
4 changes: 2 additions & 2 deletions main/EMC2101.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
#define EMC2101_IDEALITY_1_0566 0x37

#define EMC2101_DEFAULT_IDEALITY EMC2101_IDEALITY_1_0319 ///< Default ideality factor
#define EMC2101_DEFAULT_BETA EMC2101_BETA_11 ///< Default beta compensation
#define EMC2101_DEFAULT_FILTER EMC2101_FILTER_1 ///< Default temp filter setting
#define EMC2101_DEFAULT_BETA EMC2101_BETA_11 ///< Default beta compensation
#define EMC2101_DEFAULT_FILTER EMC2101_FILTER_1 ///< Default temp filter setting
#define EMC2101_DEFAULT_DATARATE EMC2101_DATARATE_32_HZ ///< Default temp conversion rate

#define EMC2101_I2CADDR_DEFAULT 0x4C ///< EMC2101 default i2c address
Expand Down
43 changes: 20 additions & 23 deletions main/self_test/self_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
#define POWER_CONSUMPTION_TARGET_GAMMA 11 //watts
#define POWER_CONSUMPTION_MARGIN 3 //+/- watts

#define TEMP_CAL_LIMIT 1200
//define this to just print die temp endlessly
//#define TEMP_TESTING

static const char * TAG = "self_test";

static void run_temp_cal(void);

bool should_test(GlobalState * GLOBAL_STATE) {
bool is_max = GLOBAL_STATE->asic_model == ASIC_BM1397;
uint64_t best_diff = nvs_config_get_u64(NVS_CONFIG_BEST_DIFF, 0);
Expand Down Expand Up @@ -122,6 +121,21 @@ static bool core_voltage_pass(GlobalState * GLOBAL_STATE)
return false;
}

#ifdef TEMP_TESTING
static void run_temp_cal(void) {
float external = 0, internal = 0;

while (1) {
external = EMC2101_get_external_temp();
internal = EMC2101_get_internal_temp();
ESP_LOGI(TAG, "ASIC: %.3f, AIR: %.3f [%.3f]", external, internal, external - internal);
vTaskDelay(500 / portTICK_PERIOD_MS);
}

}
#endif


void self_test(void * pvParameters)
{
GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters;
Expand Down Expand Up @@ -226,18 +240,13 @@ void self_test(void * pvParameters)

uint8_t chips_detected = 0;


SERIAL_init();
//chips_detected = (GLOBAL_STATE->ASIC_functions.init_fn)(0, GLOBAL_STATE->asic_count);
chips_detected = (GLOBAL_STATE->ASIC_functions.init_fn)(GLOBAL_STATE->POWER_MANAGEMENT_MODULE.frequency_value, GLOBAL_STATE->asic_count);
ESP_LOGI(TAG, "%u chips detected, %u expected", chips_detected, GLOBAL_STATE->asic_count);

//The following is used for temp testing
// //turn off vcore
// VCORE_set_voltage(0, GLOBAL_STATE);
// //delay 1 second to stabilize
// vTaskDelay(1000 / portTICK_PERIOD_MS);
// run_temp_cal();
#ifdef TEMP_TESTING
run_temp_cal();
#endif


int baud = (*GLOBAL_STATE->ASIC_functions.set_max_baud_fn)();
Expand Down Expand Up @@ -387,15 +396,3 @@ void self_test(void * pvParameters)
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}

// static void run_temp_cal(void) {
// float external = 0, internal = 0;

// while (1) {
// external = EMC2101_get_external_temp();
// internal = EMC2101_get_internal_temp();
// ESP_LOGI(TAG, "ASIC: %.3f, AIR: %.3f [%.3f]", external, internal, external - internal);
// vTaskDelay(500 / portTICK_PERIOD_MS);
// }

// }

0 comments on commit 9b0cfac

Please sign in to comment.