Fix issue #113 - CPLD update fails on Windows

Using the patch from @supersat
This commit is contained in:
Dominic Spill
2015-07-06 21:25:01 +01:00
parent 9cfa4048e9
commit ce9ad343e0
5 changed files with 21 additions and 24 deletions

View File

@ -345,7 +345,9 @@ extern "C"
typedef enum { typedef enum {
TRANSCEIVER_MODE_OFF = 0, TRANSCEIVER_MODE_OFF = 0,
TRANSCEIVER_MODE_RX = 1, TRANSCEIVER_MODE_RX = 1,
TRANSCEIVER_MODE_TX = 2 TRANSCEIVER_MODE_TX = 2,
TRANSCEIVER_MODE_SS = 3,
TRANSCEIVER_MODE_CPLD_UPDATE = 4
} transceiver_mode_t; } transceiver_mode_t;
void delay(uint32_t duration); void delay(uint32_t duration);

View File

@ -99,6 +99,11 @@ usb_request_status_t usb_vendor_request_set_transceiver_mode(
set_transceiver_mode(endpoint->setup.value); set_transceiver_mode(endpoint->setup.value);
usb_transfer_schedule_ack(endpoint->in); usb_transfer_schedule_ack(endpoint->in);
return USB_REQUEST_STATUS_OK; return USB_REQUEST_STATUS_OK;
case TRANSCEIVER_MODE_CPLD_UPDATE:
usb_endpoint_init(&usb_endpoint_bulk_out);
start_cpld_update = true;
usb_transfer_schedule_ack(endpoint->in);
return USB_REQUEST_STATUS_OK;
default: default:
return USB_REQUEST_STATUS_STALL; return USB_REQUEST_STATUS_STALL;
} }

View File

@ -168,13 +168,6 @@ t_wav_file_hdr wave_file_hdr =
} }
}; };
typedef enum {
TRANSCEIVER_MODE_OFF = 0,
TRANSCEIVER_MODE_RX = 1,
TRANSCEIVER_MODE_TX = 2,
TRANSCEIVER_MODE_SS = 3
} transceiver_mode_t;
static transceiver_mode_t transceiver_mode = TRANSCEIVER_MODE_RX; static transceiver_mode_t transceiver_mode = TRANSCEIVER_MODE_RX;
#define U64TOA_MAX_DIGIT (31) #define U64TOA_MAX_DIGIT (31)

View File

@ -907,22 +907,11 @@ int ADDCALL hackrf_cpld_write(hackrf_device* device,
{ {
const unsigned int chunk_size = 512; const unsigned int chunk_size = 512;
unsigned int i; unsigned int i;
int transferred = 0; int result, transferred = 0;
int result = libusb_release_interface(device->usb_device, 0);
if (result != LIBUSB_SUCCESS) {
return HACKRF_ERROR_LIBUSB;
}
result = set_hackrf_configuration(device->usb_device, USB_CONFIG_CPLD_UPDATE); result = hackrf_set_transceiver_mode(device, TRANSCEIVER_MODE_CPLD_UPDATE);
if( result != LIBUSB_SUCCESS ) if (result != 0)
{
return result; return result;
}
result = libusb_claim_interface(device->usb_device, 0);
if (result != LIBUSB_SUCCESS) {
return HACKRF_ERROR_LIBUSB;
}
for (i = 0; i < total_length; i += chunk_size) for (i = 0; i < total_length; i += chunk_size)
{ {

View File

@ -81,6 +81,14 @@ enum rf_path_filter {
RF_PATH_FILTER_HIGH_PASS = 2, RF_PATH_FILTER_HIGH_PASS = 2,
}; };
typedef enum {
TRANSCEIVER_MODE_OFF = 0,
TRANSCEIVER_MODE_RX = 1,
TRANSCEIVER_MODE_TX = 2,
TRANSCEIVER_MODE_SS = 3,
TRANSCEIVER_MODE_CPLD_UPDATE = 4
} transceiver_mode_t;
typedef struct hackrf_device hackrf_device; typedef struct hackrf_device hackrf_device;
typedef struct { typedef struct {