Skip to content

Commit e6dc0cb

Browse files
committed
Revert "Fix reading temperature problem", should be done in host side
This reverts commit d4b1f2a.
1 parent d4b1f2a commit e6dc0cb

File tree

4 files changed

+14
-47
lines changed

4 files changed

+14
-47
lines changed

firmware/main.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ static int g_local_work = 0;
3939
static int g_hw_work = 0;
4040

4141
uint32_t g_clock_conf_count = 0;
42-
uint16_t temperature0[10] = {0};
43-
uint16_t temperature1[10] = {0};
42+
4443

4544
static uint32_t g_nonce2_offset = 0;
4645
static uint32_t g_nonce2_range = 0xffffffff;
@@ -86,7 +85,7 @@ static void encode_pkg(uint8_t *p, int type, uint8_t *buf, unsigned int len)
8685
memcpy(data, buf, len);
8786
break;
8887
case AVA2_P_STATUS:
89-
tmp = read_temp0(temperature0) << 16 | read_temp1(temperature1);
88+
tmp = read_temp0() << 16 | read_temp1();
9089
memcpy(data + 0, &tmp, 4);
9190

9291
tmp = read_fan0() << 16 | read_fan1();
@@ -230,7 +229,7 @@ static int decode_pkg(uint8_t *p, struct mm_work *mw)
230229
case AVA2_P_REQUIRE:
231230
break;
232231
case AVA2_P_SET:
233-
if (read_temp0(temperature0) >= IDLE_TEMP || read_temp1(temperature1) >= IDLE_TEMP)
232+
if (read_temp0() >= IDLE_TEMP || read_temp1() >= IDLE_TEMP)
234233
break;
235234

236235
memcpy(&tmp, data, 4);
@@ -328,6 +327,7 @@ static int get_pkg(struct mm_work *mw)
328327

329328
start = 0;
330329
count = 2;
330+
331331
if (decode_pkg(g_pkg, mw)) {
332332
#ifdef CFG_ENABLE_ACK
333333
send_pkg(AVA2_P_NAK, NULL, 0);
@@ -385,7 +385,7 @@ int main(int argv, char **argc)
385385

386386
uart_init();
387387
debug32("%d:MM-%s\n", g_module_id, MM_VERSION);
388-
debug32("T:%d, %d\n", read_temp0(temperature0), read_temp1(temperature1));
388+
debug32("T:%d, %d\n", read_temp0(), read_temp1());
389389

390390
timer_set(0, IDLE_TIME);
391391
g_new_stratum = 0;
@@ -403,7 +403,7 @@ int main(int argv, char **argc)
403403

404404
wdg_feed((CPU_FREQUENCY / 1000) * 2);
405405
if ((!timer_read(0) && g_new_stratum) ||
406-
(read_temp0(temperature0) >= IDLE_TEMP && read_temp1(temperature1) >= IDLE_TEMP)) {
406+
(read_temp0() >= IDLE_TEMP && read_temp1() >= IDLE_TEMP)) {
407407
g_new_stratum = 0;
408408
g_local_work = 0;
409409
g_hw_work = 0;

firmware/miner.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ void miner_gen_nonce2_work(struct mm_work *mw, uint32_t nonce2, struct work *wor
248248
tmp32 = bswap_32(nonce2);
249249
work->nonce2 = nonce2;
250250

251-
if (mw->coinbase_len > AVA2_P_COINBASE_SIZE) {
251+
if(mw->coinbase_len > AVA2_P_COINBASE_SIZE) {
252252
nonce2_offset_posthash = (mw->nonce2_offset % SHA256_BLOCK_SIZE) + 32;
253253
coinbase_len_posthash = mw->coinbase_len - mw->nonce2_offset + (mw->nonce2_offset % SHA256_BLOCK_SIZE);
254254
memcpy(mw->coinbase + nonce2_offset_posthash, (uint8_t *)(&tmp32), mw->nonce2_size);

firmware/twipwm.c

+5-38
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "defines.h"
1313
#include "io.h"
1414

15+
1516
static struct lm32_twipwm *tp = (struct lm32_twipwm *)TWIPWM_BASE;
1617

1718
static void twi_start(void)
@@ -119,46 +120,12 @@ void adjust_fan(uint32_t pwm)
119120
write_pwm(value);
120121
}
121122

122-
uint16_t read_temp0(uint16_t *temperature)
123+
uint16_t read_temp0()
123124
{
124-
int i;
125-
uint32_t sum = 0;
126-
uint16_t min = temperature[0];
127-
uint16_t max = temperature[0];
128-
uint16_t temp[10] = {0};
129-
130-
memcpy(temp, temperature + 1, 9 * sizeof(uint16_t));
131-
temp[9] = (twi_read_2byte(LM32_TWI_REG_TEMP0) >> 4) / 16;
132-
memcpy(temperature, temp, 10 * sizeof(uint16_t));
133-
for(i = 0; i < 10; i++)
134-
{
135-
if(max < temperature[i])
136-
max = temperature[i];
137-
if(min > temp[i])
138-
min = temperature[i];
139-
sum = sum + temperature[i];
140-
}
141-
return (uint16_t)((sum - max - min) / 8);
125+
return (twi_read_2byte(LM32_TWI_REG_TEMP0) >> 4) / 16;
142126
}
143127

144-
uint16_t read_temp1(uint16_t *temperature)
128+
uint16_t read_temp1()
145129
{
146-
int i;
147-
uint32_t sum = 0;
148-
uint16_t min = temperature[0];
149-
uint16_t max = temperature[0];
150-
uint16_t temp[10] = {0};
151-
152-
memcpy(temp, temperature + 1, 9 * sizeof(uint16_t));
153-
temp[9] = (twi_read_2byte(LM32_TWI_REG_TEMP1) >> 4) / 16;
154-
memcpy(temperature, temp, 10 * sizeof(uint16_t));
155-
for(i = 0; i < 10; i++)
156-
{
157-
if(max < temperature[i])
158-
max = temperature[i];
159-
if(min > temp[i])
160-
min = temperature[i];
161-
sum = sum + temperature[i];
162-
}
163-
return (uint16_t)((sum - max - min) / 8);
130+
return (twi_read_2byte(LM32_TWI_REG_TEMP1) >> 4) / 16;
164131
}

firmware/twipwm.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ void wdg_feed(uint32_t value);
2020
uint32_t read_fan0();
2121
uint32_t read_fan1();
2222

23-
uint16_t read_temp0(uint16_t *temperature);
24-
uint16_t read_temp1(uint16_t *temperature);
23+
uint16_t read_temp0();
24+
uint16_t read_temp1();
2525

2626
void adjust_fan(uint32_t pwm);
2727
void reset();

0 commit comments

Comments
 (0)