1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-22 20:44:19 +00:00

Abstract out flushing of interrupt reads in BF1 devices.

This commit is contained in:
Con Kolivas 2013-09-27 11:13:38 +10:00
parent 8e4909f8d5
commit 59b33c1a58

View File

@ -27,12 +27,17 @@ static void bitfury_empty_buffer(struct cgpu_info *bitfury)
} while (amount);
}
static void bitfury_open(struct cgpu_info *bitfury)
static void bitfury_empty_intbuf(struct cgpu_info *bitfury)
{
char buf[8];
int amount;
usb_read_ii(bitfury, 0, buf, 8, &amount, C_BF1_IFLUSH);
}
static void bitfury_open(struct cgpu_info *bitfury)
{
bitfury_empty_intbuf(bitfury);
/* Magic open sequence */
usb_transfer(bitfury, 0x21, 0x22, 0x0003, 0, C_BF1_OPEN);
bitfury_empty_buffer(bitfury);
@ -40,13 +45,10 @@ static void bitfury_open(struct cgpu_info *bitfury)
static void bitfury_close(struct cgpu_info *bitfury)
{
char buf[8];
int amount;
bitfury_empty_buffer(bitfury);
/* Magic close sequence */
usb_transfer(bitfury, 0x21, 0x22, 0, 0, C_BF1_CLOSE);
usb_read_ii(bitfury, 0, buf, 8, &amount, C_BF1_IFLUSH);
bitfury_empty_intbuf(bitfury);
bitfury_empty_buffer(bitfury);
usb_transfer(bitfury, 0x23, 0x08, 0x9053, 1, C_BF1_CLOSE);
bitfury_empty_buffer(bitfury);