renamed, refactored a bit

This commit is contained in:
shufps 2024-09-22 08:39:05 +02:00 committed by WantClue
parent 49033e3661
commit 84ea82b43d
6 changed files with 41 additions and 36 deletions

View File

@ -148,14 +148,7 @@ void setup()
#endif
#ifdef NERD_NOS
nerdnos_adc_init();
SERIAL_init();
int chips = BM1397_init(200, 1);
Serial.printf("found bm1397: %d\n", chips);
int baud = BM1397_set_max_baud();
vTaskDelay(100 / portTICK_PERIOD_MS);
SERIAL_set_baud(baud);
vTaskDelay(100 / portTICK_PERIOD_MS);
nerdnos_init();
TaskHandle_t ASICTask = NULL;
TaskHandle_t ASICTask_RX = NULL;

View File

@ -19,7 +19,7 @@
#include <stdint.h>
struct __attribute__((__packed__)) nerdSHA256_context {
struct nerdSHA256_context {
uint8_t buffer[64];
uint32_t digest[8];
};

View File

@ -1,25 +0,0 @@
#pragma once
#include <stdint.h>
#include "nerdnos.h"
// forward declaration to resolve circular inclusions
typedef struct mining_subscribe mining_subscribe;
typedef struct mining_job mining_job;
// set the asic hardware difficulty
void nerdnos_set_asic_difficulty(uint32_t current_difficulty);
// create asic job
void nerdnos_create_job(mining_subscribe *mWorker, mining_job *job, bm_job_t *next_job, uint32_t extranonce_2, uint32_t stratum_difficulty);
// send new work to the asic
void nerdnos_send_work(bm_job_t *next_bm_job, uint8_t job_id);
// receive and process responses
bool nerdnos_proccess_work(uint32_t version, uint16_t timeout, task_result *result);
// test difficulty
double nerdnos_test_nonce_value(const bm_job_t *job, const uint32_t nonce, const uint32_t rolled_version, uint8_t hash_result[32]);
// free allocated RAM for strings on bm_job_t
void nerdnos_free_bm_job(bm_job_t *job);

View File

@ -7,7 +7,9 @@
#include <stdio.h>
#include "bm1397.h"
#include "mining.h"
#include "nerdnos.h"
#include "adc.h"
#include "serial.h"
#include "utils.h"
#include "stratum.h"
#include "mbedtls/sha256.h"
@ -154,4 +156,15 @@ void nerdnos_free_bm_job(bm_job_t *job) {
void nerdnos_set_asic_difficulty(uint32_t difficulty) {
BM1397_set_job_difficulty_mask(difficulty);
}
void nerdnos_init() {
nerdnos_adc_init();
SERIAL_init();
int chips = BM1397_init(200, 1);
Serial.printf("found bm1397: %d\n", chips);
int baud = BM1397_set_max_baud();
vTaskDelay(100 / portTICK_PERIOD_MS);
SERIAL_set_baud(baud);
vTaskDelay(100 / portTICK_PERIOD_MS);
}

View File

@ -64,3 +64,27 @@ typedef struct __attribute__((__packed__))
uint8_t midstate2[32];
uint8_t midstate3[32];
} job_packet_t;
// forward declaration to resolve circular inclusions
typedef struct mining_subscribe mining_subscribe;
typedef struct mining_job mining_job;
// set the asic hardware difficulty
void nerdnos_set_asic_difficulty(uint32_t current_difficulty);
// create asic job
void nerdnos_create_job(mining_subscribe *mWorker, mining_job *job, bm_job_t *next_job, uint32_t extranonce_2, uint32_t stratum_difficulty);
// send new work to the asic
void nerdnos_send_work(bm_job_t *next_bm_job, uint8_t job_id);
// receive and process responses
bool nerdnos_proccess_work(uint32_t version, uint16_t timeout, task_result *result);
// test difficulty
double nerdnos_test_nonce_value(const bm_job_t *job, const uint32_t nonce, const uint32_t rolled_version, uint8_t hash_result[32]);
// free allocated RAM for strings on bm_job_t
void nerdnos_free_bm_job(bm_job_t *job);
void nerdnos_init();

View File

@ -6,7 +6,7 @@
#include <Arduino.h>
#include <ArduinoJson.h>
#include <WiFi.h>
#include "drivers/nerd-nos/mining.h"
#include "drivers/nerd-nos/nerdnos.h"
#define MAX_MERKLE_BRANCHES 32
#define HASH_SIZE 32