USB.Device

Entities

Simple Types

Interface Types

Tagged Types

Access Types

Subtypes

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. -- -- ----------------------------------------------------------------------------

Any_USB_Device_Class

type Any_USB_Device_Class is access all USB_Device_Class'Class;

Class_Index

subtype Class_Index is UInt8;

Configure

function Configure (This  : in out USB_Device_Class;
                    UDC   : in out USB_Device_Controller'Class;
                    Index : UInt16)
                    return Setup_Request_Answer
Parameters
This
UDC
Index
Return Value

Controller

function Controller (This : USB_Device_Stack)
                     return not null Any_USB_Device_Controller
Parameters
This
Return Value

Fill_Config_Descriptor

procedure Fill_Config_Descriptor (This : in out USB_Device_Class;
                                  Data :    out UInt8_Array)
Parameters
This
Data

Get_Class_Info

procedure Get_Class_Info
  (This                     : in out USB_Device_Class;
   Number_Of_Interfaces     :    out Interface_Id;
   Config_Descriptor_Length :    out Natural)
Parameters
This
Number_Of_Interfaces
Config_Descriptor_Length

Init_Result

type Init_Result is (Ok, Not_Enough_EPs, Not_Enough_EP_Buffer);
Enumeration Literal
Ok
Not_Enough_EPs
Not_Enough_EP_Buffer

Initialize

function Initialize (This                 : in out USB_Device_Class;
                     Dev                  : in out USB_Device_Stack'Class;
                     Base_Interface_Index :        Interface_Id)
                     return Init_Result
Parameters
This
Dev
Base_Interface_Index
Return Value

Initialize

function Initialize
  (This            : in out USB_Device_Stack;
   Controller      : not null Any_USB_Device_Controller;
   Manufacturer    : USB_String;
   Product         : USB_String;
   Serial_Number   : USB_String;
   Max_Packet_Size : Control_Packet_Size;
   Vendor_Id       : UInt16 := 16#6666#;
   Product_Id      : UInt16 := 16#4242#;
   Bcd_Device      : UInt16 := 16#0121#)
   return Init_Result
Parameters
This
Controller
Manufacturer
Product
Serial_Number
Max_Packet_Size
Vendor_Id
Product_Id
Bcd_Device
Return Value

Initialized

function Initialized (This : USB_Device_Stack) return Boolean
Parameters
This
Return Value

Poll

procedure Poll (This : in out USB_Device_Stack)
Parameters
This

Register_Class

function Register_Class (This  : in out USB_Device_Stack;
                         Class : not null Any_USB_Device_Class)
                         return Boolean

Return False if there is no space left to register the class

Parameters
This
Class
Return Value

Register_String

function Register_String (This : in out USB_Device_Stack;
                          Str  : USB_String)
                          return String_Id

Register a USB string

Parameters
This
Str
Return Value

The USB String descriptor must fit in the control buffer, this is constraint on the length string that can be used in the device.

Request_Buffer

function Request_Buffer (This : in out USB_Device_Stack;
                         EP   :        EP_Addr;
                         Len  :        Packet_Size)
                         return System.Address

Allocate a buffer for the corresponding End-Point. This buffer should then be used by the class for IN or OUT transfers depending on the given EP address.

Return Null_Address if resquest fails (e.g. no memory available).

Parameters
This
EP
Len
Return Value

Request_Endpoint

function Request_Endpoint (This : in out USB_Device_Stack;
                           Typ  :        EP_Type;
                           EP   :    out EP_Id)
                           return Boolean

Allocate a non-control End-Point to be used by the class

Parameters
This
Typ
EP
Return Value

Reset

procedure Reset (This : in out USB_Device_Stack)
Parameters
This

Setup_Read_Request

function Setup_Read_Request (This  : in out USB_Device_Class;
                             Req   : Setup_Data;
                             Buf   : out System.Address;
                             Len   : out Buffer_Len)
                             return Setup_Request_Answer
Parameters
This
Req
Buf
Len
Return Value

Setup_Write_Request

function Setup_Write_Request (This  : in out USB_Device_Class;
                              Req   : Setup_Data;
                              Data  : UInt8_Array)
                              return Setup_Request_Answer
Parameters
This
Req
Data
Return Value

Start

procedure Start (This : in out USB_Device_Stack)
Parameters
This

Transfer_Complete

procedure Transfer_Complete (This : in out USB_Device_Class;
                             UDC  : in out USB_Device_Controller'Class;
                             EP   :        EP_Addr;
                             CNT  :        Packet_Size)
Parameters
This
UDC
EP
CNT

USB_Device_Class

type USB_Device_Class is limited interface;

USB_Device_Stack

type USB_Device_Stack (Max_Classes : Class_Index) is tagged private;
Record fields
Max_Classes