5.
Functions to open and close Devices
hid_OpenDevice
This function opens a device for further access by USB. Please do not use this
function to open USB_14ADDA or USB_16ADDA.
Declaration
HANDLE hid_OpenDevice ( DWORD device_type,
DWORD device_id );
Parameters
device_type
The type of the device to open.
device_id
Device's id on the Board.
For more information, please see “Device Type Table & ID Table” following below.
Return value
A valid handle representing the device, or INVALID_HANDLE_VALUE (-1) if an error occurred. For
USB_STARTER, there is no ID selection and device_id = 0
Example
HANDLE hDevice = hid_OpenDevice(Device Type, Device Index); if (hDevice == INVALID_
HANDLE_VALUE)
{
MessageBox (NULL,“Open Failed!“,“Error“,MB_OK);
}
----------------------------------------------------------------------------------------------------------------------------------
hid_CloseDevice
This function closes a device by USB.
Declaration
BOOL
hid_CloseDevice (HANDLE hDevice)
Parameters
hDevice A valid device handle.
Return value
TRUE if successful, FALSE otherwise.
Example
hid_CloseDevice(hDevice);