fb:porticula NoPaste
xidusd_usb.bi
Uploader: | ThePuppetMaster |
Datum/Zeit: | 12.12.2013 03:15:12 |
Hinweis: Dieser Quelltext ist Bestandteil des Projekts LINUX XID Userspace Treiber, zu dem es auf FreeBASIC-Portal.de eine Projektseite gibt.
'##############################################################################################################################################################
#inclib "usb"
'##############################################################################################################################################################
#Define USB_CLASS_PER_INTERFACE 0
#Define USB_CLASS_AUDIO 1
#Define USB_CLASS_COMM 2
#Define USB_CLASS_HID 3
#Define USB_CLASS_PRINTER 7
#Define USB_CLASS_PTP 6
#Define USB_CLASS_MASS_STORAGE 8
#Define USB_CLASS_HUB 9
#Define USB_CLASS_DATA 10
#Define USB_CLASS_VENDOR_SPEC &HFF
'##############################################################################################################################################################
#Define EP_IN &H01
#Define EP_OUT &H02
#Define BUF_SIZE 64
'##############################################################################################################################################################
Type usb_endpoint_descriptor
bLength as UByte
bDescriptorType as UByte
bEndpointAddress as UByte
bmAttributes as UByte
wMaxPacketSize as UShort
bInterval as UByte
bRefresh as UByte
bSynchAddress as UByte
extra as UByte Ptr
extralen as Integer
End Type
Type usb_interface_descriptor
bLength as UByte
bDescriptorType as UByte
bInterfaceNumber as UByte
bAlternateSetting as UByte
bNumEndpoints as UByte
bInterfaceClass as UByte
bInterfaceSubClass as UByte
bInterfaceProtocol as UByte
iInterface as UByte
endpoint as usb_endpoint_descriptor Ptr
extra as UByte Ptr
extralen as Integer
End Type
Type usb_interface
altsetting as usb_interface_descriptor Ptr
num_altsetting as Integer
End Type
Type usb_config_descriptor
bLength as UByte
bDescriptorType as UByte
wTotalLength as UShort
bNumInterfaces as UByte
bConfigurationValue as UByte
iConfiguration as UByte
bmAttributes as UByte
MaxPower as UByte
interface as usb_interface Ptr
extra as UByte Ptr
extralen as Integer
End Type
Type usb_device_descriptor
bLength as UByte
bDescriptorType as UByte
bcdUSB as UShort
bDeviceClass as UByte
bDeviceSubClass as UByte
bDeviceProtocol as UByte
bMaxPacketSize0 as UByte
idVendor as UShort
idProduct as UShort
bcdDevice as UShort
iManufacturer as UByte
iProduct as UByte
iSerialNumber as UByte
bNumConfigurations as UByte
End Type
Type usb_bus_ as usb_bus
Type usb_device
next as usb_device Ptr
prev as usb_device Ptr
filename as ZString * 4097
bus as usb_bus_ Ptr
descriptor as usb_device_descriptor
config as usb_config_descriptor Ptr
dev as Any Ptr
devnum as UByte
num_children as UByte
children as usb_device Ptr Ptr
End Type
Type usb_bus
next as usb_bus Ptr
prev as usb_bus Ptr
dirname as ZString * 4097
devices as usb_device Ptr
location as UInteger
root_dev as usb_device Ptr
End Type
Type usb_dev_handle
fd as Integer
bus as usb_bus Ptr
device as usb_device Ptr
config as Integer
interface as Integer
altsetting as Integer
impl_info as Any Ptr
End Type
'##############################################################################################################################################################
extern "c"
Declare Sub usb_init ()
Declare Function usb_find_busses () as Integer
Declare Function usb_find_devices () as Integer
Declare Function usb_get_busses () as usb_bus Ptr
Declare Function usb_open (dev as usb_device Ptr) as usb_dev_handle Ptr
Declare Function usb_close (devhandle as usb_dev_handle Ptr) as Integer
Declare Function usb_get_string_simple (devhandle as usb_dev_handle Ptr, index as Integer, buf as ZString Ptr, buflen as Integer) as Integer
Declare Function usb_get_descriptor_by_endpoint (devhandle as usb_dev_handle Ptr, ep as Integer, type as UByte, index as UByte, buf as Any Ptr, size as Integer) as Integer
Declare Function usb_get_descriptor (devhandle as usb_dev_handle Ptr, type as UByte, index as UByte, buf as Any Ptr, size as Integer) as Integer
Declare Function usb_bulk_write (devhandle as usb_dev_handle Ptr, ep as Integer, bytes as Byte Ptr, size as Integer, timeout as Integer) as Integer
Declare Function usb_bulk_read (devhandle as usb_dev_handle Ptr, ep as Integer, bytes as Byte Ptr, size as Integer, timeout as Integer) as Integer
Declare Function usb_interrupt_write (devhandle as usb_dev_handle Ptr, ep as Integer, bytes as Byte Ptr, size as Integer, timeout as Integer) as Integer
Declare Function usb_interrupt_read (devhandle as usb_dev_handle Ptr, ep as Integer, bytes as Byte Ptr, size as Integer, timeout as Integer) as Integer
Declare Function usb_control_msg (devhandle as usb_dev_handle Ptr, requesttype as Integer, request as Integer, value as Integer, index as Integer, bytes as Byte Ptr, size as Integer, timeout as Integer) as Integer
Declare Function usb_set_configuration (devhandle as usb_dev_handle Ptr, configuration as Integer) as Integer
Declare Function usb_claim_interface (devhandle as usb_dev_handle Ptr, interface as Integer) as Integer
Declare Function usb_release_interface (devhandle as usb_dev_handle Ptr, interface as Integer) as Integer
Declare Function usb_set_altinterface (devhandle as usb_dev_handle Ptr, alternate as Integer) as Integer
Declare Function usb_resetep (devhandle as usb_dev_handle Ptr, ep as UInteger) as Integer
Declare Function usb_clear_halt (devhandle as usb_dev_handle Ptr, ep as UInteger) as Integer
Declare Function usb_reset (devhandle as usb_dev_handle Ptr) as Integer
end extern
'##############################################################################################################################################################
Type ControlerType
V_Vendor as UShort
V_Product as UShort
V_Name as String
End Type
Dim Shared G_ControlerC as UInteger = 1
Dim Shared G_ControlerD(1 to G_ControlerC) as ControlerType