Ejemplo n.º 1
0
HANDLE
open_dev()
/*++
Routine Description:

    Called by dumpUsbConfig() to open an instance of our device

Arguments:

    None

Return Value:

    Device handle on success else NULL

--*/
{
    HANDLE hDEV = OpenUsbDevice( (LPGUID)&GUID_CLASS_USBSAMP_USB, 
                                 completeDeviceName);

    if (hDEV == INVALID_HANDLE_VALUE) {
        printf("Failed to open (%s) = %d", completeDeviceName, GetLastError());
    } else {
        printf("DeviceName = (%s)\n", completeDeviceName);
    }           

    return hDEV;

}
Ejemplo n.º 2
0
BOOL
GetUsbDeviceFileName( 
    __in LPGUID  pGuid, 
    __in char   *outNameBuf
    )
/*++
Routine Description:

    Given a ptr to a driver-registered GUID, give us a string with the device name
    that can be used in a CreateFile() call.
    Actually briefly opens and closes the device and sets outBuf if successfull;
    returns FALSE if not

Arguments:

    pGuid:      ptr to GUID registered by the driver itself
    outNameBuf: the generated zero-terminated name for this device

Return Value:

    TRUE on success else FALSE

--*/
{
    HANDLE hDev = OpenUsbDevice( pGuid, outNameBuf );

    if ( hDev != INVALID_HANDLE_VALUE ) {
        CloseHandle( hDev );
        return TRUE;
    }
    return FALSE;
}
Ejemplo n.º 3
0
int main(int argc, char* argv[])
	{
	PrintHello();

	if (ProcessCmdLine(argc, argv) != 0)
		return -1;

	OpenUsbDevice();

	if (dwRC == USBIO_ERR_SUCCESS)
		{
		GetDeviceDescriptor();
		}
	if (dwRC == USBIO_ERR_SUCCESS)
		{
		GetConfigurationDescriptor();
		}
	if (dwRC == USBIO_ERR_SUCCESS)
		{
		GetStringDescriptor();
		}
	if (dwRC == USBIO_ERR_SUCCESS)
		{
		SetConfiguration();
		}
	if (dwRC == USBIO_ERR_SUCCESS)
		{
		// In order to give the USB device-side program (t_usb)
		// enough time after getting configured to carry out
		// some device tests, we wait here for a short while
		// before proceeding:
		Delay(2000);
		GetConfigurationInfo();
		}
	if (dwRC == USBIO_ERR_SUCCESS)
		{
		OpenPipes();
		}
	if (dwRC == USBIO_ERR_SUCCESS)
		{
		ExchangeVersions();
		}
	if (dwRC == USBIO_ERR_SUCCESS)
		{
		DoTransfers();
		}
	if (dwRC == USBIO_ERR_SUCCESS)
		{
		ClosePipes();
		}

	CloseUsbDevice();

	return 0;
	}
Ejemplo n.º 4
0
/*
This�entry�is�called each�time�the�user�specifies�that�the�audio�data�input should be received
through�the�hardware�managed�by�this�DLL�or,�if�still�using�the�sound�card�for�this,�that�the�
DLL�must�activate�control�of�the�external�hardware.�It�can�be�used�by�the�DLL�itself�for�delayed
init�tasks,�like,�e.g.,�the�display�of�its�own�GUI,�if�the�DLL�has�one.�
*/
bool DLL OpenHW(void) 
{ 
	// Find the busses and devices on the USB connection.
    usb_init();
    usb_find_busses();
    usb_find_devices();

	// Find the usb device and open it.
	handle = OpenUsbDevice(I2C_TINY_USB_VID, I2C_TINY_USB_PID);
	if (handle != null)
	{
		SI5351_Init();
        SI5351_OutputDisable(0);
        SI5351_OutputDisable(1);
		m_outputEnabled = false;
	}
	return (handle != null); 
}