Skip to content

Commit

Permalink
Merge pull request #7 from ThyMYthOS/vendor-product
Browse files Browse the repository at this point in the history
Make idVendor, idProduct and bcdDevice configurable
  • Loading branch information
Fabien-Chouteau authored Feb 14, 2024
2 parents 57d2042 + 22dab80 commit 3f45e90
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/usb-device.adb
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ package body USB.Device is
Manufacturer : USB_String;
Product : USB_String;
Serial_Number : USB_String;
Max_Packet_Size : Control_Packet_Size)
Max_Packet_Size : Control_Packet_Size;
Vendor_Id : UInt16 := 16#6666#;
Product_Id : UInt16 := 16#4242#;
Bcd_Device : UInt16 := 16#0121#)
return Init_Result
is
use System;
Expand Down Expand Up @@ -378,6 +381,10 @@ package body USB.Device is

This.Initializing := null;

This.Vendor_Id := Vendor_Id;
This.Product_Id := Product_Id;
This.Bcd_Device := Bcd_Device;

-- Register mendatory strings
This.Manufacturer_Str := This.Register_String (Manufacturer);
This.Product_Str := This.Register_String (Product);
Expand Down Expand Up @@ -455,9 +462,9 @@ package body USB.Device is
bDeviceSubClass => 0,
bDeviceProtocol => 0,
bMaxPacketSize0 => UInt8 (This.Max_Packet_Size),
idVendor => 16#6666#,
idProduct => 16#4242#,
bcdDevice => 16#0121#,
idVendor => This.Vendor_Id,
idProduct => This.Product_Id,
bcdDevice => This.Bcd_Device,

-- String IDs
iManufacturer => This.Manufacturer_Str,
Expand Down
9 changes: 8 additions & 1 deletion src/usb-device.ads
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ package USB.Device is
Manufacturer : USB_String;
Product : USB_String;
Serial_Number : USB_String;
Max_Packet_Size : Control_Packet_Size)
Max_Packet_Size : Control_Packet_Size;
Vendor_Id : UInt16 := 16#6666#;
Product_Id : UInt16 := 16#4242#;
Bcd_Device : UInt16 := 16#0121#)
return Init_Result
with Post => (if Initialize'Result = Ok then This.Initialized);

Expand Down Expand Up @@ -239,6 +242,10 @@ private
String_Buffer : String (1 .. Max_Total_String_Chars);
String_Indexes : String_Info_Array;

Vendor_Id : UInt16;
Product_Id : UInt16;
Bcd_Device : UInt16;

Manufacturer_Str : String_Id := Invalid_String_Id;
Product_Str : String_Id := Invalid_String_Id;
Serial_Str : String_Id := Invalid_String_Id;
Expand Down

0 comments on commit 3f45e90

Please sign in to comment.