hwtLib.peripheral.usb.descriptors package¶
Submodules¶
hwtLib.peripheral.usb.descriptors.bundle module¶
- class hwtLib.peripheral.usb.descriptors.bundle.UsbDescriptorBundle(*args, **kwargs)[source]¶
Bases:
list
Container of USB descriptors.
- Variables
compiled_rom – list of bytes for descriptor rom generated from this descriptor bundle
compiled_type_to_addr_and_size – a dictionary mapping the descriptor type to list of tuples address size for a localization of the descriptor in compiled rom
- get_descr_bytes(start_descr_i: int, wLength: int) List[int] [source]¶
Start at the beginning of the descriptor on index start_descr_i and copy specified number of bytes from that location (may overlap to other descriptors as well)
- get_descriptor(descr_t, descr_i: int) Tuple[int, HValue] [source]¶
Get an index of descriptor of a specific type
- Parameters
descr_t – specific type of descriptor
descr_i – index of this descriptor of this specific type (excluding any descriptors of different type)
- get_descriptors_from_rom(descr_t: USB_DESCRIPTOR_TYPE) Tuple[int, int] [source]¶
Get the address and size of descriptor in comiled rom memory
- Parameters
i – index of the decriptor in a list of descriptors of this type to get
- Returns
tuple address, size
- get_endpoint_meta() Tuple[Tuple[Optional[UsbEndpointMeta], Optional[UsbEndpointMeta]]] [source]¶
- class hwtLib.peripheral.usb.descriptors.bundle.UsbEndpointMeta(index: int, dir_: USB_ENDPOINT_DIR, supports_setup: bool = False, supports_bulk: bool = False, supports_interrupt: bool = False, supports_isochronoust: bool = False, max_packet_size: int = 0, buffer_size: Optional[int] = None)[source]¶
Bases:
object
Information about USB endpoint extracted from
UsbDescriptorBundle
- __init__(index: int, dir_: USB_ENDPOINT_DIR, supports_setup: bool = False, supports_bulk: bool = False, supports_interrupt: bool = False, supports_isochronoust: bool = False, max_packet_size: int = 0, buffer_size: Optional[int] = None)[source]¶
hwtLib.peripheral.usb.descriptors.cdc module¶
This file contains a data structures used for communication and configuration of USB CDC UART device. Based on: https://www.silabs.com/documents/public/application-notes/AN758.pdf
- class hwtLib.peripheral.usb.descriptors.cdc.CHAR_FORMAT[source]¶
Bases:
object
- STOP_BIT_1 = 0¶
- STOP_BIT_1_5 = 1¶
- STOP_BIT_2 = 2¶
- class hwtLib.peripheral.usb.descriptors.cdc.CLASS_REQUEST[source]¶
Bases:
object
- GET_LINE_CODING = 33¶
- SET_CONTROL_LINE_STATE = 34¶
- SET_LINE_CODING = 32¶
- class hwtLib.peripheral.usb.descriptors.cdc.PARITY_TYPE[source]¶
Bases:
object
- EVEN = 2¶
- MARK = 3¶
- NONE = 0¶
- ODD = 1¶
- SPACE = 4¶
- class hwtLib.peripheral.usb.descriptors.cdc.USB_CDC_DESCRIPTOR_SUBTYPE[source]¶
Bases:
object
- ABSTRACT_CONTROL_MANAGEMENT = 2¶
- ATM_NETWORKING_FUNCTIONAL = 16¶
- CALL_MANAGEMENT_FUNCTIONAL = 1¶
- CAPI_CONTROL_MANAGEMENT = 14¶
- COUNTRY_SELECTION_FUNCTIONAL = 7¶
- DIRECT_LINE_MANAGEMENT = 3¶
- ETHERNET_NETWORKING_FUNCTIONAL = 15¶
- EXTENSION_UNIT_FUNCTIONAL = 12¶
- HEADER = 0¶
- MULTI_CHANNEL_MANAGEMENT = 13¶
- NETWORK_CHANNEL_TERMINAL = 10¶
- PROTOCOL_UNIT_FUNCTIONAL = 11¶
- TELEPHONE_CALL_AND_LINE_STATE_REPORTING_CAPABILITIES = 5¶
- TELEPHONE_OPERATIONAL_MODES = 8¶
- TELEPHONE_RINGER_FUNCTIONAL = 4¶
- UNION = 6¶
- USB_TERMINAL_FUNCTIONAL = 9¶
- hwtLib.peripheral.usb.descriptors.cdc.get_default_usb_cdc_vcp_descriptors(usbVer='2.0', bMaxPacketSize=64, manufacturerStr: Optional[str] = None, productStr: Optional[str] = None, deviceVer: str = '0.0') UsbDescriptorBundle [source]¶
Generates USB descriptors for USB CDC device which works as a UART (serial)
- hwtLib.peripheral.usb.descriptors.cdc.make_descriptor_functional_abstract_control_management(capability_commFeature: bool, capability_lineCodingAndSerialState: bool, capability_sendBreak: bool, capability_networkConnection: bool)[source]¶
- hwtLib.peripheral.usb.descriptors.cdc.make_descriptor_functional_call_management(supportHandlesCallManagementItself: bool, supportManagementOverDataClassInterface: bool, bDataInterface: int)[source]¶
- hwtLib.peripheral.usb.descriptors.cdc.make_descriptor_functional_union(bMasterInterface: int, bSlaveInterface: List[int])[source]¶
- hwtLib.peripheral.usb.descriptors.cdc.make_usb_line_coding_default(dwDTERate=115200, bCharFormat=0, bParityType=0, bDataBits=8)[source]¶
hwtLib.peripheral.usb.descriptors.cdc_ncm module¶
hwtLib.peripheral.usb.descriptors.hid module¶
- class hwtLib.peripheral.usb.descriptors.hid.USB_HID_COUNTRY_CODE[source]¶
Bases:
object
- ARABIC = 1¶
- BELGIAN = 2¶
- CANADIAN_BILINGUAL = 3¶
- CANADIAN_FRENCH = 4¶
- CZECH_REPUBLIC = 5¶
- DANISH = 6¶
- FINNISH = 7¶
- FRENCH = 8¶
- GERMAN = 9¶
- GREEK = 10¶
- HEBREW = 11¶
- HUNGARY = 12¶
- INTERNATIONAL_ISO = 13¶
- ITALIAN = 14¶
- JAPAN_KATAKANA = 15¶
- KOREAN = 16¶
- LATIN_AMERICAN = 17¶
- NETHERLANDS_DUTCH = 18¶
- NORWEGIAN = 19¶
- NOT_SUPPORTED = 0¶
- PERSIAN_FARSI = 20¶
- POLAND = 21¶
- PORTUGUESE = 22¶
- RUSSIA = 23¶
- SLOVAKIA = 24¶
- SPANISH = 25¶
- SWEDISH = 26¶
- SWISS_FRENCH = 27¶
- SWISS_GERMAN = 28¶
- SWITZERLAND = 29¶
- TAIWAN = 30¶
- TURKISH_F = 35¶
- TURKISH_Q = 31¶
- UK = 32¶
- US = 33¶
- YUGOSLAVIA = 34¶
- class hwtLib.peripheral.usb.descriptors.hid.USB_HID_PROTOCOL[source]¶
Bases:
object
- KEYBOARD = 1¶
- MOUSE = 2¶
- NONE = 0¶
- class hwtLib.peripheral.usb.descriptors.hid.USB_HID_SUBLCASS[source]¶
Bases:
object
- BOOT_INTERFACE = 1¶
- NONE = 0¶
- hwtLib.peripheral.usb.descriptors.hid.make_usb_descriptor_hid(hidVer: str, bCountryCode: USB_HID_COUNTRY_CODE, bNumDescriptors: int, bDescriptorType: USB_DESCRIPTOR_TYPE, wDescriptorLength: int)[source]¶
hwtLib.peripheral.usb.descriptors.std module¶
- class hwtLib.peripheral.usb.descriptors.std.USB_DESCRIPTOR_TYPE[source]¶
Bases:
object
- CONFIGURATION = 2¶
- DEVICE = 1¶
- DEVICE_QUALIFIER = 6¶
- ENDPOINT = 5¶
- FUNCTIONAL = 36¶
- HID = 33¶
- INTERFACE = 4¶
- INTERFACE_POWER = 8¶
- OTHER_SPEED_CONFIGURATION = 7¶
- REPORT = 34¶
- STRING = 3¶
- class hwtLib.peripheral.usb.descriptors.std.USB_DEVICE_CLASS[source]¶
Bases:
object
https://www.usb.org/defined-class-codes
- APPLICATION_SPECIFIC = 254¶
- AUDIO = 1¶
- AUDIO_VIDEO_DEVICE = 16¶
- BILBOARD_DEVICE = 17¶
- CDC_CONTROL = 2¶
- CDC_DATA = 10¶
- CONTENT_SECURITY = 13¶
- DIAGNOSTIC_DEVICE = 220¶
- HID = 3¶
- IMAGE = 6¶
- MASS_STORAGE = 8¶
- MISCELLANEOUS = 239¶
- PERSONAL_HEALTHCARE = 15¶
- PRINTER = 7¶
- SMART_CARD = 11¶
- UNSPECIFIED = 0¶
- USB_HUB = 9¶
- USB_PID = 5¶
- USB_TYPE_C_BRIDGE = 18¶
- VENDOR_SPECIFIC = 255¶
- VIDEO = 14¶
- WIRELESS_CONTROLLER = 224¶
- class hwtLib.peripheral.usb.descriptors.std.USB_ENDPOINT_ATTRIBUTES_SYNCHRONISATION_TYPE[source]¶
Bases:
object
Note only apply to isochronous endpoints.
- ADAPTIVE = 2¶
- ASYNCHRONOUS = 1¶
- NONE = 0¶
- SYNCHRONOUS = 3¶
- class hwtLib.peripheral.usb.descriptors.std.USB_ENDPOINT_ATTRIBUTES_TRANSFER_TYPE[source]¶
Bases:
object
- BULK = 2¶
- CONTROL = 0¶
- INTERRUPT = 3¶
- ISOCHRONOUS = 1¶
- class hwtLib.peripheral.usb.descriptors.std.USB_ENDPOINT_ATTRIBUTES_USAGE_TYPE[source]¶
Bases:
object
- DATA = 0¶
- FEEDBACK = 1¶
- IMPLICIT_FEEDBACK_DATA = 2¶
- RESERVED = 3¶
- class hwtLib.peripheral.usb.descriptors.std.USB_ENDPOINT_DIR[source]¶
Bases:
object
- IN = 1¶
- OUT = 0¶
- hwtLib.peripheral.usb.descriptors.std.make_usb_descriptor_configuration(wTotalLength: int, bNumInterfaces: int, bConfigurationValue: int, iConfiguration: int, remoteWakeup: int = 0, selfPowered: int = 0, bMaxPower: int = 250)[source]¶
- hwtLib.peripheral.usb.descriptors.std.make_usb_descriptor_device(bDeviceClass: USB_DEVICE_CLASS, bDeviceSubClass=0, bDeviceProtocol=255, usbVer: USB_VER = '2.0', bMaxPacketSize=64, idVendor=4660, idProduct=22136, bcdDevice='0.1', iManufacturer=1, iProduct=2, iSerialNumber=0, bNumConfigurations=1)[source]¶
- hwtLib.peripheral.usb.descriptors.std.make_usb_descriptor_device_qualifier(bDeviceClass: USB_DEVICE_CLASS, bDeviceSubClass=0, bDeviceProtocol=255, usbVer: USB_VER = '2.0', bMaxPacketSize=64, bNumConfigurations=1)[source]¶
- hwtLib.peripheral.usb.descriptors.std.make_usb_descriptor_endpoint(bEndpointAddressDir: USB_ENDPOINT_DIR, bEndpointAddress: int, attr_transferType: USB_ENDPOINT_ATTRIBUTES_TRANSFER_TYPE, attr_synchronisationType: USB_ENDPOINT_ATTRIBUTES_SYNCHRONISATION_TYPE, attr_usageType: USB_ENDPOINT_ATTRIBUTES_USAGE_TYPE, wMaxPacketSize: int, bInterval: int)[source]¶
- hwtLib.peripheral.usb.descriptors.std.make_usb_descriptor_interface(bInterfaceNumber: int, bAlternateSetting: int, bNumEndpoints: int, bInterfaceClass: USB_DEVICE_CLASS, bInterfaceSubClass: int, bInterfaceProtocol: int, iInterface: int)[source]¶