USB.HAL.Device

Entities

Simple Types

Record Types

Interface Types

Access Types

Constants

Subprograms

Description

---------------------------------------------------------------------------- -- Copyright (C) 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_Controller

type Any_USB_Device_Controller is access all USB_Device_Controller'Class;

Early_Address

function Early_Address (This : USB_Device_Controller) return Boolean

This function should return True if Set_Address must be called during the processing of the SET_ADDRESS setup request instead of at the end of the setup request. For some reason this is required for the USB controller of the STM32F series.

Parameters
This
Return Value

EP_Ready_For_Data

procedure EP_Ready_For_Data (This    : in out USB_Device_Controller;
                             EP      :        EP_Id;
                             Max_Len :        Packet_Size;
                             Ready   :        Boolean := True)

Max_Len has to te less than or equal to the requested buffer size. The transfered will be written to the previously requested EP buffer (see Request_Buffer).

Parameters
This
EP
Max_Len
Ready

EP_Send_Packet

procedure EP_Send_Packet (This : in out USB_Device_Controller;
                          Ep   :        EP_Id;
                          Len  :        Packet_Size)

Len has to te less than or equal to the requested buffer size. The data to transfer is read from the previously requested EP buffer (see Request_Buffer).

Parameters
This
Ep
Len

EP_Setup

procedure EP_Setup (This : in out USB_Device_Controller;
                    EP   :        EP_Addr;
                    Typ  :        EP_Type)

Setup the given End-Point for the given type of transfer

Parameters
This
EP
Typ

EP_Stall

procedure EP_Stall (This : in out USB_Device_Controller;
                    EP   :        EP_Addr;
                    Set  :        Boolean := True)
Parameters
This
EP
Set

Img

function Img (Evt : UDC_Event) return String
Parameters
Evt
Return Value

Initialize

procedure Initialize (This : in out USB_Device_Controller)
Parameters
This

No_Event

No_Event : constant UDC_Event := (Kind => None);

Poll

function Poll (This : in out USB_Device_Controller) return UDC_Event
Parameters
This
Return Value

Request_Buffer

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

Allocate a buffer for the given End-Point, either from RAM or interal USB Controller memory depending on the controller. UDC must keep track of the return address to perform IN/OUT transfers (see EP_Write_Packet and EP_Ready_For_Data).

Parameters
This
Ep
Len
Return Value

Reset

procedure Reset (This : in out USB_Device_Controller)

Called when the host resets the device

Parameters
This

Set_Address

procedure Set_Address (This : in out USB_Device_Controller;
                       Addr :        UInt7)
Parameters
This
Addr

Start

procedure Start (This : in out USB_Device_Controller)
Parameters
This

UDC_Event

type UDC_Event (Kind : UDC_Event_Kind := None) is record
   case Kind is
      when Setup_Request =>
         Req    : Setup_Data;
         Req_EP : EP_Id;
      when Transfer_Complete =>
         EP   : EP_Addr;
         BCNT : Packet_Size;
      when others => null;
   end case;
end record;
Record fields
Kind
Req
Req_EP
EP
BCNT

UDC_Event_Kind

type UDC_Event_Kind is (None,
                        Reset,
                        Setup_Request,
                        Transfer_Complete);
Enumeration Literal
None
Reset
Setup_Request
Transfer_Complete

USB_Device_Controller

type USB_Device_Controller is interface;

Valid_EP_Id

function Valid_EP_Id (This : in out USB_Device_Controller;
                      EP   :        EP_Id)
                      return Boolean

Return True if the given EP is valid for this UDC. This is used by the stack to know the number of EPs available.

Parameters
This
EP
Return Value