func configureDevice(device *usb.Device, conf *usb.ConfigurationDescriptor, u2fHandler *u2fhid.Handler) error {
	device.Setup = hidSetup(device)
	id, err := addInterface(device, conf)
	if err != nil {
		return fmt.Errorf("cannot add U2F USB Interface, %w", err)
	}
	endpoints := addEndpoints(id)
	endpoints.in.Function = u2fHandler.Tx
	endpoints.out.Function = u2fHandler.Rx
	addHIDClassDescriptor(id)
	device.Qualifier = &usb.DeviceQualifierDescriptor{}
	device.Qualifier.SetDefaults()
	device.Qualifier.NumConfigurations = uint8(len(device.Configurations))
	return nil
}
configureDevice configures device to use hidSetup Setup function, and adds an HID InterfaceDescriptor to conf
along with the needed Endpoints.
package fidati
import (
	"bytes"
	"encoding/binary"
	"errors"
	"fmt"
	"github.com/f-secure-foundry/tamago/soc/imx6/usb"
	"github.com/gsora/fidati/internal/flog"
	"github.com/gsora/fidati/u2fhid"
)
const (
	hidRequestSetIdle           = 10
	hidRequestTypeGetDescriptor = 0x21
	descriptorTypeGetReport     = 0x22
)
type hidDescriptor struct {
	Length               uint8
	Type                 uint8
	bcdHID               uint16
	CountryCode          uint8
	NumDescriptors       uint8
	ReportDescriptorType uint8
	DescriptorLength     uint16
}
func (d *hidDescriptor) setDefaults() {
	d.Length = 0x09
	d.Type = 0x21
	d.bcdHID = 0x101
}
func (d *hidDescriptor) bytes() []byte {
	buf := new(bytes.Buffer)
	binary.Write(buf, binary.LittleEndian, d)
	return buf.Bytes()
}