USB

Entities

Simple Types

Array Types

Record Types

Subtypes

Constants

Subprograms

Description

---------------------------------------------------------------------------- -- Copyright (C) 2018-2021, AdaCore -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are -- met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in -- the documentation and/or other materials provided with the -- distribution. -- 3. Neither the name of the copyright holder nor the names of its -- contributors may be used to endorse or promote products derived -- from this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- ----------------------------------------------------------------------------

Buffer_Len

subtype Buffer_Len is System.Storage_Elements.Storage_Offset;

Control_Buffer_Size

Control_Buffer_Size : constant := Usb_Embedded_Config.Control_Buffer_Size;

Control_Packet_Size

subtype Control_Packet_Size is Packet_Size range 0 .. 64;

Data_Phase_Transfer_Direction

type Data_Phase_Transfer_Direction is (Host_To_Device,
                                       Device_To_Host)
  with Size => 1;
Enumeration Literal
Host_To_Device
Device_To_Host

Device_Descriptor

type Device_Descriptor is record
   bLength            : UInt8;
   bDescriptorType    : UInt8;
   bcdUSB             : UInt16;
   bDeviceClass       : UInt8;
   bDeviceSubClass    : UInt8;
   bDeviceProtocol    : UInt8;
   bMaxPacketSize0    : UInt8;
   idVendor           : UInt16;
   idProduct          : UInt16;
   bcdDevice          : UInt16;
   iManufacturer      : String_Id;
   iProduct           : String_Id;
   iSerialNumber      : String_Id;
   bNumConfigurations : UInt8;
end record with Pack;
Record fields
bLength
bDescriptorType
bcdUSB
bDeviceClass
bDeviceSubClass
bDeviceProtocol
bMaxPacketSize0
idVendor
idProduct
bcdDevice
iManufacturer
iProduct
iSerialNumber
bNumConfigurations

Device_Qualifier

type Device_Qualifier is record
   bLength            : UInt8;
   bDescriptorType    : UInt8;
   bcdUSB             : UInt16;
   bDeviceClass       : UInt8;
   bDeviceSubClass    : UInt8;
   bDeviceProtocol    : UInt8;
   bMaxPacketSize0    : UInt8;
   bNumConfigurations : UInt8;
   bReserved          : UInt8;
end record with Pack;
Record fields
bLength
bDescriptorType
bcdUSB
bDeviceClass
bDeviceSubClass
bDeviceProtocol
bMaxPacketSize0
bNumConfigurations
bReserved

EP_Addr

type EP_Addr is record
   Num : EP_Id;
   Dir : EP_Dir;
end record;
Record fields
Num
Dir

EP_Dir

type EP_Dir is (EP_In, EP_Out);
Enumeration Literal
EP_In
EP_Out

EP_Id

subtype EP_Id is UInt4;

EP_Type

type EP_Type is (Control, Isochronous, Bulk, Interrupt);
Enumeration Literal
Control
Isochronous
Bulk
Interrupt

Img

function Img (EP : EP_Addr) return String
Parameters
EP
Return Value

Img

function Img (D : Setup_Data) return String
Parameters
D
Return Value

Interface_Id

type Interface_Id is new UInt8;

Invalid_String_Id

Invalid_String_Id : constant String_Id := 0;

Lang_ID

type Lang_ID is new UInt16;

Max_Strings

Max_Strings : constant := Usb_Embedded_Config.Max_Strings;

Max_Total_String_Chars

Max_Total_String_Chars : constant := Usb_Embedded_Config.String_Buffer_Size;

Packet_Size

type Packet_Size is range 0 .. 1024;

Request_Type

type Request_Type is record
   Recipient : Request_Type_Recipient;
   Reserved  : UInt3;
   Typ : Request_Type_Type;
   Dir : Data_Phase_Transfer_Direction;
end record with Pack, Size => 8;
Record fields
Recipient
Reserved
Typ
Dir

Request_Type_Recipient

type Request_Type_Recipient is (Dev, Iface, Endpoint, Other);
Enumeration Literal
Dev
Iface
Endpoint
Other

Request_Type_Type

type Request_Type_Type is (Stand, Class, Vendor, Reserved)
  with Size => 2;
Enumeration Literal
Stand
Class
Vendor
Reserved

Setup_Data

type Setup_Data is record
   RType   : Request_Type;
   Request : UInt8;
   Value   : UInt16;
   Index   : UInt16;
   Length  : UInt16;
end record with Pack, Size => 8 * 8;
Record fields
RType
Request
Value
Index
Length

Setup_Request_Answer

type Setup_Request_Answer is (Handled, Not_Supported, Next_Callback);
Enumeration Literal
Handled
Not_Supported
Next_Callback

String_Descriptor

type String_Descriptor (bLength : UInt8) is record
   bDescriptorType    : UInt8 := 3;
   Str                : USB_String (3 .. bLength);
end record with Pack;
Record fields
bLength
bDescriptorType
Str

String_Descriptor_Zero

type String_Descriptor_Zero is record
   bLength            : UInt8;
   bDescriptorType    : UInt8 := 3;
   Str                : String (1 .. 2);
end record;
Record fields
bLength
bDescriptorType
Str

String_Id

type String_Id is new UInt8;

String_Range

subtype String_Range is UInt8 range 0 .. 253;

The maximum length of a string is limited by the the bLength field of the String Descriptor. This field is one byte: 0 .. 255, but bLength encodes to total size of the descriptor including the bLenght and bDescriptorType fields (one byte each). So the remaining length for string is 255 - 2.

To_USB_String

function To_USB_String (Str : String) return USB_String

Convert Ada ASCII string to USB UTF16 string

Parameters
Str
Return Value

USB_String

type USB_String is array (String_Range range <>) of Character;

Verbose

Verbose : constant Boolean := False;