Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BM1368_send_hash_frequency is called on all devices when frequency change is requested. #575

Open
mutatrum opened this issue Dec 12, 2024 · 0 comments
Assignees
Labels
accepted This issue will be worked on

Comments

@mutatrum
Copy link
Contributor

The function do_frequency_transition is only in bm1368.c, which calls BM1368_send_hash_frequency function. This function is called on all devices. This works because they apparently use the same command.

if (asic_frequency != last_asic_frequency) {
ESP_LOGI(TAG, "New ASIC frequency requested: %uMHz (current: %uMHz)", asic_frequency, last_asic_frequency);
if (do_frequency_transition((float)asic_frequency)) {
power_management->frequency_value = (float)asic_frequency;
ESP_LOGI(TAG, "Successfully transitioned to new ASIC frequency: %uMHz", asic_frequency);
} else {
ESP_LOGE(TAG, "Failed to transition to new ASIC frequency: %uMHz", asic_frequency);
}
last_asic_frequency = asic_frequency;
}

bool do_frequency_transition(float target_frequency) {
float step = 6.25;
float current = current_frequency;
float target = target_frequency;
float direction = (target > current) ? step : -step;
if (fmod(current, step) != 0) {
float next_dividable;
if (direction > 0) {
next_dividable = ceil(current / step) * step;
} else {
next_dividable = floor(current / step) * step;
}
current = next_dividable;
BM1368_send_hash_frequency(current);
vTaskDelay(100 / portTICK_PERIOD_MS);
}
while ((direction > 0 && current < target) || (direction < 0 && current > target)) {
float next_step = fmin(fabs(direction), fabs(target - current));
current += direction > 0 ? next_step : -next_step;
BM1368_send_hash_frequency(current);
vTaskDelay(100 / portTICK_PERIOD_MS);
}
BM1368_send_hash_frequency(target);
return true;
}

@WantClue WantClue added the accepted This issue will be worked on label Dec 12, 2024
@WantClue WantClue self-assigned this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This issue will be worked on
Projects
None yet
Development

No branches or pull requests

2 participants