blob: 1db6d18aceeb10f9beb1f834b3171774bd0a7d44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#include "asic_miner.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <string.h>
static const char *TAG = "asic_miner";
static bool s_present = false;
static bool s_running = false;
static TaskHandle_t s_task_handle = NULL;
static double s_hashrate = 0.0;
static void asic_miner_task(void *arg)
{
ESP_LOGI(TAG, "ASIC miner task started (stub)");
while (s_running) {
vTaskDelay(pdMS_TO_TICKS(1000));
}
vTaskDelete(NULL);
}
esp_err_t asic_miner_init(void)
{
s_present = false;
ESP_LOGI(TAG, "ASIC miner initialized - no ASIC detected (software fallback)");
return ESP_OK;
}
bool asic_miner_is_present(void)
{
return s_present;
}
esp_err_t asic_miner_start(void)
{
if (!s_present) {
ESP_LOGW(TAG, "No ASIC present, cannot start");
return ESP_FAIL;
}
s_running = true;
BaseType_t ret = xTaskCreate(asic_miner_task, "asic_miner", 4096, NULL, 3, &s_task_handle);
if (ret != pdPASS) {
ESP_LOGE(TAG, "Failed to create ASIC task");
s_running = false;
return ESP_FAIL;
}
return ESP_OK;
}
void asic_miner_stop(void)
{
s_running = false;
if (s_task_handle) {
vTaskDelay(pdMS_TO_TICKS(500));
s_task_handle = NULL;
}
}
double asic_miner_get_hashrate(void)
{
return s_hashrate;
}
|