/* Closes the connection with the USB bulk device and frees all the related handles.  */
static void UblClose(void)
/* Closes the connection with the USB bulk device and frees all the related handles.  */
static void UblClose(void)
{
  if (bulkUsbDev.evReader != NULL)
  {
    (void)CloseHandle(bulkUsbDev.evReader);
    bulkUsbDev.evReader = NULL;
  }
  if (bulkUsbDev.hWinUSBDev != NULL)
  {
    (void)WinUsb_Free(bulkUsbDev.hWinUSBDev);
    bulkUsbDev.hWinUSBDev = NULL;
  }
  bulkUsbDev.pipeBulkOut = INVALID_PIPE_ID;
  bulkUsbDev.pipeBulkIn = INVALID_PIPE_ID;
  if (bulkUsbDev.hDev != NULL)
  {
    (void)CloseHandle(bulkUsbDev.hDev);
    bulkUsbDev.hDev = NULL;
  }
}