USB მოწყობილობების დასტა
სპეციფიკაციები
- USB ვერსია: 1.5.1
- გამოშვების თარიღი: 21 წლის 2025 ივლისი
- სიმარტივის SDK ვერსია: 2025.6.1
პროდუქტი დასრულდაview
Silicon Labs-ის USB მოწყობილობების დასტა უზრუნველყოფს მრავალმხრივ და
მარტივი USB კავშირი IoT პროექტებისთვის, რაც ხელს უწყობს
communication between network co-processors and hosts.
მახასიათებლები
- Efficient USB device stack
- Ideal for IoT projects
- Support for communication between network co-processors and
მასპინძლებს
პროდუქტის გამოყენების ინსტრუქცია
USB Device Configuration
Configure the USB device settings according to your project
requirements by referring to the USB Device Configuration section
დოკუმენტაციაში.
USB Device Programming Guide
მიჰყევით USB მოწყობილობის პროგრამირების სახელმძღვანელოს, რათა გაიგოთ, თუ როგორ
პროგრამირება და USB მოწყობილობასთან ურთიერთქმედება სხვადასხვა მიზნით
აპლიკაციები.
USB Device Classes
USB მოწყობილობების კლასების განყოფილება გთავაზობთ დამატებით ინფორმაციასview სხვადასხვა
კლასები, როგორიცაა CDC ACM, HID, MSC SCSI და Vendor Class. აირჩიეთ
შესაბამისი კლასი თქვენი მოწყობილობის ფუნქციონალურობის მიხედვით.
USB Device Troubleshooting
თუ USB მოწყობილობასთან დაკავშირებით რაიმე პრობლემა შეგექმნათ, იხილეთ
USB მოწყობილობის პრობლემების გადაჭრის და გამართვის სექცია
რჩევები.
Microsoft Windows OS USB Host
If you are using the USB device with a Microsoft Windows OS USB
მასპინძელო, აუცილებლად დაიცავი მოცემული ინსტრუქციები
documentation for seamless integration.
FAQ
კითხვა: რა არის გავრცელებული ყოფილიamples of devices I can build using
this USB stack?
A: The USB stack allows you to build devices such as
USB-to-serial adapters, mice or keyboards, removable storage
devices, and custom devices.
Q: Are there any specific software requirements for using this
USB device stack?
A: Compatible software includes Simplicity SDK, Simplicity
Studio, Simplicity Commander, GCC (The GNU Compiler Collection),
IAR Embedded Workbench for ARM, and IAR EWARM.
Universal Serial Bus USB
Universal Serial Bus USB
USB გადართვაview დასრულდაview
Release Notes USB
სპეციფიკაციები და მახასიათებლებიview
USB Device Configuration Overview
USB Device Programming Guide Overview
USB Device Classes Overview CDC ACM კლასის გადაჭარბებაview HID Class Overview MSC SCSI Class Overview გამყიდველის კლასის გადაჭარბებაview
USB API API Documentation USB Device API USB Device ACM API a sl_usbd_cdc_ cm_line_coding_t sl_usbd_cdc_acm_callbacks_t USB Device CDC API a sl_usbd_cdc_subcl ss_driver_t USB Device Core API
sl_usbd_device_config_t sl_usbd_setup_req_t
a sl_usbd_cl ss_driver_t USB Device HID API
sl_usbd_hid_callbacks_t USB Device MSC API
a sl_usbd_msc_subcl ss_driver_t USB Device MSC SCSI API
sl_usbd_msc_scsi_callbacks_t
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
1/174
Universal Serial Bus USB
sl_usbd_msc_scsi_lun_ პი
sl_usbd_msc_scsi_lun_info sl_usbd_msc_scsi_lun
USB მოწყობილობის მომწოდებლის API sl_usbd_vendor_callbacks_t
API Documentation USB Device Troubleshooting
დასრულდაview Microsoft Windows OS USB Host
დასრულდაview
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
2/174
დასრულდაview
დასრულდაview
USB მოწყობილობა
USB კომპიუტერული სისტემების ისტორიაში ერთ-ერთი ყველაზე წარმატებული საკომუნიკაციო ინტერფეისია და წარმოადგენს კომპიუტერის პერიფერიული მოწყობილობების დასაკავშირებლად დე ფაქტო სტანდარტს. Silicon Labs-ის USB მოწყობილობების დასტა არის USB მოწყობილობის მოდული, რომელიც სპეციალურად ჩაშენებული სისტემებისთვისაა შექმნილი. ნულიდან შექმნილი Silicon Labs-ის ხარისხით, მასშტაბირებითა და საიმედოობით, მან გაიარა მკაცრი ვალიდაციის პროცესი USB 2.0 სპეციფიკაციასთან შესაბამისობაში მოსაყვანად. ეს დოკუმენტაცია აღწერს, თუ როგორ უნდა მოხდეს Silicon Labs-ის USB მოწყობილობების დასტის ინიციალიზაცია, გაშვება და გამოყენება. იგი განმარტავს სხვადასხვა კონფიგურაციის მნიშვნელობებს და მათ გამოყენებას. ის ასევე მოიცავს...view of the technology, types of configuration possibilities, implementation procedures, and exampყველა ხელმისაწვდომი კლასისთვის ტიპიური გამოყენების მცირე რაოდენობა.
To help you understand the USB concepts quickly, the documentation features many examples of USB with basic functions. These examples will provide you with a framework that allows you to build devices quickly. These exampმათში შედის:
USB-to-serial adapter (Communications Device Class) Mouse or keyboard (Human Interface Device Class) Removable storage device (Mass Storage Class) Custom device (Vendor Class)
შემდეგი არის დასრულდაview of the documentation sections:
Specifications and Features USB Device Configuration USB Device Programming Guide USB Device Classes
CDC ACM Class HID Class MSC SCSI Class Vendor Class USB Device Troubleshooting Microsoft Windows OS USB Host
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
3/174
USB
USB
USB Version 1.5.1 July 21, 2025 – Release Notes
Simplicity SDK ვერსია 2025.6.1
Silicon Labs-ის ეფექტური USB მოწყობილობების დასტა გთავაზობთ მრავალმხრივ, მარტივად გამოსაყენებელ USB კავშირს, რომელიც იდეალურია IoT პროექტებისთვის, მათ შორის ქსელის თანაპროცესორებსა და ჰოსტებს შორის კომუნიკაციისთვის. ადრინდელი ვერსიების სანახავად დააჭირეთ აქ.
გამოშვების შეჯამება
ძირითადი მახასიათებლები | API ცვლილებები | შეცდომების გამოსწორება | ჩიპის გააქტიურება
ძირითადი მახასიათებლები
Underlying platform changes only.
API ცვლილებები
არცერთი.
შეცდომების გამოსწორება
არცერთი.
ჩიპის ჩართვა
არცერთი.
ძირითადი მახასიათებლები
New Features | Enhancements | Removed Features | Deprecated Features
ახალი ფუნქციები
არცერთი.
გაძლიერებები
Underlying platform changes only.
Removed Features
არცერთი.
მოძველებული თვისებები
არცერთი.
API ცვლილებები
New APIs | Modified APIs | Removed APIs | Deprecated APIs
ახალი API
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
4/174
USB
არცერთი.
Modified APIs
არცერთი.
წაშლილი API-ები
არცერთი.
მოძველებული API-ები
არცერთი.
შეცდომების გამოსწორება
არცერთი.
ჩიპის ჩართვა
არცერთი.
განაცხადი მაგampლე ცვლილებები
ახალი ყოფილიamples | მოდიფიცირებული ყოფილიamples | Removed Examples | Deprecated Examples
ახალი ყოფილიamples
არცერთი.
შეცვლილია მაგamples
არცერთი.
ამოღებულია ეგamples
არცერთი.
Deprecated Examples
არცერთი.
Impact of Release Changes
Impact Statements | Migration Guide
Impact Statements
არცერთი.
მიგრაციის გზამკვლევი
არცერთი.
ცნობილი საკითხები და შეზღუდვები
არცერთი.
ამ გამოშვების გამოყენება
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
5/174
USB
What’s in the Release? | Compatible Software | Installation and Use | Help and Feedback
What’s in the Release?
USB Device Stack Application Examples
თავსებადი პროგრამული უზრუნველყოფა
პროგრამული უზრუნველყოფა
Simplicity SDK Simplicity Studio Simplicity Commander GCC GNU კომპილატორების კოლექცია) IAR ჩაშენებული სამუშაო მაგიდა ARM IAR EWARM-ისთვის
თავსებადი ვერსია ან ვარიანტი
2025.6.0 5.11.0 1.18.2 (provided with Simplicity Studio) 12.2.1 (provided with Simplicity Studio) 9.40.1 (provided with Simplicity Studio)
ინსტალაცია და გამოყენება
To kick start your development see our:
USB Device Programming Guide. API Documentation.
For information about Secure Vault Integration, see Secure Vault.
ხელახლაview Security and Software Advisory notifications and manage your notification preferences:
ò Go to https://community.silabs.com/. ó Log in with your account credentials. ô Click your profile icon in the upper-right corner of the page.
õ Select Notifications from the dropdown menu. ö In the Notifications section, go to the My Product Notifications tab to review historical Security and Software Advisory
შეტყობინებები
÷ To manage your preferences, use the Manage Notifications tab to customize which product updates and advisories you
მიღება.
For recommended configuration settings, see here.
To learn more about the software in this release, dive into our online documentation.
დახმარება და გამოხმაურება
Contact Silicon Labs Support. To use our Ask AI tool to get answers, see the search field at the top of this page.
შენიშვნა: Ask AI ექსპერიმენტულია.
Get help from our developer community.
SDK გამოშვების და ტექნიკური პოლიტიკა
იხილეთ ჩვენი SDK-ის გამოშვებისა და მოვლა-პატრონობის პოლიტიკა.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
6/174
დასრულდაview
დასრულდაview
სპეციფიკაციები
შეესაბამება „უნივერსალური სერიული ავტობუსის სპეციფიკაციის მე-2.0 ვერსიას“. ახორციელებს „ინტერფეისის ასოციაციის აღწერის საინჟინრო ცვლილების შეტყობინებას (ECN)“. გადაცემის ტიპები
Control Bulk Interrupt USB classes Communication Device Class (CDC) Abstract Control Model (ACM) Human Interface Device (HID) Mass Storage Class (MSC) Vendor-specific class framework
მახასიათებლები
მასშტაბირებადია მხოლოდ საჭირო ფუნქციების ჩათვლით, მეხსიერების დატვირთვის მინიმიზაციისთვის. მხარს უჭერს სრულ სიჩქარეს (12 მბიტ/წმ). მხარს უჭერს კომპოზიტურ (მრავალფუნქციურ) მოწყობილობებს. მხარს უჭერს მრავალკონფიგურირებულ მოწყობილობებს. მხარს უჭერს USB ენერგიის დაზოგვის ფუნქციებს (მოწყობილობის შეჩერება და განახლება). მასობრივი შენახვის კლასის სრული ინტეგრაცია Micrium OS-ში. File სისტემის მოდული შემუშავებულია CMSIS-RTOS2 აბსტრაქციის ფენით, რათა მას შეეძლოს სხვადასხვა ოპერაციულ სისტემასთან მუშაობა. Silicon Labs GSDK აღჭურვილია FreeRTOS და Micrium OS პორტებით.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
7/174
დასრულდაview
დასრულდაview
USB Device Configuration
This section discusses how to configure Silicon Labs USB Device. There are three groups of configuration parameters, as follows:
USB მოწყობილობის ბირთვის კონფიგურაცია USB მოწყობილობის ინფორმაცია კონფიგურაცია USB მოწყობილობის აპარატურის კონფიგურაცია
USB Device Core Configuration
Silicon Labs USB Device can be configured at compile time via a set of #defines located in the sl_usbd_core_config.h file. USB Device uses #defines when possible because they allow code and data sizes to be scaled at compile time based on which features are enabled. This allows the read-only memory (ROM) and random-access memory (RAM) footprints of Silicon Labs USB Device to be adjusted based on your application’s requirements.
რეკომენდებულია: კონფიგურაციის პროცესი დაიწყეთ ნაგულისხმევი მნიშვნელობებით (მონიშნულია მუქი შრიფტით).
The sections below are organized based on the order in the template configuration file, sl_usbd_core_config.h.
Core Configuration Classes Configuration
ძირითადი კონფიგურაცია
ცხრილი – USB მოწყობილობის ბირთვის კონფიგურაციის კონსტანტები
Constant Description
ნაგულისხმევი მნიშვნელობა
SL_USBD_TA SK_STACK_ SIZE
Configures the stack size in bytes of USBD core task
4096
SL_USBD_TA SK_PRIORIT Y
Configures the priority of USBD core task. This is a CMSIS-RTOS2 priority.
osPriorityHigh
SL_USBD_A UTO_START _USB_DEVIC E
თუ ჩართულია, USB მოწყობილობა ავტომატურად ჩაირთვება ბირთვის ჩართვისა და პირველად 1 USBD ბირთვის დავალების დაგეგმვისთანავე. თუ გამორთულია, თქვენს აპლიკაციას დასჭირდება sl_usbd_core_start_device()-ის გამოძახება, როდესაც ის მზად იქნება USB ჰოსტის მიერ აღმოსაჩენად.
SL_USBD_C The total number of configurations that will be added via the sl_usbd_add_configuration()
1
ONFIGURATI function.
ON_QUANTI
TY
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
8/174
დასრულდაview
მუდმივი
SL_USBD _INTERF ACE_QU ANTITY
SL_USBD _ALT_INT ERFACE_ QUANTI
TY
SL_USBD _INTERF ACE_GR
OUP_QU
სიძველე
SL_USBD _DESCRI
PTOR_Q
უნენტი
SL_USBD _STRING _QUANTI
TY
SL_USBD _OPEN_E NDPOIN TS_QUA NTITY
Description The total number of USB interfaces to be added for all your configurations. This greatly depends on the class(es) used. For more information on how many interfaces a class instance requires, refer to the section “Resource Needs from core” of your class(es).
The total number of USB alternate interfaces to be added for all your configurations. This greatly depends on the class(es) used. This value must always be equal or greater than SL_USBD_INTERFACE_QUANTITY . For more information on how many alternate interfaces a class instance requires, refer to the section “Resource Needs from Core” of your class(es).
USB ინტერფეისის ჯგუფების საერთო რაოდენობა, რომლებიც დაემატება თქვენი ყველა კონფიგურაციისთვის. ეს მნიშვნელოვნად არის დამოკიდებული გამოყენებულ კლას(ებ)ზე. დამატებითი ინფორმაციისთვის იმის შესახებ, თუ რამდენ ინტერფეისის ჯგუფს სჭირდება კლასის ეგზემპლარი, იხილეთ თქვენი კლასი(ებ)ის განყოფილება „რესურსების საჭიროებები ბირთვიდან“.
თქვენი ყველა კონფიგურაციისთვის დამატებული Endpoint-ის აღმწერების საერთო რაოდენობა. ეს მნიშვნელოვნად არის დამოკიდებული გამოყენებულ კლას(ებ)ზე. კლასის ინსტანციას რამდენ endpoint-ის აღმწერს სჭირდება, დამატებითი ინფორმაციისთვის იხილეთ თქვენი კლასი(ებ)ის „Core-დან რესურსების საჭიროებების“ განყოფილებაში „endpoints of country“. გაითვალისწინეთ, რომ აქ საკონტროლო endpoints-ების გათვალისწინება საჭირო არ არის. USB სტრიქონების საერთო რაოდენობა. რაოდენობის ნულზე დაყენება გამორთავს ფუნქციას. ამის გამორთვა გამოიწვევს იმას, რომ მოწყობილობა არ შეინახავს აპლიკაციიდან გადაცემულ USB აღწერილობის სტრიქონებს. ეს ნიშნავს, რომ ჰოსტი ვერ შეძლებს აღწერილობის სტრიქონების (როგორიცაა მწარმოებელი და პროდუქტის სახელი) მოძიებას. კონფიგურაციაზე გახსნილი endpoints of country. მოწყობილობას საკონტროლო გადაცემისთვის მინიმუმ ორი გახსნილი endpoint სჭირდება, მაგრამ თქვენ ასევე უნდა დაამატოთ გამოყენებული კლასი(ებ)ის endpoints. კლასის ინსტანციას რამდენ გახსნილ endpoint of country სჭირდება, დამატებითი ინფორმაციისთვის იხილეთ თქვენი კლასი(ებ)ის „Core-დან რესურსების საჭიროებების“ განყოფილებაში „endpoints of country“.
ნაგულისხმევი მნიშვნელობა
10 10
2
20 30 20
Classes Configuration
კლასებს აქვთ კონკრეტული კომპილაციის დროის კონფიგურაციები. დამატებითი ინფორმაციისთვის იხილეთ USB მოწყობილობის კლასები.
USB მოწყობილობის ინფორმაციის კონფიგურაცია
sl_usbd_device_config.h კონფიგურაცია file #define-s-ის კომპილაციის დროის ჯგუფებად გადაჯგუფება თქვენი მოწყობილობის შესახებ ძირითადი ინფორმაციის დასაყენებლად, როგორიცაა გამყიდველის/პროდუქტის ID, მოწყობილობის სტრიქონები და ა.შ. ქვემოთ მოცემულ ცხრილში აღწერილია ამ კონფიგურაციაში ხელმისაწვდომი თითოეული კონფიგურაციის ინფორმაცია. file.
Table – USB Device Information Configuration Defines
მუდმივი
SL_USBD_DEVIC E_VENDOR_ID
SL_USBD_DEVIC E_PRODUCT_ID
Description Your vendor identification number as delivered by the USB Implementers Forum. For more information on how you can obtain a vendor ID, see http://www.usb.org/developers/vendor/ . Your product identification number.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
9/174
დასრულდაview
მუდმივი
აღწერა
SL_USBD_DEVICE_RELEASE Release number of your device. _NUMBER
SL_USBD_DEVICE_MANUFA String describing the manufacturer of your device. This configuration is ignored when the
CTURER_STRING
configuration SL_USBD_STRING_QUANTITY is set to 0.
SL_USBD_DEVICE_PRODUC სტრიქონი, რომელიც აღწერს თქვენს პროდუქტს. ეს კონფიგურაცია იგნორირებულია კონფიგურაციის დროს.
T_STRING
SL_USBD_STRING_QUANTITY is set to 0.
SL_USBD_DEVICE_SERIAL_N String containing the serial number of your device. This configuration is ignored when the
UMBER_STRING
configuration SL_USBD_STRING_QUANTITY is set to 0.
SL_USBD_DEVICE_LANGUA Identification number of the language of your device’s strings. Possible values are:
GE_ID
– SL_USBD_LANG_ID_ARABIC_SAUDI_ARABIA
– SL_USBD_LANG_ID_CHINESE_TAIWAN
– SL_USBD_LANG_ID_ENGLISH_US
– SL_USBD_LANG_ID_ENGLISH_UK
– SL_USBD_LANG_ID_FRENCH
– SL_USBD_LANG_ID_GERMAN
– SL_USBD_LANG_ID_ბერძნული
– SL_USBD_LANG_ID_ITALIAN
– SL_USBD_LANG_ID_PORTUGUESE
– SL_USBD_LANG_ID_SANSKRIT
This configuration is ignored when the configuration SL_USBD_STRING_QUANTITY is set to 0.
USB მოწყობილობის აპარატურის კონფიგურაცია
თქვენს მიერ გამოყენებული Silicon Labs მოწყობილობიდან გამომდინარე, შესაძლოა გქონდეთ GPIO პინი და პორტი USB VBUS Sense სიგნალისთვის. კონფიგურაციის განსაზღვრებები მოცემულია sl_usbd_hardware_config.h სათაურში. file.
მუდმივი
SL_USBD_DRIVER_VBUS_SENSE_PORT SL_USBD_DRIVER_VBUS_SENSE_PIN
აღწერა
GPIO პორტი თქვენს დაფაზე USB VBUS Sense სიგნალისთვის. GPIO პინი თქვენს დაფაზე USB VBUS Sense სიგნალისთვის.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
10/174
დასრულდაview
დასრულდაview
USB Device Programming Guide
ეს განყოფილება განმარტავს, თუ როგორ გამოიყენოთ USB მოწყობილობის მოდული.
USB მოწყობილობის მოდულის საწყისი დაყენება
This section describes the basic steps required to initialize the USB Device module and to add, prepare, and start a device. Initializing the USB Device Module Initializing the USB Device Core Initializing the aCl ss(es) Adding Your USB Device Building Your USB Device Adding Configuration(s) Adding USB Function(s) Starting Your USB Device
Event Hook Functions
Initializing the USB Device Module
Initializing the USB Device Core
ა აშშ ა დაიწყეთ B მოწყობილობის მოდულის ბირთვის ინიციალიზაციით sl_usbd_core_init() ფუნქციის შესრულებით. ქვემოთ მოცემული მაგალითი აჩვენებს sl_usbd_core_init() ფუნქციის შესრულებით.
Example – sl_usbd_core_init()-ის გამოძახება
sl_status_t status; status = sl_usbd_core_init(); თუ (სტატუსი! SL_STATUS_OK) { /* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავება. */
}
Initializing the Class(es)
USB მოწყობილობის მოდულის ბირთვის ინიციალიზაციის შემდეგ, თქვენ უნდა ინიციალიზაცია გაუკეთოთ თითოეულ კლასს, რომლის გამოყენებასაც აპირებთ. დამატებითი ინფორმაციისთვის იხილეთ თქვენი acl ss(es)-ის „პროგრამირების სახელმძღვანელო“ განყოფილება.
თქვენი USB მოწყობილობის შექმნა
Adding Configuration(s)
მოწყობილობის წარმატებით ინიციალიზაციის შემდეგ, შეგიძლიათ დაიწყოთ მასზე USB ფუნქციების დამატება, ახალი კონფიგურაციით დაწყებული. მოწყობილობას უნდა ჰქონდეს მინიმუმ ერთი კონფიგურაცია. კონფიგურაციის(ების) დასამატებლად, გამოიძახეთ ფუნქცია aa sl_usbd_core_dd_configur tion() ფუნქცია. ეს ფუნქცია უნდა გამოიძახოთ თითოეული კონფიგურაციისთვის, რომლის დამატებაც გსურთ.ampქვემოთ მოცემულია, თუ როგორ დაამატოთ სრული სიჩქარე.
Example – Adding Configuration(s) to Your Device
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
11/174
დასრულდაview
sl_status_t status; uint8_t config_nbr_fs;
/* Adding a full-speed configuration to the device. */
სტატუსი = sl_usbd_core_add_configuration(0,
/* No special attributes to the configuration. */
100u,
/* მაქსიმალური ენერგომოხმარება: 100mA.
*/
SL_USBD_DEVICE_SPEED_FULL,
/* Full-Speed configuration.
*/
“Config Add Example Full-Speed config”,
&config_nbr_fs);
თუ (სტატუსი! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
USB ფუნქცია(ები)ს დამატება
მას შემდეგ, რაც თქვენს მოწყობილობას წარმატებით დაამატებთ მინიმუმ ერთ კონფიგურაციას, შეგიძლიათ დაამატოთ მას ინტერფეისები და საბოლოო წერტილები. თითოეულ USB კლასს აქვს საკუთარი საჭიროებები ინტერფეისისა და საბოლოო წერტილების ტიპის, რაოდენობისა და სხვა პარამეტრების თვალსაზრისით. Silicon Labs-ის USB მოწყობილობა ამატებს ინტერფეისებსა და საბოლოო წერტილებს მის მიერ შემოთავაზებულ კლასებში.
თქვენი აპლიკაციიდან შეგიძლიათ შექმნათ USB კლასი და დაამატოთ ის კონფიგურაციაში. USB მოწყობილობის კლასის ინსტანციების კონცეფციის შესახებ დამატებითი ინფორმაციისთვის იხილეთ USB მოწყობილობის კლასები. გაითვალისწინეთ, რომ მრავალფუნქციური (კომპოზიტური) მოწყობილობის შესაქმნელად შეგიძლიათ შექმნათ და დაამატოთ კონფიგურაციაში მრავალი განსხვავებული კლასის ინსტანცია.
ყოფილმაample below shows how to create a class instance and add it to a configuration.
Example – Adding a Class Instance to Your Device
sl_status_t სტატუსი; uint8_t class_nbr;
/* Create an instance of the class you want to use.*/ /* Note that depending on the class this function can have more arguments. */ status = sl_usbd_<class>_create_instance(&class_nbr); if (status ! SL_STATUS_OK) { /* An error occurred. Error handling should be added here. */ }
/* Add the class instance to the Full-Speed configuration. */ status = sl_usbd_<class>_add_to_configuration(class_nbr, /* Class number returned by sl_usbd_<class>_create_instance. */
config_nbr_fs); /* Configuration number returned by sl_usbd_core_add_configuration(). */ if (status ! SL_STATUS_OK) { /* An error occurred. Error handling should be added here. */ }
Starting Your USB Device
By default, the device will be started automatically by the USB device core task after the device initialization is completed and the kernel started. To control when the device is started and becomes visible by the USB host, use the configuration define SL_USBD_AUTO_START_USB_DEVICE to disable the auto-start feature. When disabled, after you have built/prepared your device, you can start it and make it visible to the USB host by calling the function sl_usbd_core_start_device() .
ყოფილმაample below shows how to start your device using the sl_usbd_core_start_device() function.
Example – თქვენი მოწყობილობის ჩართვა
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
12/174
დასრულდაview
sl_status_t სტატუსი;
სტატუსი = sl_usbd_core_start_device(); თუ (სტატუსი! SL_STATUS_OK) { /* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავება. */ }
Event Hook Functions
The USB Device core module offers two weak hook functions that you can re-defined in your application. Their purpose is to notify when bus and configuration events occur.
ცხრილი – USB Event Hook-ის ფუნქციები
ღონისძიება
აღწერა
ავტობუსი
Called when USB Bus event occurs
Configuration Called when USB Configuration event occurs
Function Signature
void sl_usbd_on_bus_event(sl_usbd_bus_event_t event); void sl_usbd_on_config_event(sl_usbd_config_event_t event, uint8_t config_nbr);
Example – Event Hook Functions
void sl_usbd_on_bus_event(sl_usbd_bus_event_t event) { switch (event) { case SL_USBD_EVENT_BUS_CONNECT:
// called when USB cable is inserted in a host controller break;
შემთხვევა SL_USBD_EVENT_BUS_DISCONNECT: // გამოიძახება, როდესაც USB კაბელი ამოღებულია მასპინძელი კონტროლერის შესვენებიდან;
case SL_USBD_EVENT_BUS_RESET: // called when the host sends reset command break;
შემთხვევა SL_USBD_EVENT_BUS_SUSPEND: // გამოიძახება, როდესაც ჰოსტი აგზავნის suspend ბრძანებას break;
case SL_USBD_EVENT_BUS_RESUME: // called when the host sends wake up command break;
ნაგულისხმევი: შესვენება; } }
void sl_usbd_on_config_event(sl_usbd_config_event_t მოვლენა, uint8_t config_nbr) { გადამრთველი (მოვლენა) { შემთხვევა SL_USBD_EVENT_CONFIG_SET:
// called when the host sets a configuration break;
case SL_USBD_EVENT_CONFIG_UNSET: // called when a configuration is unset break;
ნაგულისხმევი: შესვენება; } }
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
13/174
დასრულდაview
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
14/174
დასრულდაview
დასრულდაview
USB Device Classes
Silicon Labs-ის USB მოწყობილობაში ხელმისაწვდომ USB კლასებს აქვთ რამდენიმე საერთო მახასიათებელი. ეს განყოფილება განმარტავს ამ მახასიათებლებს და მათ ურთიერთქმედებას ბირთვის ფენასთან.
For more information on a specific class, see the following:
CDC ACM Class HID Class MSC SCSI Class Vendor Class
About Class Instances
USB მოწყობილობაში არსებული USB კლასები კლასის ეგზემპლარების კონცეფციას ნერგავენ. კლასის ეგზემპლარი მოწყობილობაში ერთ ფუნქციას წარმოადგენს. ფუნქცია შეიძლება აღიწეროს ერთი ინტერფეისით ან ინტერფეისების ჯგუფით და მიეკუთვნოს კონკრეტულ კლასს.
თითოეული USB კლასის იმპლემენტაციას აქვს გარკვეული საერთო კონფიგურაციები და ფუნქციები, რომლებიც დაფუძნებულია კლასის ეგზემპლარის კონცეფციაზე. საერთო კონფიგურაციები და ფუნქციები წარმოდგენილია ქვემოთ მოცემულ ცხრილში. სვეტის სათაურში „მუდმივები ან ფუნქცია“, ჩანაცვლების ველი XXXX შეიძლება შეიცვალოს კლასის სახელით: CDC, HID, MSC, CDC_ACM ან VENDOR (ფუნქციის სახელწოდების გამყიდველი).
ცხრილი – მრავალჯერადი კლასის ეგზემპლარების კონცეფციასთან დაკავშირებული კონსტანტები და ფუნქციები
მუდმივი ან ფუნქცია
SL_USBD_XXXX_CL ASS_INS TANCE_QUANTITY
SL_USBD_XXXX_CONFIGUR ATION_QUANTITY
sl_usb d _XXXX_cre ate _insta nce ()
sl_usbd_XXXX_add_to_conf iguration()
აღწერა
ახდენს კლასის ეგზემპლარების მაქსიმალური რაოდენობის კონფიგურაციას.
Configures the maximum number of configurations. During the class initialization, a created class instance will be added to one or more configurations. Creates a new class instance.
Adds an existing class instance to the specified device configuration.
In terms of code implementation, the class will declare a local global variable that contains a class control structure. This class control structure is associated with one class instance and will contain specific information to manage the class instance.
The following figures show several case scenarios. Each figure includes a code exampრაც შეესაბამება შემთხვევის სცენარს.
სურათი – კლასის მრავალი ეგზემპლარი – FS მოწყობილობა (1 კონფიგურაცია 1 ინტერფეისით) წარმოადგენს ტიპურ USB მოწყობილობას. მოწყობილობა არის სრული სიჩქარის (FS) და შეიცავს ერთ კონფიგურაციას. მოწყობილობის ფუნქცია აღწერილია ერთი ინტერფეისით, რომელიც შედგება მონაცემთა კომუნიკაციისთვის განკუთვნილი საბოლოო წერტილების წყვილისგან. იქმნება ერთი კლასის ეგზემპლარი, რომელიც საშუალებას მოგცემთ მართოთ მთელი ინტერფეისი მასთან დაკავშირებულ საბოლოო წერტილთან ერთად.
Figure – Multiple Class Instances – FS Device 1 Configuration with 1 Interface)
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
15/174
დასრულდაview
The code corresponding to Figure – Multiple Class Instances – FS Device (1 Configuration with 1 Interface) is shown in the exampქვემოთ.
Example – Multiple Class Instances – FS Device 1 Configuration with 1 Interface)
sl_status_t status; uint8_t class_0;
void app_usbd_XXXX_enable(uint8_t class_nbr) { /* კლასის ჩართვის მოვლენის მართვა. */ }
void app_usbd_XXXX_disable(uint8_t class_nbr) { /* Handle Class disable event. */ }
sl_usbd_XXXX_callbacks_t class_callbacks = {
(1)
.enable = app_usbd_XXXX_enable,
.disable = app_usbd_XXXX_disable
};
status = sl_usbd_XXXX_init();
(2)
თუ (სტატუსი! SL_STATUS_OK) {
/* $$$$ შეცდომის მართვა. */
}
სტატუსი = sl_usbd_XXXX_create_instance(&class_callbacks,
(3)
&class_0);
თუ (სტატუსი! SL_STATUS_OK) {
/* $$$$ შეცდომის მართვა. */
}
სტატუსი = sl_usbd_XXXX_add_to_configuration(class_0, config_0);
(4)
თუ (სტატუსი! SL_STATUS_OK) {
/* $$$$ შეცდომის მართვა. */
}
(1) თითოეული კლასი გთავაზობთ უკუკავშირის ფუნქციების ერთობლიობას მოწყობილობის დაკავშირების/გათიშვის მოვლენებისთვის და კლასის სპეციფიკური მოვლენებისთვის. უკუკავშირის სტრუქტურის ობიექტი გადაეცემა არგუმენტად კლასის ეგზემპლარის შექმნისას sl_usbd_XXXX_create_instance() ფუნქციით.
ფუნქცია.
(1) Initialize the class. All internal variables, structures, and class ports will be initialized. Note that the Init() function in some classes may take other arguments.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
16/174
დასრულდაview
(2) Create the class instance, which is class_0 . The function sl_usbd_XXXX_create_instance() allocates a class control structure associated with class_0 . Depending on the class, sl_usbd_XXXX_create_instance() may have additional parameters aside from the class number that represent class-specific information stored in the class control structure. a a a (3) Add the cl ss inst nce, class_0 , to the specified configur tion number, config_0 . sl_usbd_XXXX_add_to_configuration() will create the interface 0 and its associated IN and OUT endpoints. As a result, the class instance encompasses the interface 0 and its endpoints. Any communication done on the interface 0 will use the class instance number, class_0 . Figure – Multiple Class Instances – FS Device (2 Configurations and Multiple Interfaces) represents a more complex exampმაგ. სრული სიჩქარის მოწყობილობა ორი კონფიგურაციისგან შედგება. მოწყობილობას აქვს ორი ფუნქცია, რომლებიც ერთსა და იმავე კლასს მიეკუთვნება, მაგრამ თითოეული ფუნქცია აღწერილია ორი ინტერფეისით და აქვს ორმხრივი საბოლოო წერტილების წყვილი. ამ მაგალითშიample, two class instances are created. Each class instance is associated with a group of interfaces as opposed to Figure – Multiple Class Instances – FS Device (1 Configuration with 1 Interface) and Figure – Multiple Class Instances – FS Device (2 Configurations and Multiple Interfaces) where the class instance was associated with a single interface.
Figure – Multiple Class Instances – FS Device 2 Configurations and Multiple Interfaces)
The code corresponding to Figure – Multiple Class Instances – FS Device (2 Configurations and Multiple Interfaces) is shown in the example below. The error handling is omitted for clarity.
Example – Multiple Class Instances – FS Device 2 Configurations and Multiple Interfaces)
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
17/174
დასრულდაview
sl_status_t status; uint8_t class_0; uint8_t class_1;
status = sl_usbd_XXXX_init();
status = sl_usbd_XXXX_create_instance(&class_0); status = sl_usbd_XXXX_create_instance(&class_1);
სტატუსი = sl_usbd_XXXX_add_to_configuration(class_0, cfg_0); სტატუსი = sl_usbd_XXXX_add_to_configuration(class_1, cfg_0);
სტატუსი = sl_usbd_XXXX_add_to_configuration(class_0, cfg_1); სტატუსი = sl_usbd_XXXX_add_to_configuration(class_1, cfg_1);
(1)
(2) (3)
(4) (5)
(6) (6)
(1) Initialize the class. Any internal variables, structures, and class ports will be initialized.
(2) Create the class instance, class_0 . The function sl_usbd_XXXX_create_instance() allocates a class control structure associated with class_0 .
(3) Create the class instance, class_1 . The function sl_usbd_XXXX_create_instance() allocates another class control structure associated with class_1 .
(4) Add the class instance, class_0 , to the configuration, cfg_0 . sl_usbd_XXXX_add_to_configuration() will create the interface 0, interface 1, alternate interfaces, and the associated IN and OUT endpoints. The class instance number, class_0 , will be used for any data communication on interface 0 or interface 1.
(5) დაამატეთ კლასის ეგზემპლარი, class_1, კონფიგურაციას, cfg_0. sl_usbd_XXXX_add_to_configuration() შექმნის ინტერფეის 2-ს, ინტერფეის 3-ს და მათთან დაკავშირებულ IN და OUT საბოლოო წერტილებს. კლასის ეგზემპლარის ნომერი, class_1, გამოყენებული იქნება ნებისმიერი მონაცემთა კომუნიკაციისთვის ინტერფეის 2-ზე ან ინტერფეის 3-ზე.
(6) Add the same class instances, class_0 and class_1 , to the other configuration, cfg_1 .
თითოეული კლასი განსაზღვრავს sl_usbd_XXXX_callbacks_t ტიპის სტრუქტურას. მისი მიზანია, თითოეულ კლასს მისცეს უკუკავშირის ფუნქციების ნაკრები, რომელიც გამოიძახება მოვლენის მოხდენისას. თითოეულ კლასში წარმოდგენილია ორი უკუკავშირის ფუნქცია. ისინი წარმოდგენილია ქვემოთ მოცემულ ცხრილში.
Table – Common Class Callback Functions
Fields Description .enable Called when the USB class instance is enabled successfully. .disable Called when the USB class instance is disabled.
Function Signature void app_usbd_XXXX_enable(uint8_t class_nbr); void app_usbd_XXXX_disable(uint8_t class_nbr);
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
18/174
დასრულდაview
დასრულდაview
USB მოწყობილობის CDC ACM კლასი
USB Device CDC Base Class Overview USB მოწყობილობის CDC ACM კლასის რესურსების საჭიროებები ძირითადი USB მოწყობილობის CDC ACM ქვეკლასიდანview USB Device CDC ACM Class Configuration USB Device CDC ACM Class Programming Guide
This section describes the Communications Device Class (CDC) class and the associated CDC subclass supported by Silicon Labs’ USB Device stack. Silicon Labs USB-Device currently supports the Abstract Control Model (ACM) subclass, which is commonly used for serial emulation.
CDC includes various telecommunication and networking devices. Telecommunication devices encompass analog modems, analog and digital telephones, ISDN terminal adapters, etc. For example, networking devices contain ADSL and cable modems, Ethernet adapters, and hubs. CDC defines a framework to encapsulate existing communication services standards, such as V.250 (for modems over telephone network) and Ethernet (for local area network devices), using a USB link. A communication device is in charge of device management, call management when needed, and data transmission.
CDC განსაზღვრავს მოწყობილობების შვიდ ძირითად ჯგუფს. თითოეული ჯგუფი მიეკუთვნება კომუნიკაციის მოდელს, რომელიც შეიძლება მოიცავდეს რამდენიმე ქვეკლასს. მოწყობილობების თითოეულ ჯგუფს CDC-ის საბაზისო კლასის გარდა, აქვს საკუთარი სპეციფიკაციის დოკუმენტი. შვიდი ჯგუფია:
Public Switched Telephone Network (PSTN), devices including voiceband modems, telephones, and serial emulation devices. Integrated Services Digital Network (ISDN) devices, including terminal adaptors and telephones. Ethernet Control Model (ECM) devices, including devices supporting the IEEE 802 family (ex.: cable and ADSL modems, WiFi adapters). Asynchronous Transfer Mode (ATM) devices, including ADSL modems and other devices connected to ATM networks (workstations, routers, LAN switches). Wireless Mobile Communications (WMC) devices, including multi-function communications handset devices used to manage voice and data communications. Ethernet Emulation Model (EEM) devices which exchange Ethernet-framed data. Network Control Model (NCM) devices, including high-speed network devices (High Speed Packet Access modems, Line Terminal Equipment)
The CDC and the associated subclass implementation complies with the following specifications:
Universal Serial Bus, Class Definitions for Communications Devices, Revision 1.2, November 3 2010. Universal Serial Bus, Communications, Subclass for PSTN Devices, Revision 1.2, February 9 2007.
USB Device CDC Base Class Overview
A CDC device is composed of the following interfaces to implement communication capability:
Communications Class Interface (CCI) is responsible for the device management and optionally the call management. The
device management enables the general configuration and control of the device and the notification of events to the host. The call management enables calls establishment and termination. Call management might be multiplexed through a DCI. A CCI is mandatory for all CDC devices. It identifies the CDC function by specifying the communication model supported by the CDC device. The interface(s) following the CCI can be any defined USB class interface, such as Audio or a vendor-specific interface. The vendor-specific interface is represented specifically by a DCI.
მონაცემთა კლასის ინტერფეისი (DCI) პასუხისმგებელია მონაცემთა გადაცემაზე. გადაცემული და/ან მიღებული მონაცემები არ შეესაბამება კონკრეტულ
format. Data could be raw data from a communication line, data following a proprietary format, etc. All the DCIs following the CCI can be seen as subordinate interfaces.
A CDC device must have at least one CCI and zero or more DCIs. One CCI and any subordinate DCI together provide a feature to the host. This capability is also referred to as a function. In a CDC composite device, you could have several
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
19/174
დასრულდაview
functions. Therefore, the device would be composed of several sets of CCI and DCI(s) as shown in Figure – CDC Composite Device.
Figure – CDC Composite Device
CDC მოწყობილობა, სავარაუდოდ, გამოიყენებს საბოლოო წერტილების შემდეგ კომბინაციას:
A pair of control IN and OUT endpoints called the default endpoint. An optional bulk or interrupt IN endpoint. A pair of bulk or isochronous IN and OUT endpoints. Note that Silicon Labs USB device stack does not currently support isochronous endpoints.
The table below shows the usage of the different endpoints and by which interface of the CDC they are used.
ცხრილი – დაავადებათა კონტროლის ცენტრის საბოლოო წერტილის გამოყენება
ბოლო წერტილი
კონტროლი IN
კონტროლი OUT
შეწყვეტა ან მასობრივი შესვლა მასობრივი ან იზოქრონული შესვლა მასობრივი ან იზოქრონული
გარეთ
მიმართულება
Deviceto-host
Host-todevice
Deviceto-host
Deviceto-host
Host-todevice
ინტერფეისის გამოყენება
CCI
Standard requests for enumeration, class-specific requests, device
management, and optionally call management.
CCI
Standard requests for enumeration, class-specific requests, device
management, and optionally call management.
CCI
Events notification, such as ring detect, serial line status, network status.
DCI
Raw or formatted data communication.
DCI
Raw or formatted data communication.
საკომუნიკაციო მოწყობილობების უმეტესობა იყენებს შეფერხების საბოლოო წერტილს, რათა შეატყობინოს მასპინძელს მოვლენების შესახებ. იზოქრონული საბოლოო წერტილები არ უნდა იქნას გამოყენებული მონაცემთა გადაცემისთვის, როდესაც საკუთრების პროტოკოლი ეყრდნობა მონაცემთა ხელახლა გადაცემას USB პროტოკოლის შეცდომების შემთხვევაში. იზოქრონულმა კომუნიკაციამ შეიძლება თანდაყოლილი დაკარგოს მონაცემები, რადგან მას არ გააჩნია ხელახალი ცდის მექანიზმები.
The seven major models of communication encompass several subclasses. A subclass describes the way the device should use the CCI to handle the device management and call management. The table below shows all the possible subclasses and the communication model they belong to.
ცხრილი – CDC ქვეკლასები
Subclass
პირდაპირი ხაზის მართვის მოდელი აბსტრაქტული მართვის მოდელი
კომუნიკაციის მოდელი
PSTN
PSTN
Example of Devices Using This Subclass
Modem devices directly controlled by the USB host
Serial emulation devices, modem devices controlled through a serial command set
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
20/174
დასრულდაview
Subclass
კომუნიკაციის მოდელი
Example of Devices Using This Subclass
Telephone Control Model
PSTN
Multi-Channel Control ISDN Model
CAPI კონტროლის მოდელი ISDN
Ethernet Networking ECM Control Model
ATM Networking
ბანკომატ
კონტროლის მოდელი
უსადენო ტელეფონის მართვის მოდელი
WMC
Device Management WMC
Mobile Direct Line Model
WMC
OBEX
WMC
Ethernet ემულაციის EEM მოდელი
ქსელის კონტროლის მოდელი
NCM
Voice telephony devices
Basic rate terminal adaptors, primary rate terminal adaptors, telephones
Basic rate terminal adaptors, primary rate terminal adaptors, telephones DOC-SIS cable modems, ADSL modems that support PPPoE emulation, Wi-Fi adaptors (IEEE 802.11-family), IEEE 802.3 adaptors ADSL modems
Mobile terminal equipment connecting to wireless devices
Mobile terminal equipment connecting to wireless devices Mobile terminal equipment connecting to wireless devices
Mobile terminal equipment connecting to wireless devices Devices using Ethernet frames as the next layer of transport. Not intended for routing and Internet connectivity devices IEEE 802.3 adaptors carrying high-speed data bandwidth on network
USB Device CDC ACM Class Resource Needs from Core
ყოველ ჯერზე, როდესაც თქვენ დაამატებთ CDC ACM კლასის ინსტანციას USB კონფიგურაციაში sl_usbd_cdc_acm_add_to_configuration() ფუნქციის გამოძახების გზით, ბირთვიდან გამოიყოფა შემდეგი რესურსები.
რესურსი
Interfaces Alternate interfaces Endpoints Interface groups
რაოდენობა
2 2 3 1
Note that those numbers are per configuration. When setting up your SL_USBD_INTERFACE_QUANTITY , SL_USBD_ALT_INTERFACE_QUANTITY , SL_USBD_INTERFACE_GROUP_QUANTITY and SL_USBD_DESCRIPTOR_QUANTITY configuration values, don’t forget to take into account on how many configurations the class will be added. For the SL_USBD_OPEN_ENDPOINTS_QUANTITY configuration value, since endpoints are opened only when a configuration is set by the host, you just need to take into account the number of needed endpoints for a class instance.
USB მოწყობილობის CDC ACM ქვეკლასი გადაჭარბებულიაview
The CDC base class is composed of a Communications Class Interface (CCI) and Data Class Interface (DCI), which is discussed in detail in USB Device CDC Base Class Overview . This section discusses a CCI of type ACM. It consists of a default endpoint for the management element and an interrupt endpoint for the notification element. A pair of bulk endpoints is used to carry unspecified data over the DCI.
ACM ქვეკლასს იყენებენ საკომუნიკაციო მოწყობილობების ორი ტიპი:
მოწყობილობები, რომლებიც მხარს უჭერენ AT ბრძანებებს (მაგალითად, ხმოვანი მოდემები). სერიული ემულაციის მოწყობილობები, რომლებსაც ასევე ვირტუალური COM პორტის მოწყობილობებს უწოდებენ.
There are several subclass-specific requests for the ACM subclass. They allow you to control and configure the device. The complete list and description of all ACM requests can be found in the specification <Universal Serial Bus, Communications,
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
21/174
დასრულდაview Subclass for PSTN Devices, revision 1.2, February 9, 2007=, section 6.2.2.
From this list, Silicon Labs9 ACM subclass supports the following:
Table – ACM Requests Supported by Silicon Labs
Subclass Request Description
SetCommFeature GetCommFeature ClearCommFeature
ჰოსტი ამ მოთხოვნას აგზავნის მოცემული საკომუნიკაციო ფუნქციის პარამეტრების გასაკონტროლებლად. არ გამოიყენება სერიული ემულაციისთვის.
The host sends this request to get the current settings for a given communications feature. Not used for serial emulation.
The host sends this request to clear the settings for a given communications feature. Not used for serial emulation.
SetLineCoding
ჰოსტი აგზავნის ამ მოთხოვნას ACM მოწყობილობის პარამეტრების კონფიგურაციისთვის: ბაუდის სიჩქარე, გაჩერების ბიტების რაოდენობა, პარიტეტის ტიპი და მონაცემთა ბიტების რაოდენობა. სერიული ემულაციისთვის, ეს მოთხოვნა ავტომატურად იგზავნება სერიული ტერმინალის მიერ ყოველ ჯერზე, როდესაც თქვენ კონფიგურაციას უკეთებთ სერიულ პარამეტრებს ღია ვირტუალური COM პორტისთვის.
GetLineCoding
The host sends this request to get the current ACM settings (baud rate, stop bits, parity, data bits). For a serial emulation, serial terminals send this request automatically during virtual COM port opening.
SetControlLineState ჰოსტი აგზავნის ამ მოთხოვნას ნახევრად დუპლექსური მოდემების ოპერატორის სამართავად და მიუთითებს, მზადაა თუ არა მონაცემთა ტერმინალური აღჭურვილობა (DTE). სერიული ემულაციის შემთხვევაში, DTE არის სერიული ტერმინალი. სერიული ემულაციისთვის, გარკვეული სერიული ტერმინალები საშუალებას გაძლევთ გაგზავნოთ ეს მოთხოვნა დაყენებული კონტროლით.
SetBreak
The host sends this request to generate an RS-232 style break. For a serial emulation, certain serial terminals allow you to send this request.
Silicon Labs9 ACM ქვეკლასი იყენებს შეწყვეტის შეყვანის საბოლოო წერტილს, რათა აცნობოს მასპინძელს სერიული ხაზის მიმდინარე მდგომარეობის შესახებ.
line state is a bitmap informing the host about:
Data discarded because of overrun Parity error Framing error State of the ring signal detection State of break detection mechanism State of transmission carrier State of receiver carrier detection
Silicon Labs9 ACM subclass implementation complies with the following specification:
Universal Serial Bus, Communications, Subclass for PSTN Devices, revision 1.2, February 9, 2007.
USB Device CDC ACM Class Configuration
This section discusses how to configure the CDC ACM Class (Communication Device Class, Abstract Control Model). There are two groups of configuration parameters:
USB მოწყობილობის CDC ACM კლასის აპლიკაციის სპეციფიკური კონფიგურაციები USB მოწყობილობის CDC ACM კლასის ეგზემპლარის კონფიგურაციები
USB Device CDC ACM Class Application Specific Configurations
CDC Base Class ACM Subclass
დაავადებათა კონტროლისა და პრევენციის ცენტრის ბაზისური კლასი
First, to use the Silicon Labs USB device CDC class module, you will need to adjust the CDC compile-time configuration #define-s according to your application needs. They are regrouped inside the sl_usbd_core_config.h header file CDC სექციაში. მათი მიზანია USB მოწყობილობის მოდულის ინფორმირება იმის შესახებ, თუ რამდენი USB CDC ობიექტი უნდა გამოყოს.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
22/174
დასრულდაview
The table below describes each configuration field available in this configuration structure.
Table – USB Device CDC Configuration Defines
კონფიგურაციის სახელი
SL_USBD_CDC_CL AS S_INSTANCE_QUANT ITY
SL_USBD_CDC_CONF IGURATION_QUANTI
TY
SL_USBD_CDC_DATA _INTERFACE_QUANTI
TY
აღწერა
Number of class instances you will allocate via a call to the function
sl_usbd_cdc_acm_create_instance().
კონფიგურაციების რაოდენობა. ACM კლასის ინსტანციების დამატება შესაძლებელია ერთ ან რამდენიმე aaaa კონფიგურაციაში sl_usbd_cdc_acm_add_to_configuration() ფუნქციის გამოყენებით.
Total number of data interfaces (DCI) for all the CDC functions. Each CDC ACM function a a a a a a a a a dded vi c ll to the function sl_usbd_cdc_acm_create_instance() will dd d t interf ce.
ნაგულისხმევი მნიშვნელობა
2
1
2
ACM ქვეკლასი
The ACM subclass has one compile-time configuration shown in the table below.
ცხრილი – USB მოწყობილობის CDC ACM კონფიგურაციის განსაზღვრა
კონფიგურაციის სახელი
SL_USBD_CDC_ACM_SUBCL ASS_I NSTANCE_QUANTITY
აღწერა
აკონფიგურირებს ქვეკლასების ინსტანციების რაოდენობას, რომლებსაც გამოყოფთ ზარის მეშვეობით.
ფუნქცია sl_usbd_cdc_acm_create_instance().
ნაგულისხმევი მნიშვნელობა
2
USB Device CDC ACM Class Instance Configurations
ეს განყოფილება განსაზღვრავს CDC ACM სერიული კლასის ინსტანციებთან დაკავშირებულ კონფიგურაციებს. კლასის ინსტანციის შექმნა, ხაზის მდგომარეობა, ინტერვალი, გამოძახება, მართვა, შესაძლებლობები.
Class Instance Creation
CDC ACM სერიული კლასის ეგზემპლარის შესაქმნელად, გამოიძახეთ ფუნქცია T a sl_usbd_cdc_acm_create_instance(). ეს ფუნქცია იყენებს სამ კონფიგურაციის არგუმენტს, როგორც ეს აქ არის აღწერილი.
line_state_interval
This is the interval (in milliseconds) that your CDC ACM serial class instance will report the line state notifications to the T a a host. his v lue must be power of two (1, 2, 4, 8, 16, etc).
call_mgmt_capabilities
ზარის მართვის შესაძლებლობების ბიტმაპი. ბიტმაპის შესაძლო მნიშვნელობებია შემდეგი:
Value (bit)
SL_USBD_ACM_SERIAL_CALL_MGMT_DEV
SL_USBD_ACM_SERIAL_CALL_MGMT_DATA_CCI _DCI
აღწერა
Device handles call management itself. Device can send/receive call management information over a Data Class interface.
p_acm_callbacks
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
23/174
დასრულდაview
a a M a a p_acm_callbacks is pointer to structure of type sl_usbd_cdc_acm_callbacks_t . Its purpose is to give the CDC AC Cl ss set of callback functions to be called when a CDC ACM event occurs. Not all callbacks are mandatory and a null pointer ( NULL ) can be passed in the callbacks structure variable when the callback is not needed. The table below describes each configuration field available in this configuration structure.
Table – sl_usbd_cdc_acm _callbacks_t Configuration Structure
ველები
აღწერა
.enable
გამოიძახება, როდესაც USB კლასის ეგზემპლარი ჩართულია
წარმატებით.
.disable
Called when the USB class instance is disabled.
.line_control_changed Called when a line control change is received.
line_coding_changed გამოიძახება ხაზის კოდირების ცვლილების მიღებისას.
Function Signature
void app_usbd_cdc_acm_enable(uint8_t subclass_nbr);
void app_usbd_cdc_acm_disable(uint8_t subclass_nbr);
void app_usbd_cdc_acm_line_control_changed(uint8_t subclass_nbr, uint8_t event, uint8_t event_chngd); bool app_usbd_cdc_acm_line_coding_changed(uint8_t subclass_nbr, subclass_nbr, sl_usbd_cdc_acm_line_coding_t
*p_line_coding
უკუკავშირის ფუნქციებისთვის იხილეთ განყოფილება „მოვლენის შეტყობინებების უკუკავშირის რეგისტრაცია“, მაგ.ampლე.
USB მოწყობილობის CDC ACM კლასის პროგრამირების სახელმძღვანელო
ეს განყოფილება განმარტავს, თუ როგორ გამოიყენოთ CDC აბსტრაქტული კონტროლის მოდელის კლასი. USB მოწყობილობის ინიციალიზაცია CDC ACM კლასის USB მოწყობილობის CDC ACM კლასის ეგზემპლარის დამატება თქვენს მოწყობილობაზე კომუნიკაცია CDC ACM კლასის გამოყენებით
Initializing the USB Device CDC ACM Class
To add CDC ACM class functionality to your device, you must first initialize the CDC base class and the ACM subclass by a a c lling the functions sl_usbd_cdc_init() nd sl_usbd_cdc_acm_init() . T a a a a a he ex mple below shows how to c ll sl_usbd_cdc_init() nd sl_usbd_cdc_acm_init() using def ult rguments.
Example – Initialization of CDC ACM Class
sl_status_t სტატუსი;
status = sl_usbd_cdc_init(); if (status ! SL_STATUS_OK) { /* An error occurred. Error handling should be added here. */
}
სტატუსი = sl_usbd_cdc_acm_init(); თუ (სტატუსი! SL_STATUS_OK) { /* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავება. */
}
Adding a USB Device CDC ACM Class Instance to Your Device
To add CDC ACM class functionality to your device, you must create an instance, then add it to your device’s configuration(s).
CDC ACM კლასის ინსტანციის შექმნა
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
24/174
დასრულდაview
CDC ACM კლასის ეგზემპლარის თქვენი მოწყობილობის კონფიგურაციაში დამატება. მოვლენების შეტყობინებების უკუკავშირის რეგისტრაცია.
CDC ACM კლასის ინსტანციის შექმნა
a a M a a a Cre te CDC AC cl ss inst nce by c lling the function sl_usbd_cdc_acm_create_instance() . T a a a M a a a he ex mple below shows how to cre te CDC AC cl ss inst nce vi sl_usbd_cdc_acm_create_instance() .
Example – Creating a CDC ACM Function via sl_usbd_cdc_acm_create_instance()
uint8_t ქვეკლასი_nbr; sl_status_t სტატუსი;
status = sl_usbd_cdc_acm_create_instance(64u, SL_USBD_ACM_SERIAL_CALL_MGMT_DATA_CCI_DCI | SL_USBD_ACM_SERIAL_CALL_MGMT_DEV, NULL, &subclass_nbr);
თუ (სტატუსი! SL_STATUS_OK) { /* შეცდომა მოხდა. შეცდომების დამუშავება აქ უნდა დაემატოს. */
}
CDC ACM კლასის ეგზემპლარის დამატება თქვენი მოწყობილობის კონფიგურაციაში (კონფიგურაციებში)
After you have created a CDC ACM class instance, you can add it to a configuration by calling the function
sl_usbd_cdc_acm_add_to_configuration() .
ქვემოთ მოცემული მაგალითი გვიჩვენებს, თუ როგორ უნდა დააკონფიგურიროთ sl_usbd_cdc_acm_add_to_configuration() ფუნქცია.
Example – Call to USBD ACM sl_usbd_cdc_acm_add_to_configuration()
sl_status_t სტატუსი;
status = sl_usbd_cdc_acm_add_to_configuration(subclass_nbr,
(1)
config_nbr_fs);
(2)
თუ (სტატუსი! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
a a a (1) Cl ss number to dd to the configur tion returned by sl_usbd_cdc_acm_create_instance() . (2) Configuration number (here adding it to a Full-Speed configuration).
ღონისძიების შეტყობინებების უკუკავშირის რეგისტრაცია
CDC ACM სერიულ კლასს შეუძლია აცნობოს თქვენს აპლიკაციას ხაზის კონტროლის ან კოდირების ნებისმიერი ცვლილების შესახებ შეტყობინების უკუკავშირის ფუნქციების მეშვეობით. უკუკავშირის ფუნქციების სტრუქტურა შეიძლება გადაეცეს არგუმენტად ACM ეგზემპლარის შექმნის დროს. გაითვალისწინეთ, რომ ეს უკუკავშირები არჩევითია. მაგ.ample – CDC ACM Callbacks Registration illustrates the use of the callback registration functions. Example – CDC ACM-ის უკუკავშირის იმპლემენტაცია აჩვენებს ყოფილსample of implementation of the callback functions.
Example – CDC ACM-ის უკუკავშირის რეგისტრაცია
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
25/174
დასრულდაview
uint8_t ქვეკლასი_nbr; sl_status_t სტატუსი;
sl_usbd_cdc_acm_callbacks_t sli_usbd_cdc_acm_callbacks = { app_usbd_cdc_acm_connect, app_usbd_cdc_acm_disconnect, app_usbd_cdc_acm_line_control_changed, app_usbd_cdc_acm_line_coding_changed, };
status = sl_usbd_cdc_acm_create_instance(64u, SL_USBD_ACM_SERIAL_CALL_MGMT_DATA_CCI_DCI | SL_USBD_ACM_SERIAL_CALL_MGMT_DEV, &sli_usbd_cdc_acm_callbacks, &subclass_nbr);
if (status ! SL_STATUS_OK) { /* An error occurred. Error handling should be added here. */ }
Example – CDC ACM-ის უკუკავშირის იმპლემენტაცია
bool app_usbd_cdc_acm_line_coding_changed (uint8_t
subclass_nbr,
sl_usbd_cdc_acm_line_coding_t *p_line_coding)
{
uint32_t baudrate_new;
uint8_t პარიტეტი_ახალი;
uint8_t stop_bits_new;
uint8_t data_bits_new;
/* TODO Apply new line coding.*/ baudrate_new = p_line_coding->BaudRate; parity_new = p_line_coding->Parity; stop_bits_new = p_line_coding->StopBits; data_bits_new = p_line_coding->DataBits;
return (true);
(1)
}
void app_usbd_cdc_acm_line_control_changed (uint8_t subclass_nbr, uint8_t event, uint8_t event_changed)
{ bool rts_state; bool rts_state_changed; bool dtr_state; bool dtr_state_changed; bool brk_state; bool brk_state_changed;
/* დავალება ახალი ხაზის კონტროლის გამოყენება. */ rts_state = ((event & SL_USBD_CDC_ACM_CTRL_RTS) ! 0) ? true : false; rts_state_changed = ((event_changed & SL_USBD_CDC_ACM_CTRL_RTS) ! 0) ? true : false; dtr_state = ((event & SL_USBD_CDC_ACM_CTRL_DTR) ! 0) ? true : false; dtr_state_changed = ((event_changed & SL_USBD_CDC_ACM_CTRL_DTR) ! 0) ? true : false; brk_state = ((event & SL_USBD_CDC_ACM_CTRL_BREAK) ! 0) ? true : false; brk_state_changed = ((event_changed & SL_USBD_CDC_ACM_CTRL_BREAK) ! 0) ? true : false;
}
(1) It is important to return false to this function if the line coding applying failed. Otherwise, return true.
Communicating Using the CDC ACM Class
Serial Status
Line Coding Line Control
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
26/174
დასრულდაview
ხაზის მდგომარეობის ქვეკლასის ეგზემპლარის კომუნიკაცია
Serial Status
ხაზის კოდირება
The USB host controls the line coding (baud rate, parity, etc) of the CDC ACM device. When necessary, the application is responsible for setting the line coding. There are two functions provided to retrieve and set the current line coding, as described in the table below.
Table – CDC ACM Line Coding Functions
ფუნქცია
sl_usbd_cdc_acm_g e t_line _cod ing ()
sl_usbd_cdc_acm_s e t_line _co d ing ()
აღწერა
Your application can get the current line coding settings set either from the host with SetLineCoding requests or with the function sl_usbd_cdc_acm_set_line_coding() .
Your application can set the line coding. The host can retrieve the settings with the GetLineCoding request.
ხაზის კონტროლი
The USB host controls the line control (RTS and DTR pins, break signal, and so on) of the CDC ACM device. When necessary, your application is responsible for applying the line controls. A function is provided to retrieve and set the current line controls, as are described in the table below.
ცხრილი – CDC ACM ხაზის კონტროლის ფუნქციები
ფუნქცია
sl_usb d _cd c_acm_g e t_line _co ntr o l_state ()
თქვენს აპლიკაციას შეუძლია მიიღოს ჰოსტის მიერ დაყენებული მიმდინარე საკონტროლო ხაზის მდგომარეობა SetControlLineState მოთხოვნის გამოყენებით.
ხაზის სახელმწიფო
USB ჰოსტი ხაზის მდგომარეობას რეგულარული ინტერვალებით იღებს. თქვენმა აპლიკაციამ ხაზის მდგომარეობა ყოველ ჯერზე უნდა განაახლოს. საჭიროების შემთხვევაში, თქვენი აპლიკაცია პასუხისმგებელია ხაზის მდგომარეობის დაყენებაზე. მიმდინარე ხაზის კონტროლის მისაღებად და დასაყენებლად გათვალისწინებულია ორი ფუნქცია, როგორც ეს აღწერილია ქვემოთ მოცემულ ცხრილში.
Table – CDC ACM Line S tate Functions
ფუნქცია
sl_usb d _cd c_acm_se t _line _state _e v e nt()
sl_usbd_cdc_acm_cle ar_line _state _e v e nt()
თქვენს აპლიკაციას შეუძლია დააყენოს ხაზის მდგომარეობის ნებისმიერი მოვლენა(ები). ხაზის მდგომარეობის დაყენებისას, ჰოსტს ეგზავნება შეწყვეტის შემავალი შეტყობინება, რათა შეატყობინოს მას სერიული ხაზის მდგომარეობის ცვლილების შესახებ.
Application can clear two events of the line state: transmission carrier and receiver carrier detection. All the other events are self-cleared by the ACM serial emulation subclass.
Subclass Instance Communication
Silicon Labs’ ACM subclass offers the following functions to communicate with the host. For more details about the functions9 parameters, see the CDC ACM Subclass Functions reference.
ფუნქციის სახელი
sl_usb d _cd c_acm_ re ad () sl_usb d _cd c_acm_write ()
ოპერაცია
Receives data from host through a bulk OUT endpoint. This function is blocking. Sends data to host through a bulk IN endpoint. This function is blocking.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
27/174
დასრულდაview
ცხრილი – CDC ACM Communication API-ის შეჯამება aaaaa sl_usbd_cdc_acm_read() და sl_usbd_cdc_acm_write() უზრუნველყოფენ სინქრონულ კომუნიკაციას, რაც ნიშნავს, რომ გადაცემის ბლოკირება ხდება. სხვა სიტყვებით რომ ვთქვათ, ფუნქციის გამოძახებისას, აპლიკაცია იბლოკება გადაცემის დასრულებამდე, შეცდომით ან მის გარეშე. შესაძლებელია დროის ამოწურვის მითითება, რათა თავიდან იქნას აცილებული მუდმივი ლოდინი. მაგ.ample below shows a read and write example that receives data from the host using the bulk OUT endpoint and sends data to the host using the bulk IN endpoint.
Listing – Serial Read and Write Example
__ALIGNED(4) uint8_t rx_buf[2];
__ALIGNED(4) uint8_t tx_buf[2];
uint32_t
xfer_len;
sl_status_t
სტატუსი;
სტატუსი = sl_usbd_cdc_acm_read(subclass_nbr,
(1)
rx_buf,
(2)
2u,
0u,
(3)
&xfer_len);
თუ (სტატუსი! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
სტატუსი = sl_usbd_cdc_acm_write(subclass_nbr,
(1)
tx_buf,
(4)
2u,
0u,
(3)
&xfer_len);
თუ (სტატუსი! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
T aaaaa M (1) sl_usbd_cdc_acm_create_instance()-ით შექმნილი კლასის ინსტანციის ნომერი უზრუნველყოფს AC ქვეკლასის შიდა მითითებას, რათა მოხდეს გადაცემის შესაბამის ნაყარი OUT ან IN საბოლოო წერტილამდე მარშრუტიზაცია. (2) თქვენმა აპლიკაციამ უნდა უზრუნველყოს, რომ ფუნქციისთვის მოწოდებული ბუფერი საკმარისად დიდია ყველა მონაცემის დასატევად. წინააღმდეგ შემთხვევაში, შეიძლება წარმოიშვას სინქრონიზაციის პრობლემები. (3) უსასრულო ბლოკირების სიტუაციის თავიდან ასაცილებლად, მიუთითეთ მილიწამებში გამოხატული ტაიმ-აუტი. 809 მნიშვნელობა აპლიკაციის დავალებას სამუდამოდ ლოდინს აიძულებს. (4) აპლიკაცია უზრუნველყოფს ინიციალიზებული გადაცემის ბუფერს.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
28/174
დასრულდაview
დასრულდაview
USB მოწყობილობის HID კლასი
USB Device HID Class Overview USB Device HID Class Resource Needs from Core USB Device HID Class Configuration USB Device HID Class Programming Guide HID Periodic Input Reports Task
ეს განყოფილება აღწერს Silicon Labs-ის USB მოწყობილობის მიერ მხარდაჭერილ ადამიანის ინტერფეისის მოწყობილობის (HID) კლასს.
The HID class encompasses devices used by humans to control computer operations, such as keyboards, mice, pointing devices, and game devices.
The HID class can also be used in a composite device that contains controls such as knobs, switches, buttons, and sliders. For exampაუდიო ყურსასმენში ხმის, დადუმებისა და გამორთვის კონტროლი ყურსასმენის HID ფუნქციით კონტროლდება. HID კლასს შეუძლია მონაცემების გაცვლა ნებისმიერი მიზნით, მხოლოდ კონტროლისა და შეფერხების გადაცემის გამოყენებით.
The HID class is one of the oldest and most widely-used USB classes. All the major host operating systems provide a native driver to manage HID devices, which is why a variety of vendor-specific devices work with the HID class. This class also includes various types of output items such as LEDs, audio, tactile feedback, etc.
The HID implementation complies with the following specifications:
ადამიანის ინტერფეისის მოწყობილობების (HID) მოწყობილობის კლასის განმარტება, 27/6/01, ვერსია 1.11. უნივერსალური სერიული ავტობუსის HID გამოყენების ცხრილები, 28/10/2004, ვერსია 1.12.
USB Device HID Class Overview
დასრულდაview
HID მოწყობილობა შედგება შემდეგი საბოლოო წერტილებისგან:
A pair of control IN and OUT endpoints called the default endpoint An interrupt IN endpoint An optional interrupt OUT endpoint
The table below describes the usage of the different endpoints:
Table – HID Class Endpoints Usage
Endpoint Direction Usage
კონტროლი IN
კონტროლი
გარეთ
Interrupt IN
შეწყვეტა
გარეთ
Deviceto-host
Host-todevice
Deviceto-host
Host-todevice
ჩამოთვლის სტანდარტული მოთხოვნები, კლასის სპეციფიკური მოთხოვნები და მონაცემთა კომუნიკაცია (შეყვანა, ფუნქციების ანგარიშები, რომლებიც იგზავნება მასპინძელთან GET_REPORT მოთხოვნით). ჩამოთვლის სტანდარტული მოთხოვნები, კლასის სპეციფიკური მოთხოვნები და მონაცემთა კომუნიკაცია (გამომავალი, ფუნქციების ანგარიშები, რომლებიც მიღებულია მასპინძელისგან SET_REPORT მოთხოვნით). მონაცემთა კომუნიკაცია (შეყვანა და ფუნქციების ანგარიშები).
Data communication (Output and Feature reports).
მოხსენება
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
29/174
დასრულდაview
მასპინძელი და HID მოწყობილობა მონაცემებს ანგარიშების გამოყენებით ცვლიან. ანგარიში შეიცავს ფორმატირებულ მონაცემებს, რომლებიც ინფორმაციას გვაწვდიან HID მოწყობილობის მართვის საშუალებებისა და სხვა ფიზიკური ერთეულების შესახებ. მართვის საშუალება მომხმარებლის მიერ მანიპულირებადია და მოწყობილობის ერთ ასპექტს მართავს. მაგალითადampმაგალითად, მართვის საშუალება შეიძლება იყოს მაუსის ან კლავიატურის ღილაკი, გადამრთველი და ა.შ. სხვა ობიექტები მომხმარებელს აწვდიან ინფორმაციას მოწყობილობის გარკვეული ფუნქციების მდგომარეობის შესახებ. მაგალითადample, LEDs on a keyboard notify the user about the caps lock on, the numeric keypad active, etc.
ანგარიშის მონაცემების ფორმატი და გამოყენება მასპინძელს ესმის ანგარიშის აღმწერის შინაარსის ანალიზით. შინაარსის ანალიზს ახორციელებს პარსერი. ანგარიშის აღმწერი აღწერს მოწყობილობაში თითოეული კონტროლის მიერ მოწოდებულ მონაცემებს. იგი შედგება ელემენტებისგან, რომლებიც წარმოადგენს მოწყობილობის შესახებ ინფორმაციის ნაწილებს და შედგება 1 ბაიტიანი პრეფიქსისა და ცვლადი სიგრძისგან.
data. For more details about the item format, refer to <Device Class Definition for Human Interface Devices (HID) Version
1.11=, პუნქტი 5.6 და 6.2.2.
There are three principal types of items:
მთავარი ელემენტი განსაზღვრავს ან აჯგუფებს მონაცემთა ველების გარკვეულ ტიპებს.
Global item describes data characteristics of a control.
Local item describes data characteristics of a control.
Each item type is defined by different functions. An item function can also be called a tag. An item function can be seen as a sub-item that belongs to one of the three principal item types. The table below provides a brief overview of the item9s functions in each item type. For a complete description of the items in each category, see <Device Class Definition for Human Interface Devices (HID) Version 1.11=, section 6.2.2.
Table – Item’s Function Description for Each Item Type
Item Item Type Function
აღწერა
მთავარი შეყვანა
Describes information about the data provided by one or more physical controls.
Main Output Describes data sent to the device.
მთავარი მახასიათებელი
Describes device configuration information sent to or received from the device which influences the overall behavior of the device or one of its components.
კოლექციის მთავარ ჯგუფთან დაკავშირებული ერთეულები (შეყვანა, გამომავალი ან ფუნქცია).
Main End of Closes a collection. Collection
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
30/174
დასრულდაview
Item Item Type Function
აღწერა
Global Usage Page
განსაზღვრავს მოწყობილობაში ხელმისაწვდომ ფუნქციას.
Global Logical Defines the lower limit of the reported values in logical units. Minimum
Global Logical Defines the upper limit of the reported values in logical units. Maximum
Global Physical Defines the lower limit of the reported values in physical units, that is the Logical Minimum Minimum expressed in physical units.
Global Physical Defines the upper limit of the reported values in physical units, that is the Logical Maximum Maximum expressed in physical units.
Global Unit
Indicates the unit exponent in base 10. The exponent ranges from -8 to +7.
ექსპონენტი
Global Unit
Indicates the unit of the reported values. For instance, length, mass, temperature units, etc.
Global Report Size
Indicates the size of the report fields in bits.
გლობალური ანგარიშის ID მიუთითებს კონკრეტულ ანგარიშზე დამატებულ პრეფიქსზე.
Global Report Count
Indicates the number of data fields for an item.
Global Push
ათავსებს გლობალური ელემენტის მდგომარეობის ცხრილის ასლს CPU დასტაზე.
გლობალური პოპი
Replaces the item state table with the last structure from the stack.
Local Usage
Represents an index to designate a specific Usage within a Usage Page. It indicates the vendor9s suggested use for a specific control or group of controls. A usage supplies information to an application developer about what a control is actually measuring.
Local Usage
Defines the starting usage associated with an array or bitmap.
მინიმალური
Local Usage
Defines the ending usage associated with an array or bitmap.
მაქსიმალური
Local Designator Determines the body part used for a control. Index points to a designator in the Physical
ინდექსი
აღმწერი.
Local Designator Defines the index of the starting designator associated with an array or bitmap. Minimum
Local Designator Defines the index of the ending designator associated with an array or bitmap. Maximum
ლოკალური სტრიქონის ინდექსი
სტრიქონის აღმწერის სტრიქონის ინდექსი. ის საშუალებას იძლევა, სტრიქონი კონკრეტულ ელემენტთან ან კონტროლთან ასოცირდეს.
ლოკალური სტრიქონი
Specifies the first string index when assigning a group of sequential strings to controls in an array
Minimum or bitmap.
Local Local
String Maximum
გამსაზღვრელი
განსაზღვრავს ბოლო სტრიქონის ინდექსს, როდესაც მასივში ან ბიტმაპში არსებულ კონტროლებს ენიჭება თანმიმდევრული სტრიქონების ჯგუფი.
განსაზღვრავს ლოკალური ელემენტების ნაკრების დასაწყისს ან დასასრულს.
A control9s data must define at least the following items:
Input, Output or Feature Main items Usage Local item Usage Page Global item Logical Minimum Global item Logical Maximum Global item Report Size Global item
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
31/174
დასრულდაview
ანგარიშების რაოდენობა გლობალური ერთეული ქვემოთ მოცემულ ცხრილში ნაჩვენებია მაუსის ანგარიშის აღმწერის შინაარსის წარმოდგენა ჰოსტის HID პარსერის პერსპექტივიდან. მაუსს აქვს სამი ღილაკი (მარცხენა, მარჯვენა და ბორბალი). კოდი წარმოდგენილია ექსში.ampქვემოთ მოცემულია კოდის იმპლემენტაცია, რომელიც შეესაბამება მაუსის ანგარიშის აღმწერის ამ წარმოდგენას.
სურათი - ანგარიშის აღმწერის შინაარსი მასპინძელი HID ანალიზატორიდან View
(1) გამოყენების გვერდის ფუნქცია განსაზღვრავს მოწყობილობის ზოგად ფუნქციას. ამ შემთხვევაშიampანუ, HID მოწყობილობა ეკუთვნის
generic desktop control.
(2) კოლექცია აპლიკაცია აჯგუფებს ძირითად ელემენტებს, რომლებსაც აქვთ საერთო დანიშნულება და შესაძლოა ნაცნობი იყვნენ აპლიკაციებისთვის. დიაგრამაზე ჯგუფი შედგება სამი შეყვანის ძირითადი ელემენტისგან. ამ კოლექციისთვის, მართვის საშუალებების რეკომენდებული გამოყენებაა მაუსი, როგორც ეს მითითებულია გამოყენების პუნქტში. (3) ჩადგმული კოლექციები შეიძლება გამოყენებულ იქნას აპლიკაციებისთვის ერთი მართვის ან მართვის საშუალებების ჯგუფის გამოყენების შესახებ დამატებითი დეტალების მისაწოდებლად. ამ მაგალითშიample, the Collection Physical, nested into the Collection Application, is composed of the same three Input items forming the Collection Application. The Collection Physical is used for a set of data items that represent data points collected at one geometric point. In the exampმაგალითად, შემოთავაზებული გამოყენება არის მაჩვენებელი, როგორც ეს მითითებულია გამოყენების პუნქტში. აქ მაჩვენებელის გამოყენება ეხება მაუსის პოზიციის კოორდინატებს და სისტემის პროგრამული უზრუნველყოფა გადათარგმნის მაუსის კოორდინატებს ეკრანის კურსორის მოძრაობისას. (4) ასევე შესაძლებელია ჩადგმული გამოყენების გვერდები, რომლებიც უფრო მეტ დეტალს გვაწვდიან მოწყობილობის ზოგადი ფუნქციის გარკვეული ასპექტის შესახებ. ამ შემთხვევაში, ორი შეყვანის პუნქტი დაჯგუფებულია და შეესაბამება მაუსის ღილაკებს. ერთი შეყვანის პუნქტი განსაზღვრავს მაუსის სამ ღილაკს (მარჯვენა, მარცხენა და ბორბალი) პუნქტისთვის მონაცემთა ველების რაოდენობის (ანგარიშის რაოდენობის პუნქტი), მონაცემთა ველის ზომის (ანგარიშის ზომის პუნქტი) და თითოეული მონაცემთა ველის შესაძლო მნიშვნელობების მიხედვით (გამოყენების მინიმალური და მაქსიმალური, ლოგიკური მინიმალური და მაქსიმალური პუნქტები). მეორე შეყვანის პუნქტი არის 13-ბიტიანი მუდმივა, რომელიც საშუალებას იძლევა შეყვანის ანგარიშის მონაცემები გასწორდეს ბაიტის საზღვარზე. ეს შეყვანის პუნქტი გამოიყენება მხოლოდ შევსების მიზნით. (5) მაუსის პოზიციის კოორდინატებისთვის განსაზღვრულია კიდევ ერთი ჩადგმული გამოყენების გვერდი, რომელიც ეხება ზოგად სამუშაო მაგიდის კონტროლს. ამ გამოყენების გვერდისთვის, შეყვანის პუნქტი აღწერს მონაცემთა ველებს, რომლებიც შეესაბამება x და y ღერძებს, როგორც ეს მითითებულია ორი გამოყენების პუნქტით.
ნივთები.
After analyzing the previous mouse Report descriptor content, the host9s HID parser is able to interpret the Input report data sent by the device with an interrupt IN transfer or in response to a GET_REPORT request. The Input report data corresponding to the mouse Report descriptor shown in Figure – Report Descriptor Content from a Host HID Parser View is
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
32/174
დასრულდაview
shown in the table below. The total size of the report data is 4 bytes. Different types of reports may be sent over the same endpoint. For the purpose of distinguishing the different types of reports, a 1-byte report ID prefix is added to the data report. If a report ID was used in the example of the mouse report, the total size of the report data would be 5 bytes.
ცხრილი – ჰოსტისთვის გაგზავნილი შეყვანის ანგარიში, რომელიც შეესაბამება 3 ღილაკიან მაუსის მდგომარეობას
ბიტი ოფსეტი
0 1 2 3 16 24
ბიტების რაოდენობა 1 1 1 13 8 8
Description Button 1 (left button). Button 2 (right button). Button 3 (wheel button). Not used. Position on axis X. Position on axis Y.
A Physical descriptor indicates the part or parts of the body intended to activate a control or controls. An application may use this information to assign a functionality to the control of a device. A Physical descriptor is an optional class-specific descriptor and most devices have little gain for using it. Refer to <Device Class Definition for Human Interface Devices (HID) Version 1.11= section 6.2.3 for more details about this descriptor.
USB Device HID Class Resource Needs from Core
ყოველ ჯერზე, როდესაც თქვენ დაამატებთ HID კლასის ინსტანციას USB კონფიგურაციაში sl_usbd_hid_add_to_configuration() ფუნქციის გამოძახების გზით, ბირთვიდან გამოიყოფა შემდეგი რესურსები.
რესურსი
Interfaces Alternate interfaces Endpoints Interface groups
რაოდენობა
1 1 1 (2 თუ შეწყვეტის OUT ბოლო წერტილი ჩართულია) 0
Note that those numbers are per configuration. When setting up your SL_USBD_INTERFACE_QUANTITY , SL_USBD_ALT_INTERFACE_QUANTITY , SL_USBD_INTERFACE_GROUP_QUANTITY and SL_USBD_DESCRIPTOR_QUANTITY configuration values, don’t forget to take into account on how many configurations the class will be added. For the SL_USBD_OPEN_ENDPOINTS_QUANTITY configuration value, since endpoints are opened only when a configuration is set by the host, you just need to take into account the number of needed endpoints for a class instance.
USB Device HID Class Configuration
Two groups of configuration parameters are used to configure the HID class:
USB Device HID Class Application-Specific Configurations USB Device HID Class Instance Configurations
USB Device HID Class Application-Specific Configurations
First, to use the Silicon Labs USB device HID class module, adjust the HID compile-time configuration defines according to your application needs. They are regrouped inside the sl_usbd_core_config.h header file under the HID section. They can be divided into two sections, the quantity configurations and the HID task configurations. The quantity configurations purpose is to inform the USB device module about how many USB HID objects to allocate.
The table below describes each configuration define.
ცხრილი – USB მოწყობილობის HID კონფიგურაციის განსაზღვრებები
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
33/174
დასრულდაview
კონფიგურაციის სახელი
SL_USBD_HID_CL ASS_I NSTANCE_QUANTITY
SL_USBD_HID_CONFIG URATION_QUANTITY
SL_USBD_HID_REPORT_ ID_QUANTITY
SL_USBD_HID_PUSH_P OP_ITEM_QUANTITY
SL_USBD_HID_TIMER_T ASK_STACK_SIZE
SL_USBD_HID_TIMER_T ASK_PRIORITY
აღწერა
Number of class instances you will allocate via a call to the function
sl_usbd_hid_create_instance().
კონფიგურაციების რაოდენობა. HID კლასის ინსტანციების დამატება შესაძლებელია ერთ ან რამდენიმე aaaa კონფიგურაციაში, sl_usbd_hid_add_to_configuration() ფუნქციის გამოყენებით. აკონფიგურირებს გამოსაყოფი ანგარიშის ID-ების საერთო რაოდენობას.
Configures the total number of Push/Pop items to allocate.
The timer task handles all the timer-based HID operations. This configuration allows you to set the stack size (in number of bytes). Priority of HID task. his is a CMSIS-RTOS2 priority.
ნაგულისხმევი მნიშვნელობა
2 1 2 0 2048
osPriorityHigh
USB Device HID Class Instance Configurations Class Instance Creation subclass
protocol country_code
interval_in and interval_out p_hid_callback HID Class Report Descriptor Example This section defines the configurations related to the HID class instances.
Class Instance Creation
Creating a HID class instance is done by calling the function a a a sl_usbd_hid_create_instance() , which t kes sever l configur tion arguments that are described below.
subclass
HID ქვეკლასის კოდი. შესაძლო მნიშვნელობებია:
SL_USBD_HID_SUBCL ASS_NONE SL_USBD_HID_SUBCL ASS_BOOT
A HID device that uses the boot subclass must use standard report formats. For more information on the subclass codes, see section 4.2 of HID specification revision 1.11.
პროტოკოლი
Protocol used by the HID device. Possible values are:
SL_USBD_HID_PROTOCOL_NONE SL_USBD_HID_PROTOCOL_KBD SL_USBD_HID_PROTOCOL_MOUSE
თუ თქვენი HID ფუნქცია მაუსია, პროტოკოლი უნდა იყოს დაყენებული SL_USBD_HID_PROTOCOL_MOUSE-ზე. თუ ეს კლავიატურაა, ის უნდა იყოს დაყენებული SL_USBD_HID_PROTOCOL_KBD-ზე. წინააღმდეგ შემთხვევაში, პროტოკოლი უნდა იყოს დაყენებული SL_USBD_HID_PROTOCOL_NONE-ზე. ქვეკლასების კოდების შესახებ დამატებითი ინფორმაციისთვის იხილეთ HID სპეციფიკაციის 1.11 ვერსიის 4.3 ნაწილი.
country_code
ID of the country code. Possible values are:
SL_USBD_HID_COUNTRY_CODE_NOT_SUPPORTED
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
34/174
დასრულდაview
SL_USBD_HID_COUNTRY_CODE_ARABIC SL_USBD_HID_COUNTRY_CODE_BELGIAN SL_USBD_HID_COUNTRY_CODE_CANADIAN_BILINGUAL SL_USBD_HID_COUNTRY_CODE_CANADIAN_FRENCH SL_USBD_HID_COUNTRY_CODE_CZECH_REPUBLIC SL_USBD_HID_COUNTRY_CODE_DANISH SL_USBD_HID_COUNTRY_CODE_FINNISH SL_USBD_HID_COUNTRY_CODE_FRENCH SL_USBD_HID_COUNTRY_CODE_GERMAN SL_USBD_HID_COUNTRY_CODE_GREEK SL_USBD_HID_COUNTRY_CODE_HEBREW SL_USBD_HID_COUNTRY_CODE_HUNGARY SL_USBD_HID_COUNTRY_CODE_INTERNATIONAL SL_USBD_HID_COUNTRY_CODE_ITALIAN SL_USBD_HID_COUNTRY_CODE_JAPAN_KATAKANA SL_USBD_HID_COUNTRY_CODE_KOREAN SL_USBD_HID_COUNTRY_CODE_L ATIN_AMERICAN SL_USBD_HID_COUNTRY_CODE_NETHERL ANDS_DUTCH SL_USBD_HID_COUNTRY_CODE_NORWEGIAN SL_USBD_HID_COUNTRY_CODE_PERSIAN_FARSI SL_USBD_HID_COUNTRY_CODE_POL AND SL_USBD_HID_COUNTRY_CODE_PORTUGUESE SL_USBD_HID_COUNTRY_CODE_RUSSIA SL_USBD_HID_COUNTRY_CODE_SLOVAKIA SL_USBD_HID_COUNTRY_CODE_SPANISH SL_USBD_HID_COUNTRY_CODE_SWEDISH SL_USBD_HID_COUNTRY_CODE_SWISS_FRENCH SL_USBD_HID_COUNTRY_CODE_SWISS_GERMAN SL_USBD_HID_COUNTRY_CODE_SWITZERL AND SL_USBD_HID_COUNTRY_CODE_TAIWAN SL_USBD_HID_COUNTRY_CODE_TURKISH_Q SL_USBD_HID_COUNTRY_CODE_UK SL_USBD_HID_COUNTRY_CODE_US SL_USBD_HID_COUNTRY_CODE_YUG OSL AVIA SL_USBD_HID_COUNTRY_CODE_TURKISH_F
ქვეყნის კოდი განსაზღვრავს, თუ რომელი ქვეყნისთვის არის ლოკალიზებული აპარატურა. აპარატურის უმეტესობა არ არის ლოკალიზებული და შესაბამისად, ეს საკონტროლო მნიშვნელობა იქნება SL_USBD_HID_COUNTRY_CODE_NOT_SUPPORTED (0). თუმცა, კლავიატურაზე შეგიძლიათ გამოიყენოთ ეს ველი კლავიშების ენის მითითებისთვის.
ქვეყნის კოდების შესახებ დამატებითი ინფორმაციისთვის იხილეთ HID სპეციფიკაციის 1.11 გადახედვის 6.2.1 ნაწილი.
interval_in and interval_out
interval_in and interval_out represent the polling interval of the IN interrupt endpoint and the OUT interrupt endpoint.
This represents the polling interval of the endpoint, in milliseconds. Setting this value depends on how frequently your device is susceptible to generate a new report for the host. For instance, if a report is generated every 16 milliseconds, the interval should be 16 or less.
The value must be a power of 2 (1, 2, 4, 8, 16, etc.).
interval_out v lue იგნორირებული იქნება, თუ ctrl_rd_en დაყენებულია true-ზე.
p_hid_callback
აააა p_hid_callback არის sl_usbd_hid_callbacks_t ტიპის სტრუქტურის მაჩვენებელი. მისი დანიშნულებაა HID Cl ss-ისთვის HID მოვლენის გამოძახებისას გამოსაძახებელი უკუკავშირის ფუნქციების ნაკრების მინიჭება.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
35/174
დასრულდაview
ყველა უკუკავშირი სავალდებულო არ არის და ნულოვანი მაჩვენებელი (NULL) შეიძლება გადაეცეს უკუკავშირის სტრუქტურის ცვლადს, როდესაც უკუკავშირი არ არის საჭირო. ქვემოთ მოცემულ ცხრილში აღწერილია ამ კონფიგურაციის სტრუქტურაში ხელმისაწვდომი თითოეული კონფიგურაციის ველი.
ცხრილი – sl_usbd_hid_callbacks_t კონფიგურაციის სტრუქტურა
ველები
აღწერა
Function Signature
.enable .disable .get_report_desc
.get_phy_desc
.set_output_report .get_feature_report .set_feature_report
Called when the USB class instance is enabled successfully. Called when the USB class instance is disabled.
Called during the HID Instance creation to pass your report descriptor. For each of your HID functions, you must provide a report descriptor. The report descriptor indicates to the host how the periodic report that will be sent by the device should be parsed. Writing your own report descriptor can be challenging, and that is why there are some resources to help. This is the only mandatory callback function. Called during the HID Instance creation to pass your physical descriptor. The physical descriptor is a descriptor that provides information about the specific part or parts of the human body that are activating a control or controls. For more information on physical descriptors, see section 6.2.3 of HID specification revision 1.11. The physical descriptor is optional and most of the time ignored. The buffer passed here can be set to NULL and the length set to 0. Called when the host sets a report as described in your report descriptor (when it sends a report).
გამოიძახება, როდესაც მასპინძელი ითხოვს ფუნქციის ანგარიშს, როგორც ეს აღწერილია თქვენი ანგარიშის აღწერილობაში.
გამოიძახება, როდესაც ჰოსტი აყენებს ფუნქციის ანგარიშს, როგორც ეს აღწერილია თქვენი ანგარიშის აღწერილობაში.
void app_usbd_hid_enable(uint8_t class_nbr); void app_usbd_hid_disable(uint8_t class_nbr); void app_usbd_hid_get_report_desc(uint8_t class_nbr, const uint8_t *p_report_ptr, uint16_tp_report_len);
void app_usbd_hid_get_phy_desc(uint8_t class_nbr, const uint8_t *p_report_ptr, uint16_tp_report_len);
void app_usbd_hid_set_output_report(uint8_t class_nbr, uint8_t report_id, uint8_t *p_report_buf, uint16_t report_len); void app_usbd_hid_get_feature_report(uint8_t class_nbr, uint8_t report_id, uint8_t *p_report_buf, uint16_t report_len); void app_usbd_hid_set_feature_report(uint8_t class_nbr, uint8_t report_id, uint8_t *p_report_buf, uint16_t report_len);
.get_protocol
იღებს მიმდინარე აქტიურ პროტოკოლს.
void app_usbd_hid_get_protocol(uint8_t class_nbr, uint8_t *p_protocol);
.set_protocol
Sets current active protocol.
void app_usbd_hid_set_protocol(uint8_t class_nbr, uint8_t პროტოკოლი);
HID Class Report Descriptor Example
Silicon Labs-ის HID კლასიample application provides an example of a report descriptor for a simple mouse. The example below shows a mouse report descriptor.
Example – Mouse Report Descriptor
static uint8_t app_usbd_hid_report_desc[] = {
(1) (2)
SL_USBD_HID_GLOBAL_USAGE_PAGE + 1, SL_USBD_HID_USAGE_PAGE_GENERIC_DESKTOP_CONTROLS,
SL_USBD_HID_LOCAL_USAGE + 1, SL_USBD_HID_CA_MOUSE,
(3)
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
36/174
დასრულდაview
SL_USBD_HID_MAIN_COLLECTION +1, SL_USBD_HID_COLLECTION_APPLICATION,(4)
SL_USBD_HID_LOCAL_USAGE +1, SL_USBD_HID_CP_POINTER,(5)
SL_USBD_HID_MAIN_COLLECTION +1, SL_USBD_HID_COLLECTION_PHYSICAL,(6)
SL_USBD_HID_GLOBAL_USAGE_PAGE +1, SL_USBD_HID_USAGE_PAGE_BUTTON,(7)
SL_USBD_HID_LOCAL_USAGE_MIN +1,0 01,
SL_USBD_HID_LOCAL_USAGE_MAX +1,0 03,
SL_USBD_HID_GLOBAL_LOG_MIN +1,0 00,
SL_USBD_HID_GLOBAL_LOG_MAX +1,0 01,
SL_USBD_HID_GLOBAL_REPORT_COUNT +1,0 03,
SL_USBD_HID_GLOBAL_REPORT_SIZE +1,0 01,
SL_USBD_HID_MAIN_INPUT +1, SL_USBD_HID_MAIN_DATA |
SL_USBD_HID_MAIN_VARIABLE |
SL_USBD_HID_MAIN_ABSOLUTE,
SL_USBD_HID_GLOBAL_REPORT_COUNT +1,0 01,(8)
SL_USBD_HID_GLOBAL_REPORT_SIZE +1,0 0D,
SL_USBD_HID_MAIN_INPUT +1, SL_USBD_HID_MAIN_CONSTANT,(9)
SL_USBD_HID_GLOBAL_USAGE_PAGE +1, SL_USBD_HID_USAGE_PAGE_GENERIC_DESKTOP_CONTROLS,
SL_USBD_HID_LOCAL_USAGE +1, SL_USBD_HID_DV_X,
SL_USBD_HID_LOCAL_USAGE +1, SL_USBD_HID_DV_Y,
SL_USBD_HID_GLOBAL_LOG_MIN +1,0 81,
SL_USBD_HID_GLOBAL_LOG_MAX +1,0 7F,
SL_USBD_HID_GLOBAL_REPORT_SIZE +1,0 08,
SL_USBD_HID_GLOBAL_REPORT_COUNT +1,0 02,
SL_USBD_HID_MAIN_INPUT +1, SL_USBD_HID_MAIN_DATA |
SL_USBD_HID_MAIN_VARIABLE |
SL_USBD_HID_MAIN_RELATIVE,
SL_USBD_HID_MAIN_ENDკოლექცია,(10)
SL_USBD_HID_MAIN_ENDCOLLECTION
(11)};
(1) მაუსის ანგარიშის აღმწერის წარმომადგენელი ცხრილი ინიციალიზებულია ისე, რომ თითოეული ხაზი შეესაბამება მოკლე ელემენტს. ეს უკანასკნელი ჩამოყალიბებულია 1-ბაიტიანი პრეფიქსისა და 1-ბაიტიანი მონაცემებისგან. იხილეთ viewed by a host HID parser in Figure – Report Descriptor Content from a Host HID Parser View.
(2) გამოყენებულია ზოგადი სამუშაო მაგიდის გამოყენების გვერდი.
(3) ზოგადი სამუშაო მაგიდის გამოყენების გვერდზე, გამოყენება tag suggests that the group of controls is for controlling a mouse. A mouse collection typically consists of two axes (X and Y) and one, two, or three buttons.
(4) The mouse collection is started.
(5) Within the mouse collection, a usage tag უფრო კონკრეტულად მიუთითებს, რომ მაუსის კონტროლი მაჩვენებლის კოლექციას ეკუთვნის. მაჩვენებლის კოლექცია არის ღერძების კოლექცია, რომელიც წარმოქმნის მნიშვნელობას, რათა მიმართოს, მიუთითოს ან მიუთითოს მომხმარებლის განზრახვებზე აპლიკაციაზე.
(6) მაჩვენებლის შეგროვება დაწყებულია.
(7) The Buttons Usage Page defines an Input item composed of three 1-bit fields. Each 1-bit field represents the mouse9s button 1, 2 and 3 respectively and can return a value of 0 or 1.
(8) The Input Item for the Buttons Usage Page is padded with 13 other bits.
(9) Another Generic Desktop Usage Page is indicated for describing the mouse position with the axes X and Y. The Input item is composed of two 8-bit fields whose value can be between -127 and 127.
(10) The pointer collection is closed.
(11) The mouse collection is closed.
USB.org HID გვერდი
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
37/174
დასრულდაview
The USB Implementers Forum (USB-IF) provides a tool called “HID Descriptor Tool” along with other information on the report descriptor format. Seehttp://www.usb.org/developers/hidpage/ for more information.
USB მოწყობილობის HID კლასის პროგრამირების სახელმძღვანელო
This section explains how to use the HID class. Initializing the USB Device HID Class Adding a USB Device HID Class Instance to your Device Communicating using the USB Device HID Class
Initializing the USB Device HID Class
თქვენს მოწყობილობაზე HID კლასის ფუნქციონალურობის დასამატებლად, ჯერ კლასი უნდა ინიციალიზაცია გაუკეთოთ sl_usbd_hid_init() ფუნქციის გამოძახებით.ampქვემოთ მოცემულია, თუ როგორ გამოვიძახოთ sl_usbd_hid_init() ფუნქცია ნაგულისხმევი არგუმენტების გამოყენებით. sl_usbd_hid_init() ფუნქციაზე გადასაცემი კონფიგურაციის არგუმენტების შესახებ დამატებითი ინფორმაციისთვის იხილეთ USB მოწყობილობის HID კლასის აპლიკაციის სპეციფიკური კონფიგურაციები.
Example – Calling sl_usbd_hid_init()
sl_status_t სტატუსი;
სტატუსი = sl_usbd_hid_init(); თუ (სტატუსი! SL_STATUS_OK) { /* შეცდომა მოხდა. შეცდომების დამუშავება აქ უნდა დაემატოს. */
}
Adding a USB Device HID Class Instance to Your Device
თქვენს მოწყობილობაზე HID კლასის ფუნქციონალურობის დასამატებლად, თქვენ უნდა შექმნათ ეგზემპლარი და შემდეგ დაამატოთ ის თქვენი მოწყობილობის კონფიგურაციაში.
HID კლასის ეგზემპლარის შექმნა
Create a HID class instance by calling the function sl_usbd_hid_create_instance() . The example below shows how to create a simple mouse function via sl_usbd_hid_create_instance() using default arguments. For more information on the configuration arguments to pass to sl_usbd_hid_create_instance() , see USB Device HID Class Instance Configurations .
Example – Adding a Mouse Function via sl_usbd_hid_create_instance()
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
38/174
დასრულდაview
/* Global constants. */ static const uint8_t app_usbd_hid_mouse_report_desc[] = {
SL_USBD_HID_GLOBAL_USAGE_PAGE + 1, SL_USBD_HID_USAGE_PAGE_GENERIC_DESKTOP_CONTROLS, SL_USBD_HID_LOCAL_USAGE + 1, SL_USBD_HID_CA_MOUSE, SL_USBD_HID_MAIN_COLLECTION + 1, SL_USBD_HID_COLLECTION_APPLICATION, SL_USBD_HID_LOCAL_USAGE + 1, SL_USBD_HID_CP_POINTER, SL_USBD_HID_MAIN_COLLECTION + 1, SL_USBD_HID_COLLECTION_PHYSICAL, SL_USBD_HID_GLOBAL_USAGE_PAGE + 1, SL_USBD_HID_USAGE_PAGE_BUTTON, SL_USBD_HID_LOCAL_USAGE_MIN + 1, 0 01, SL_USBD_HID_LOCAL_USAGE_MAX + 1, 0 03, SL_USBD_HID_GLOBAL_LOG_MIN + 1, 0 00, SL_USBD_HID_GLOBAL_LOG_MAX + 1, 0 01, SL_USBD_HID_GLOBAL_REPORT_COUNT + 1, 0 03, SL_USBD_HID_GLOBAL_REPORT_SIZE + 1, 0 01, SL_USBD_HID_MAIN_INPUT + 1, SL_USBD_HID_MAIN_DATA | SL_USBD_HID_MAIN_VARIABLE | SL_USBD_HID_MAIN_ABSOLUTE, SL_USBD_HID_GLOBAL_REPORT_COUNT + 1, 0 01, SL_USBD_HID_GLOBAL_REPORT_SIZE + 1, 0 0D, SL_USBD_HID_MAIN_INPUT + 1, SL_USBD_HID_MAIN_CONSTANT, SL_USBD_HID_GLOBAL_USAGE_PAGE + 1, SL_USBD_HID_USAGE_PAGE_GENERIC_DESKTOP_CONTROLS, SL_USBD_HID_LOCAL_USAGE + 1, SL_USBD_HID_DV_X, SL_USBD_HID_LOCAL_USAGE + 1, SL_USBD_HID_DV_Y, SL_USBD_HID_GLOBAL_LOG_MIN + 1, 0 81, SL_USBD_HID_GLOBAL_LOG_MAX + 1, 0 7F, SL_USBD_HID_GLOBAL_REPORT_SIZE + 1, 0 08, SL_USBD_HID_GLOBAL_REPORT_COUNT + 1, 0 02, SL_USBD_HID_MAIN_INPUT + 1, SL_USBD_HID_MAIN_DATA | SL_USBD_HID_MAIN_VARIABLE | SL_USBD_HID_MAIN_RELATIVE, SL_USBD_HID_MAIN_ENDCOLLECTION, SL_USBD_HID_MAIN_ENDCOLLECTION };
/* ლოკალური ცვლადები.*/ uint8_t class_nbr; sl_status_t სტატუსი;
sl_usbd_hid_callbacks_t app_usbd_hid_callbacks = { NULL, NULL, app_usbd_hid_get_report_desc, NULL, NULL, NULL, NULL, NULL, NULL };
void app_usbd_hid_get_report_desc(uint8_t class_nbr, const uint8_t **p_report_ptr, uint16_t *p_report_len)
{ (void)class_nbr;
*p_report_ptr = app_usbd_hid_mouse_report_desc; *p_report_len = sizeof(app_usbd_hid_mouse_report_desc); }
status = sl_usbd_hid_create_instance(SL_USBD_HID_SUBCLASS_BOOT, SL_USBD_HID_PROTOCOL_MOUSE, SL_USBD_HID_COUNTRY_CODE_NOT_SUPPORTED, Ex_USBD_HID_Mouse_ReportDesc, sizeof(Ex_USBD_HID_Mouse_ReportDesc), 2u, 2u, true, &app_usbd_hid_callbacks, &class_nbr);
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
39/174
დასრულდაview
/* An error occurred. Error handling should be added here. */}
Adding the HID Class Instance to Your Device’s Configuration(s) After you have created a HID class instance, you can add it to a configuration by calling the function
sl_usbd_hid_add_to_configuration() .
ყოფილმაample below shows how to call sl_usbd_hid_add_to_configuration() .
Example – Calling sl_usbd_hid_add_to_configuration()
sl_status_t სტატუსი;
sl_usbd_hid_add_to_configuration(class_nbr,
(1)
config_nbr_fs); (2)
თუ (სტატუსი! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
(1) კლასის ნომერი, რომელიც უნდა დაემატოს sl_usbd_hid_create_instance()-ის მიერ დაბრუნებულ კონფიგურაციას. (2) კონფიგურაციის ნომერი (აქ ემატება მას სრული სიჩქარის კონფიგურაციას).
Communicating Using the USB Device HID Class
Class Instance Communication Synchronous Communication Class Instance Communication The HID class offers the following functions to communicate with the host.
ცხრილი – HID საკომუნიკაციო API-ის შეჯამება
ფუნქციის სახელი
sl_usb d _hid _ re ad _sy nc() sl_usb d _hid _write _sy nc()
Operation Receives data from the host through interrupt OUT endpoint. This function is blocking. Sends data to the host through interrupt IN endpoint. This function is blocking.
Synchronous Communication Synchronous communication means that the transfer is blocking. Upon the function call, the applications blocks until the transfer is completed with or without an error. A timeout can be specified to avoid waiting forever. The exampქვემოთ მოცემულ სურათზე ნაჩვენებია წაკითხვისა და ჩაწერის ფუნქცია, რომელიც იღებს მონაცემებს ჰოსტისგან შეწყვეტის OUT ბოლო წერტილის გამოყენებით და უგზავნის მონაცემებს ჰოსტს შეწყვეტის IN ბოლო წერტილის გამოყენებით.
Example – Synchronous HID Read and Write
__ALIGNED(4) uint8_t rx_buf[2];
__ALIGNED(4) uint8_t tx_buf[2];
uint32_t
xfer_len;
sl_status_t
სტატუსი;
status = sl_usbd_hid_read_sync(class_nbr,
(1)
(void *)rx_buf,
(2)
2u,
0u,
(3)
&xfer_len);
თუ (სტატუსი! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
40/174
დასრულდაview
status =sl_usbd_hid_read_sync(class_nbr,(1)(void *)rx_buf,(2)2u,0u,(3)&xfer_len);if(status ! SL_STATUS_OK){/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */}
status =sl_usbd_hid_write_sync(class_nbr,(1)(void *)tx_buf,(4)2u,0u,(3)&xfer_len);if(status ! SL_STATUS_OK){/* An error occurred. Error handling should be added here. */}
(1) The class instance number created from sl_usbd_hid_create_instance() provides an internal reference for the HID class to route the transfer to the proper interrupt OUT or IN endpoint.
(2) აპლიკაციამ უნდა უზრუნველყოს, რომ ფუნქციისთვის მოწოდებული ბუფერი საკმარისად დიდი იყოს ყველა მონაცემის განსათავსებლად. წინააღმდეგ შემთხვევაში, შესაძლოა სინქრონიზაციის პრობლემები წარმოიშვას. შიდა დონეზე, წაკითხვის ოპერაცია სრულდება ან მართვის საბოლოო წერტილით, ან შეწყვეტის საბოლოო წერტილით, sl_usbd_hid_create_instance() ფუნქციის გამოძახებისას დაყენებული მართვის წაკითხვის ფლაგის მიხედვით.
(3) To avoid an infinite blocking situation, a timeout expressed in milliseconds can be specified. A value of 809 makes the application task wait forever.
(4) აპლიკაცია უზრუნველყოფს ინიციალიზებული გადაცემის ბუფერს.
HID პერიოდული შეყვანის ანგარიშების დავალება
To save bandwidth, the host has the ability to silence reports from an interrupt IN endpoint by limiting the reporting frequency. To do so, the host must send the SET_IDLE request. The HID class implemented by Silicon Labs contains an internal task that respects the reporting frequency limitation that you can apply to one or several input reports. Figure Periodic Input Reports Task shows the functioning of the periodic input reports tasks.
Figure – Periodic Input Reports Task
(1) The device receives a SET_IDLE request. This request specifies an idle duration for a given report ID. For more details about the SET_IDLE request, see <Device Class Definition for Human Interface Devices (HID) Version 1.11=, section 7.2.4. A report ID allows you to distinguish among the different types of reports sent from the same endpoint.
(2) A report ID structure (allocated during the HID class initialization phase) is updated with the idle duration. An idle duration counter is initialized with the idle duration value. The report ID structure is inserted at the end of a linked list containing input reports ID structures. The idle duration value is expressed in 4-ms unit which gives a range of 4 to 1020 ms.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
41/174
დასრულდაview
If the idle duration is less than the polling interval of the interrupt IN endpoint, the reports are generated at the polling interval.
(3) ყოველ 4 მილიწამში, პერიოდული შეყვანის ანგარიშის დავალება ათვალიერებს შეყვანის ანგარიშების ID-ების სიას. თითოეული შეყვანის ანგარიშის ID-სთვის, დავალება ასრულებს ორი შესაძლო ოპერაციიდან ერთ-ერთს. დავალების პერიოდის ხანგრძლივობა ემთხვევა უმოქმედობის ხანგრძლივობისთვის გამოყენებულ 4 მილიწამიან ერთეულს. თუ მასპინძელმა არ გაგზავნა SET_IDLE მოთხოვნები, შეყვანის ანგარიშების ID-ების სია ცარიელია და დავალებას დასამუშავებელი არაფერი აქვს. დავალება ამუშავებს მხოლოდ იმ ID-ებს, რომლებიც განსხვავდება 0-ისგან და რომელთა უმოქმედობის ხანგრძლივობა 0-ზე მეტია.
(4) For a given input report ID, the task verifies if the idle duration has elapsed. If the idle duration has not elapsed, the counter is decremented and no input report is sent to the host.
(5) თუ უმოქმედობის ხანგრძლივობა გავიდა (ანუ უმოქმედობის ხანგრძლივობის მრიცხველი ნულს მიაღწია), შეყვანის ანგარიში იგზავნება ჰოსტზე sl_usbd_hid_write_sync() ფუნქციის გამოძახებით შეწყვეტის IN ბოლო წერტილის მეშვეობით.
(6) The input report data sent by the task comes from an internal data buffer allocated for each input report described in the Report descriptor. An application task can call the sl_usbd_hid_write_sync() function to send an input report. After sending the input report data, sl_usbd_hid_write_sync() updates the internal buffer associated to an input report ID with the data just sent. Then, the periodic input reports task always sends the same input report data after each idle duration elapsed and until the application task updates the data in the internal buffer. There is some locking mechanism to avoid corruption of the input report ID data in the event of a modification happening at the exact time of transmission done by the periodic input report task.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
42/174
დასრულდაview
დასრულდაview
USB Device MSC Class
USB მოწყობილობა MSC კლასის გადაჭარბებაview USB მოწყობილობის MSC კლასის რესურსების საჭიროება ძირითადი USB მოწყობილობის MSC კლასის კონფიგურაციიდან USB მოწყობილობის MSC კლასის პროგრამირების სახელმძღვანელო USB მოწყობილობის MSC კლასის შენახვის დრაივერები
This section describes the mass storage device class (MSC) supported by Silicon Labs USB Device. MSC is a protocol that enables the transfer of information between a USB device and a host. The information being transferred is anything that can be stored electronically, such as executable programs, source code, documents, images, configuration data, or other text or numeric data. The USB device appears as an external storage medium to the host, enabling the transfer of files via drag and drop.
A file system defines how the files are organized in the storage media. The USB mass storage class specification does not require any particular file system to be used on conforming devices. Instead, it provides a simple interface to read and write sectors of data using the Small Computer System Interface (SCSI) transparent command set. As such, operating systems may treat the USB drive like a hard drive, and can format it with any file system they like.
USB მასობრივი შენახვის მოწყობილობის კლასი მხარს უჭერს ორ სატრანსპორტო პროტოკოლს, შემდეგნაირად:
მხოლოდ მასობრივი ტრანსპორტირების (BOT) კონტროლი/მასშტაბიანი/შეფერხების (CBI) ტრანსპორტირება (გამოიყენება მხოლოდ ფლოპი დისკის დრაივებისთვის)
მასობრივი შენახვის მოწყობილობის კლასი SCSI გამჭვირვალე ბრძანებების ნაკრებს მხოლოდ BOT პროტოკოლის გამოყენებით ახორციელებს, რაც ნიშნავს, რომ მონაცემებისა და სტატუსის ინფორმაციის გადასაცემად მხოლოდ მასობრივი საბოლოო წერტილები იქნება გამოყენებული. MSC იმპლემენტაცია მხარს უჭერს მრავალ ლოგიკურ ერთეულს.
MSC-ის დანერგვა შეესაბამება შემდეგ სპეციფიკაციებს:
უნივერსალური სერიული ავტობუსის მასობრივი შენახვის კლასის სპეციფიკაციაview, ვერსია 1.3, 2008 წლის 5 სექტემბერი. უნივერსალური სერიული ავტობუსის მასობრივი შენახვის კლასის მხოლოდ ნაყარი ტრანსპორტირება, ვერსია 1.0, 1999 წლის 31 სექტემბერი.
USB მოწყობილობა MSC aCl ss Overview
Protocol Endpoints Class Requests Small Computer System Interface (SCSI)
პროტოკოლი
In this section, we will discuss the Bulk-Only Transport (BOT) protocol of the Mass Storage Class. The Bulk-Only Transport protocol has three stages:
The Command Transport The Data Transport The Status Transport
Mass storage commands are sent by the host through a structure called the Command Block Wrapper (CBW). For commands requiring a data transport stagე., ჰოსტი შეეცდება მოწყობილობიდან ზუსტი რაოდენობის ბაიტების გაგზავნას ან მიღებას, როგორც ეს მითითებულია CBW-ის სიგრძისა და დროშის ველებში. მონაცემთა ტრანსპორტირების შემდეგtage, the host attempts to receive a Command Status Wrapper (CSW) from the device that details the status of the command as well as any data residue (if
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
43/174
დასრულდაview
any). For commands that do not include a data transport stage, the host attempts to receive the CSW directly after CBW is sent. The protocol is detailed in Figure – MSC Protocol.
სურათი – MSC პროტოკოლი
საბოლოო წერტილები
On the device side, in compliance with the BOT specification, the MSC is composed of the following endpoints: A pair of control IN and OUT endpoints called default endpoint. A pair of bulk IN and OUT endpoints.
The table below indicates the different usages of the endpoints.
ცხრილი – MSC საბოლოო წერტილის გამოყენება
ბოლო წერტილი
Control IN Control OUT Bulk IN Bulk OUT
მიმართულება
მოწყობილობიდან ჰოსტამდე ჰოსტამდე მოწყობილობამდე მოწყობილობიდან ჰოსტამდე ჰოსტამდე მოწყობილობამდე
გამოყენება
ჩამოთვლა და MSC კლასის სპეციფიკური მოთხოვნები ჩამოთვლა და MSC კლასის სპეციფიკური მოთხოვნები CSW-ს და მონაცემების გაგზავნა CBW-ს და მონაცემების მიღება
კლასის მოთხოვნები
There are two defined control requests for the MSC BOT protocol. These requests and their descriptions are detailed in the table below.
Table – Mass Storage Class Requests
კლასის მოთხოვნები
მხოლოდ მასობრივი შენახვის გადატვირთვა
აღწერა
This request is used to reset the mass storage device and its associated interface. This request readies the device to receive the next command block.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
44/174
დასრულდაview
კლასის მოთხოვნები
აღწერა
მაქსიმალური მნიშვნელობის მიღება. ეს მოთხოვნა გამოიყენება მოწყობილობის მიერ მხარდაჭერილი ყველაზე მაღალი ლოგიკური ერთეულის ნომრის (LUN) დასაბრუნებლად. მაგალითადampლე, ა
LUN
მოწყობილობა LUN 0-ით და LUN 1-ით დააბრუნებს 1 მნიშვნელობას. მოწყობილობა, რომელსაც აქვს ერთი ლოგიკური ერთეული, დააბრუნებს 0-ს ან შეაჩერებს
request. The maximum value that can be returned is 15.
Small Computer System Interface SCSI
პროგრამირების ინტერფეისის დონეზე, MSC მოწყობილობა ახორციელებს ერთ-ერთ სტანდარტულ შენახვის მედიის საკომუნიკაციო პროტოკოლს, როგორიცაა SCSI და SFF-8020i (ATAPI). „პროგრამირების ინტერფეისი“ განსაზღვრავს, თუ რომელი პროტოკოლია დანერგილი და ეხმარება მასპინძელ ოპერაციულ სისტემას USB შენახვის მოწყობილობასთან კომუნიკაციისთვის შესაფერისი მოწყობილობის დრაივერის ჩატვირთვაში. SCSI არის ყველაზე გავრცელებული პროტოკოლი, რომელიც გამოიყენება USB MSC შენახვის მოწყობილობებთან. ჩვენ გთავაზობთ MSC SCSI ქვეკლასის იმპლემენტაციას, რომლის გამოყენებაც ჩვენს GSDK მომხმარებლებს შეუძლიათ ყუთიდან ამოღებისთანავე.
SCSI is a set of standards for handling communication between computers and peripheral devices. These standards include commands, protocols, electrical interfaces and optical interfaces. Storage devices that use other hardware interfaces, such as USB, use SCSI commands for obtaining device/host information and controlling the device’s operation and transferring blocks of data in the storage media.
SCSI ბრძანებები მოიცავს მოწყობილობების ტიპებისა და ფუნქციების ფართო სპექტრს და შესაბამისად, მოწყობილობებს სჭირდებათ ამ ბრძანებების ქვესიმრავლე. ზოგადად, ძირითადი კომუნიკაციისთვის აუცილებელია შემდეგი ბრძანებები:
INQUIRY READ CAPACITY(10) READ(10) REQUEST SENSE TEST UNIT READY WRITE(10)
USB Device MSC Class Resource Needs from Core
Each time you add an MSC class instance to a USB configuration via the function sl_usbd_msc_add_to_configuration() , the following resources will be allocated from the core.
რესურსი
Interfaces Alternate interfaces Endpoints Interface groups
რაოდენობა
1 1 2 0
Note that those numbers are per configuration. When setting up your SL_USBD_INTERFACE_QUANTITY , SL_USBD_ALT_INTERFACE_QUANTITY , SL_USBD_INTERFACE_GROUP_QUANTITY and SL_USBD_DESCRIPTOR_QUANTITY configuration values, don’t forget to take into account on how many configurations the class will be added. For the SL_USBD_OPEN_ENDPOINTS_QUANTITY configuration value, since endpoints are opened only when a configuration is set by the host, you just need to take into account the number of needed endpoints for a class instance.
USB Device MSC Class Configuration
Two groups of configuration parameters are used to configure the MSC class:
USB Device MSC Class Application-Specific Configurations USB Device MSC Class Logical Unit Configuration
USB Device MSC Class Application-Specific Configurations
Class Compile-Time Configurations Class Instance Creation
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
45/174
დასრულდაview
კლასის კომპილაციის დროის კონფიგურაციები
Silicon Labs USB Device MSC class and SCSI subclass are configurable at compile time via #defines located in the sl_usbd_core_config.h file.
Table – Generic Configuration Constants
კონფიგურაციის სახელი
აღწერა
SL_USBD_MSC_CLASS_INST Number of class instances you will allocate via a call to the function
ANCE_QUANTITY
sl_usbd_msc_scsi_create_instance() .
SL_USBD_MSC_CONFIGURA კონფიგურაციის რაოდენობა, რომელსაც კლასის ეგზემპლარი შეიძლება დაემატოს გამოძახების გზით.
TION_QUANTITY
ფუნქცია sl_usbd_msc_scsi_add_to_configuration().
SL_USBD_MSC_LUN_QUANT Number of logical units per class instance that you will add via a call to the
ITY
function sl_usbd_msc_scsi_lun_add() .
SL_USBD_MSC_SCSI_64_BIT რთავს ან გამორთავს 64 ბიტიანი ლოგიკური ბლოკის მისამართის (LBA) მხარდაჭერას.
_LBA_EN
SL_USBD_MSC_DATA_BUFF Size of data buffer per class instance in bytes ER_SIZE
ნაგულისხმევი მნიშვნელობა
2
1
2
0
512
Class Instance Creation
Creating a USB Device MSC SCSI class instance is done by calling the sl_usbd_msc_scsi_create_instance() function. This function takes one configuration argument that is described below.
p_scsi_callbacks
p_scsi_callbacks არის sl_usbd_msc_scsi_callbacks_t ტიპის კონფიგურაციის სტრუქტურის მაჩვენებელი. საერთო USB მოწყობილობის callbacks კლასის connect/disconnect-ის გარდა, ის MSC კლასს აწვდის არჩევითი უკუკავშირის ფუნქციების ერთობლიობას, რომლებიც გამოიძახება ლოგიკურ ერთეულზე მოვლენის დროს. თუ უკუკავშირები არ არის საჭირო, ამ არგუმენტს შეიძლება გადაეცეს null მაჩვენებელი (NULL).
The table below describes each configuration field available in this configuration structure.
Table – sl_usbd_msc_scsi_callbacks_t Configuration Structure
ველები
აღწერა
.enable
Called when the USB class instance is enabled successfully.
.disable გამოიძახება, როდესაც USB კლასის ეგზემპლარი გამორთულია.
.host_eject ფუნქცია გამოიძახება, როდესაც ლოგიკური ერთეული ამოღებულია ჰოსტიდან.
Function Signature
void app_usbd_msc_scsi_enable(uint8_t class_nbr);
void app_usbd_msc_scsi_disable(uint8_t class_nbr); void app_usbd_msc_scsi_host_eject(uint8_t class_nbr, uint8_t lu_nbr);
USB Device MSC Class Logical Unit Configuration
Adding a logical unit to an MSC class instance is done by calling the function sl_usbd_msc_lun_add() . This function takes one configuration argument that is described below.
p_lu_info
p_lu_info is a pointer to a structure of type sl_usbd_msc_scsi_lun_info_t . Its purpose is to provide the information on the logical unit to the MSC class.
The table below describes each configuration field available in this configuration structure.
ცხრილი – sl_usbd_msc_scsi_lun_info_t კონფიგურაციის სტრუქტურა
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
46/174
დასრულდაview
ველი
აღწერა
ველი
.scsi_lun_api_p tr
აღწერა
მედია დრაივერის API-ის მაჩვენებელი, რომელიც ამ ლოგიკურ ერთეულს დაამუშავებს. მეხსიერების დრაივერების შესახებ დამატებითი ინფორმაციისთვის იხილეთ USB მოწყობილობის MSC კლასის შენახვის დრაივერები.
.v e nd o r_id _ p tr
.product_id_ptr
.პროდუქტი_ვიზუალიზაცია_დონე .ის_წაკითხულია_მხოლოდ
Pointer to a string that contains the vendor identification of the logical unit. The maximum length of the string is 8 characters. Pointer to a string that contains the product identification of the logical unit. The maximum length of the string is 16 characters. Product revision level.
დროშა, რომელიც მიუთითებს, ლოგიკური ერთეული უნდა იყოს თუ არა მხოლოდ წასაკითხი წერტილიდან view მასპინძლის (ჭეშმარიტი) თუ არა (მცდარი).
USB მოწყობილობის MSC კლასის პროგრამირების სახელმძღვანელო
ეს განყოფილება განმარტავს, თუ როგორ გამოიყენოთ MSC კლასი.
Initializing the USB Device MSC Class Adding a USB Device MSC SCSI Class Instance to Your Device USB Device MSC Class Logical Unit Handling
USB მოწყობილობის MSC კლასის ინიციალიზაცია
თქვენს მოწყობილობაზე MSC SCSI კლასის ფუნქციონალურობის დასამატებლად, ჯერ ინიციალიზაცია გაუკეთეთ MSC ბაზის კლასის და SCSI ქვეკლასის sl_usbd_msc_init() და sl_usbd_msc_scsi_init() ფუნქციების გამოძახებით.
ყოფილმაampქვემოთ მოცემულია, თუ როგორ გამოვიძახოთ sl_usbd_msc_init() და sl_usbd_msc_scsi_init() ფუნქციები.
Example – Calling sl_usbd_msc_init() and sl_usbd_msc_scsi_init()
sl_status_t სტატუსი;
სტატუსი = sl_usbd_msc_init(); თუ (სტატუსი! SL_STATUS_OK) { /* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავება. */
}
status = sl_usbd_msc_scsi_init(); if (status ! SL_STATUS_OK) { /* An error occurred. Error handling should be added here. */
}
Adding a USB Device MSC SCSI Class Instance to Your Device
To add MSC SCSI class functionality to your device, first create an instance, then add it to your device’s configuration(s). You must add at least one logical unit to your instance.
Creating an MSC SCSI Class Instance
Create a MSC SCSI class instance by calling the function sl_usbd_msc_scsi_create_instance() .
ყოფილმაample below shows how to call sl_usbd_msc_scsi_create_instance() using default arguments. For more information on the configuration arguments to pass to sl_usbd_msc_scsi_create_instance() , see USB Device MSC Class Application Specific Configurations .
Example – Calling sl_usbd_ msc_scsi_create_instance()
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
47/174
დასრულდაview
uint8_t class_nbr; sl_status_t status;
sl_usbd_msc_scsi_callbacks_t app_usbd_msc_scsi_callbacks = { .enable = NULL, .disable = NULL, .host_eject = NULL };
სტატუსი = sl_usbd_msc_scsi_create_instance(&app_usbd_msc_scsi_callbacks,0 &class_nbr);
if (status ! SL_STATUS_OK) { /* An error occurred. Error handling should be added here. */ }
Adding the MSC Class Instance to Your Device’s Configuration(s)
MSC კლასის ეგზემპლარის შექმნის შემდეგ, მისი კონფიგურაციაში დამატება ფუნქციის გამოძახებით შეგიძლიათ
sl_usbd_msc_add_to_configuration() .
ყოფილმაampქვემოთ მოცემულია, თუ როგორ გამოვიძახოთ sl_usbd_msc_scsi_add_to_configuration() ფუნქცია ნაგულისხმევი არგუმენტების გამოყენებით.
Example – Calling sl_usbd_ msc_scsi_add_to_configuration()
sl_status_t სტატუსი;
status = sl_usbd_msc_scsi_add_to_configuration(class_nbr,
(1)
config_nbr_fs);
(2)
თუ (სტატუსი! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
(1) Class number to add to the configuration returned by sl_usbd_msc_scsi_create_instance() . (32) Configuration number (here adding it to a Full-Speed configuration).
USB მოწყობილობის MSC კლასის ლოგიკური ერთეულების დამუშავება
Adding a Logical Unit Attaching/Detaching a Storage Medium
ლოგიკური ერთეულის დამატება
When adding a logical unit to your MSC SCSI class instance, it must be bound to a storage medium (RAMDisk, SD card, flash memory, etc). The MSC class uses a storage driver to communicate with storage media. This driver will need to be supply when adding the logical unit.
ყოფილმაampქვემოთ მოცემულია, თუ როგორ დავამატოთ ლოგიკური ერთეული sl_usbd_msc_scsi_lun_add() ფუნქციის გამოყენებით.
Example – Adding a Logical Unit via sl_usbd_msc_scsi_lun_add()
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
48/174
დასრულდაview
sl_usbd_msc_scsi_lun_t *lu_object_ptr = NULL;
sl_usbd_msc_scsi_lun_info_t lu_info;
sl_status_t
სტატუსი;
lu_info.sl_usbd_msc_scsi_lun_api_t = &app_usbd_scsi_storage_block_device_api;
lu_info.vendor_id_ptr
= “Silicon Labs”;
lu_info.product_id_ptr
= “block device example”;
lu_info.product_revision_level = 0x1000u;
lu_info.is_read_only
= false;
status = sl_usbd_msc_scsi_lun_add(class_nbr, &lu_info, &lu_object_ptr);
if (status ! SL_STATUS_OK) { /* An error occurred. Error handling should be added here. */ }
Attaching/Detaching a Storage Medium
ლოგიკური ერთეულის დამატების შემდეგ, მასპინძლის მხრიდან ხელმისაწვდომი რომ იყოს, უნდა იყოს მიერთებული შენახვის საშუალება. MSC კლასი გთავაზობთ ორ ფუნქციას შენახვის მედიის ლოგიკურ ერთეულთან ასოცირების გასაკონტროლებლად: sl_usbd_msc_scsi_lun_attach() და sl_usbd_msc_scsi_lun_detach(). ეს ფუნქციები საშუალებას გაძლევთ, საჭიროების შემთხვევაში, განახორციელოთ შენახვის მოწყობილობის ამოღების ემულაცია, რათა ხელახლა მოიპოვოთ წვდომა ჩაშენებული აპლიკაციიდან.
ყოფილმაample below shows how to use the function sl_usbd_msc_scsi_lun_attach() and sl_usbd_msc_scsi_lun_detach() .
Example – Media Attach/Detach
sl_status_t სტატუსი;
სტატუსი = sl_usbd_msc_scsi_lun_attach(lu_object_ptr); თუ (სტატუსი! SL_STATUS_OK) { /* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავება. */
}
…
(1)
status = sl_usbd_msc_scsi_lun_detach(lu_object_ptr); if (status ! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
…
(2)
status = sl_usbd_msc_scsi_lun_attach(lu_object_ptr) if (status ! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
…
(3)
(1) From this moment, if the MSC device is connected to a host, the storage media is accessible.
(2) თუ MSC მოწყობილობა დაკავშირებულია ჰოსტთან, მედია ახლა გამოჩნდება, როგორც მიუწვდომელი. ამ ეტაპზე, მედიაზე ოპერაციების შესრულება შესაძლებელია ჩაშენებული აპლიკაციიდან.
(3) კვლავ, თუ MSC მოწყობილობა დაკავშირებულია ჰოსტთან, შენახვის მედია გამოჩნდება, როგორც დაკავშირებული.
USB Device MSC Class Storage Drivers
USB მოწყობილობის MSC კლასის მოწყობილობას შენახვის საშუალებასთან კომუნიკაციისთვის მეხსიერების დრაივერი სჭირდება. ამ ეტაპზე, Silicon Labs დრაივერებს არ სთავაზობს.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
49/174
დასრულდაview
T P Y a a he driver A I is defined by typedef sl_usbd_msc_scsi_lun_api_t . our sl_usbd_msc_scsi_lun_api_t v ri ble must be included to a a a a a a a a your sl_usbd_msc_scsi_lun_info_t v ri ble, p ssed s rgument when you dd logic l unit with sl_usbd_msc_scsi_lun_add() . See section USB Device MSC SCSI API for more details on the structures. The storage driver implementation can be as simple as an array of sectors in RAM. Typical sector size (i.e., block size) is 512 for mass storage devices, and 2048 for CD-ROMs.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
50/174
დასრულდაview
დასრულდაview
USB მოწყობილობის მომწოდებლის კლასი
USB Device Vendor Class Overview USB Device Vendor Class Resource Needs from Core USB Device Vendor Class Configuration USB Device Vendor Class Programming Guide The Vendor class allows you to build vendor-specific devices that can implement a proprietary protocol. It relies on a pair of bulk endpoints to transfer data between the host and the device. Bulk transfers are convenient for transferring large amounts of unstructured data and provide a reliable exchange of data by using an error detection and retry mechanism. In addition to bulk endpoints, the Vendor class can also use an optional pair of interrupt endpoints. Any operating system (OS) can work with the Vendor class provided that the OS has a driver to handle the Vendor class. Depending on the OS, the driver can be native or vendor-specific. For instance, under Microsoft Windows®, your application interacts with the WinUSB driver provided by Microsoft to communicate with the vendor device.
USB Device Vendor Class Overview
სურათი – Windows Host-სა და Vendor კლასს შორის ზოგადი არქიტექტურა გვიჩვენებს Vendor კლასის გამოყენებით მასპინძელსა და მოწყობილობას შორის ზოგად არქიტექტურას. ამ მაგალითშიampანუ, მასპინძელი ოპერაციული სისტემაა MS Windows.
Figure – General Architecture Between MS Windows Host and Vendor Class
On the MS Windows side, the application communicates with the vendor device by interacting with a USB library. Libraries, like libusb, offer an API to manage a device and its associated pipes, and to communicate with the device through control, bulk and interrupt endpoints.
On the device side, the Vendor class is composed of the following endpoints:
A pair of control IN and OUT endpoints called the default endpoint. A pair of bulk IN and OUT endpoints.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
51/174
დასრულდაview
შეწყვეტის IN და OUT საბოლოო წერტილების წყვილი. ეს წყვილი არასავალდებულოა. ქვემოთ მოცემულ ცხრილში მითითებულია სხვადასხვა საბოლოო წერტილების გამოყენება:
ცხრილი – მომწოდებლის კლასის საბოლოო წერტილების გამოყენება
საბოლოო წერტილის მიმართულება
კონტროლი IN
კონტროლი
გარეთ
ჯგუფური შეყვანა
Device-tohost
>Host-todevice
Device-tohost
ნაყარი გატანა
Interrupt IN
შეწყვეტა
გარეთ
Host-todevice
Device-tohost
Host-todevice
გამოყენება
Standard requests for enumeration and vendor-specific requests.
Standard requests for enumeration and vendor-specific requests.
Raw data communication. Data can be structured according to a proprietary protocol.
Raw data communication. Data can be structured according to a proprietary protocol.
Raw data communication or notification. Data can be structured according to a proprietary protocol. Raw data communication or notification. Data can be structured according to a proprietary protocol.
მოწყობილობის აპლიკაციას შეუძლია გამოიყენოს მასიური და შეწყვეტის საბოლოო წერტილები მონაცემების ჰოსტისთვის გასაგზავნად ან მისაღებად. მას შეუძლია გამოიყენოს მხოლოდ ნაგულისხმევი საბოლოო წერტილი ჰოსტის მიერ გაგზავნილი მომწოდებლის სპეციფიკური მოთხოვნების გაშიფვრისთვის. სტანდარტული მოთხოვნები შიდა დონეზე იმართება Silicon Labs USB მოწყობილობის ძირითადი ფენის მიერ.
USB Device Vendor Class Resource Needs from Core
ყოველ ჯერზე, როდესაც კონფიგურაციას sl_usbd_vendor_add_to_configuration() ფუნქციის მეშვეობით დაამატებთ გამყიდველის კლასის ინსტანციას, ბირთვიდან გამოიყოფა შემდეგი რესურსები.
რესურსი
Interfaces Alternate interfaces Endpoints Interface groups
რაოდენობა
1 1 2 (4 if you enabled interrupt endpoints) 0
Note that those numbers are per configuration. When setting up your SL_USBD_INTERFACE_QUANTITY , SL_USBD_ALT_INTERFACE_QUANTITY , SL_USBD_INTERFACE_GROUP_QUANTITY and SL_USBD_DESCRIPTOR_QUANTITY configuration values, don’t forget to take into account on how many configurations the class will be added. For the SL_USBD_OPEN_ENDPOINTS_QUANTITY configuration value, since endpoints are opened only when a configuration is set by the host, you just need to take into account the number of needed endpoints for a class instance.
USB მოწყობილობის მომწოდებლის კლასის კონფიგურაცია
Two groups of configuration parameters are used to configure the Vendor class:
USB Device Vendor Class Application-Specific Configurations USB Device Vendor Class Instance Configurations
USB მოწყობილობის მომწოდებლის კლასის აპლიკაციის სპეციფიკური კონფიგურაციები
First, to use the Silicon Labs USB device Vendor class module, adjust the Vendor compile-time configuration defines according to your application needs. They are regrouped inside the sl_usbd_core_config.h header file under the Vendor section. The quantity configurations purpose is to inform the USB device module about how many USB Vendor objects to allocate.
The table below describes each configuration define.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
52/174
დასრულდაview
ცხრილი – USB მოწყობილობის მომწოდებლის კონფიგურაციის განსაზღვრებები
კონფიგურაციის სახელი
აღწერა
ნაგულისხმევი მნიშვნელობა
SL_USBD_VENDOR_CLASS_INSTANCE_QUANTITY Number of class instances you will allocate via a call to the 2 function sl_usbd_vendor_create_instance() .
SL_USBD_VENDOR_CONFIGURATION_QUANTITY კონფიგურაციების რაოდენობა. მომწოდებლის კლასის ინსტანციების 1 დამატება შესაძლებელია ერთ ან რამდენიმე კონფიგურაციაში sl_usbd_vendor_add_to_configuration() ფუნქციის გამოძახებით.
USB Device Vendor Class Instance Configurations
This section defines the configurations related to the Vendor class instances.
კლასის ეგზემპლარის შექმნა intr_en ინტერვალი p_vendor_callbacks
Class Instance Creation
Creating a Vendor class instance is done by calling the function sl_usbd_vendor_create_instance() , which takes three configuration arguments that are described below.
intr_en
Boolean that indicates if a pair of interrupt endpoints should be added or not.
ღირებულება
ჭეშმარიტი ცრუ
აღწერა
ჩაშენებული აპლიკაციისთვის დაემატება IN/OUT საბოლოო წერტილების წყვილი. შეფერხების საბოლოო წერტილი არ დაემატება. ხელმისაწვდომი იქნება მხოლოდ ჯგუფური IN/OUT საბოლოო წერტილების წყვილი.
ინტერვალი
If you set intr_en to true , you can specify the interrupt endpoints polling interval (in milliseconds). If you set intr_en to false , you can set interval to 0 as it will be ignored by the class.
p_vendor_callbacks
p_vendor_callbacks is a pointer to a callback functions structure variable. that you can specify to handle the class specific control requests. If you don’t use any class specific requests or needs enable/disable notification, you can set this to NULL .
ყოფილმაampქვემოთ მოცემულია თქვენი კლასის სპეციფიკური მოთხოვნების დამმუშავებლის მოსალოდნელი ხელმოწერა.
Example – კლასის სპეციფიკური მოთხოვნის ფუნქციის ხელმოწერა
void app_usbd_vendor_req_handle(uint8_t
class_nbr, (1)
const sl_usbd_setup_req_t *p_setup_req); (2)
sl_usbd_vendor_callbacks_t app_usbd_vendor_callback_functions =
{
.enable = NULL, .disable = NULL, .setup_req = app_usbd_vendor_req_handle,
};
(1) მომწოდებლის კლასის ეგზემპლარის ნომერი.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
53/174
დასრულდაview
(2) Pointer to a received setup request from host.
USB Device Vendor Class Programming Guide
ეს განყოფილება განმარტავს, თუ როგორ გამოიყენოთ Vendor კლასი. USB მოწყობილობის Vendor კლასის ინიციალიზაცია USB მოწყობილობის Vendor კლასის ეგზემპლარის თქვენს მოწყობილობაზე დამატება USB მოწყობილობის Vendor კლასის გამოყენებით კომუნიკაცია
USB მოწყობილობის მომწოდებლის კლასის ინიციალიზაცია
თქვენს მოწყობილობაზე მომწოდებლის კლასის ფუნქციონალის დასამატებლად, ჯერ კლასის ინიციალიზაცია მოახდინეთ USBD_Vendor_Init() ფუნქციის გამოძახებით.ampქვემოთ მოცემულია, თუ როგორ გამოვიძახოთ sl_usbd_vendor_init() ფუნქცია.
Example – Calling sl_usbd_vendor_init()
sl_status_t სტატუსი;
სტატუსი = sl_usbd_vendor_init(); თუ (სტატუსი! SL_STATUS_OK) { /* შეცდომა მოხდა. შეცდომების დამუშავება აქ უნდა დაემატოს. */ }
USB მოწყობილობის მომწოდებლის კლასის ეგზემპლარის დამატება თქვენს მოწყობილობაზე
To add vendor class functionality to your device, you must first create an instance, then add it to your device’s configuration(s).
Creating a Vendor Class Instance Adding the Vendor Class Instance to Your Device’s Configuration(s)
Creating a Vendor Class Instance
Create a Vendor class instance by calling the function sl_usbd_vendor_create_instance() . The exampქვემოთ მოცემულია, თუ როგორ გამოვიძახოთ sl_usbd_vendor_create_instance() ფუნქცია ნაგულისხმევი არგუმენტების გამოყენებით. sl_usbd_vendor_create_instance()-ში გადასაცემი კონფიგურაციის არგუმენტების შესახებ დამატებითი ინფორმაციისთვის იხილეთ USB მოწყობილობის მომწოდებლის კლასის ეგზემპლარის კონფიგურაციები.
Example – Calling sl_usbd_vendor_create_instance()
uint8_t class_nbr; sl_status_t status;
status = sl_usbd_vendor_create_instance(false,
(1)
0u,
(2)
app_usbd_vendor_callback_functions, (3)
&class_nbr);
თუ (სტატუსი! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
(1) No Interrupt endpoints with this class instance. (2) Interval is ignored since Interrupt endpoints are disabled.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
54/174
დასრულდაview
(3) Callback function that is part of your application that handles vendor-specific class requests. See Communicating using the USB Device Vendor Class for more information. Adding the Vendor Class Instance to Your Device’s Configuration(s) After you have created a vendor class instance, you can add it to a configuration by calling the function USBD_Vendor_ConfigAdd(). The example below shows how to call sl_usbd_vendor_add_to_configuration() using default arguments.
Example – Calling sl_usbd_vendor_add_to_configuration()
sl_status_t სტატუსი;
status = sl_usbd_vendor_add_to_configuration(class_nbr,
(1)
config_nbr_fs);
(2)
თუ (სტატუსი! SL_STATUS_OK) {
/* შეცდომა მოხდა. აქ უნდა დაემატოს შეცდომების დამუშავების ფუნქცია. */
}
(1) Class number to add to the configuration returned by sl_usbd_vendor_create_instance() . (2) Configuration number (here adding it to a Full-Speed configuration).
Communicating Using the USB Device Vendor Class
General Synchronous Communication Asynchronous Communication Vendor Request General The Vendor class offers the following functions to communicate with the host. For more details about the parameters of the function, see USB Device Vendor API.
Table – Vendor Communication API Summary
ფუნქციის სახელი
sl_usb d _v e nd o r_ re ad _b ulk_sy nc() sl_usb d _v e nd o r_write _b ulk_sy nc() sl_usb d _v e nd o r_ re ad _b ulk_asy nc() sl_usb d _v e nd o r_write _b ulk_asy nc() sl_usb d _v e nd o r_ re ad _inte rrup t_sy nc() sl_usb d _v e nd o r_write _inte rrup t_sy nc() sl_usb d _v e nd o r_ re ad _inte rrup t_asy nc
()
sl_usb d _v e nd o r_write _inte rrup t_asy nc
()
Operation Receives data from host through bulk OUT endpoint. This function is blocking. Sends data to host through bulk IN endpoint. This function is blocking. Receives data from host through bulk OUT endpoint. This function is non-blocking. Sends data to host through bulk IN endpoint. This function is non-blocking. Receives data from host through interrupt OUT endpoint. This function is blocking. Sends data to host through interrupt IN endpoint. This function is blocking. Receives data from host through interrupt OUT endpoint. This function is non-
ბლოკირება.
Sends data to host through interrupt IN endpoint. This function is non-blocking.
The vendor requests are also another way to communicate with the host. When managing vendor requests sent by the host, the application can receive or send data from or to the host using the control endpoint; you will need to provide an application callback passed as a parameter of sl_usbd_vendor_create_instance() . Synchronous Communication
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
55/174
დასრულდაview
Synchronous communication means that the transfer is blocking. When a function is called, the application blocks until the transfer completes with or without an error. A timeout can be specified to avoid waiting forever. The example below shows a read and write that receives data from the host using the bulk OUT endpoint and sends data to the host using the bulk IN endpoint.
Example – Synchronous Bulk Read and Write
__ALIGNED(4) uint8_t rx_buf[2];
__ALIGNED(4) uint8_t tx_buf[2];
uint32_t
xfer_len;
sl_status_t
სტატუსი;
status = sl_usbd_vendor_read_bulk_sync(class_nbr,
(1)
(void *)&rx_buf[0],
(2)
2u,
0u,
(3)
&xfer_len);
თუ (სტატუსი! SL_STATUS_OK) {
/* $$$$ შეცდომის მართვა. */
}
status = sl_usbd_vendor_write_bulk_sync( class_nbr,
(1)
(void *)&tx_buf[0],
(4)
2u,
0u,
(3)
false,
(5)
&xfer_len);
თუ (სტატუსი! SL_STATUS_OK) {
/* $$$$ შეცდომის მართვა. */
}
(1) The class instance number created with sl_usbd_vendor_create_instance() provides an internal reference to the Vendor class to route the transfer to the proper bulk OUT or IN endpoint.
(2) The application must ensure that the buffer provided to the function is large enough to accommodate all the data. Otherwise, synchronization issues might happen.
(3) In order to avoid an infinite blocking situation, a timeout expressed in milliseconds can be specified. A value of 809 makes the application task wait forever.
(4) აპლიკაცია უზრუნველყოფს ინიციალიზებული გადაცემის ბუფერს.
(5) If this flag is set to true , and the transfer length is multiple of the endpoint maximum packet size, the device stack will send a zero-length packet to the host to signal the end of the transfer.
The use of interrupt endpoint communication functions, sl_usbd_vendor_read_interrupt_sync() and sl_usbd_vendor_write_interrupt_sync() , is similar to bulk endpoint communication functions presented in Example – Synchronous Bulk Read and Write.
ასინქრონული კომუნიკაცია
Asynchronous communication means that the transfer is non-blocking. When a function is called, the application passes the transfer information to the device stack and does not block. Other application processing can be done while the transfer is in progress over the USB bus. Once the transfer has completed, a callback function is called by the device stack to inform the application about the transfer completion. The example below shows asynchronous read and write.
Example – Asynchronous Bulk Read and Write
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
56/174
დასრულდაview
void app_usbd_vendor_comm (uint8_t class_nbr)
{
__ALIGNED(4) uint8_t rx_buf[2];
__ALIGNED(4) uint8_t tx_buf[2];
sl_status_t
სტატუსი;
status = sl_usbd_vendor_read_bulk_async(class_nbr,
(void *)&rx_buf[0],
(2)
2u,
app_usbd_vendor_rx_completed,
NULL);
(4)
თუ (სტატუსი! SL_STATUS_OK) {
/* $$$$ შეცდომის მართვა. */
}
status = sl_usbd_vendor_write_bulk_async(class_nbr,
(void *)&tx_buf[0],
(5)
2u,
app_usbd_vendor_tx_completed,
NULL,
(4)
false);
(6)
თუ (სტატუსი! SL_STATUS_OK) {
/* $$$$ შეცდომის მართვა. */
}
}
(1) (3)
(1) (3)
static void app_usbd_vendor_rx_completed(uint8_t class_nbr,
(3)
void *p_buf,
uint32_t buf_len,
uint32_t xfer_len,
void *p_callback_arg,
sl_status_t status)
{
თუ (სტატუსი! SL_STATUS_OK) {
/* $$$$ Do some processing. */
} სხვა {
/* $$$$ შეცდომის მართვა. */
}
}
static void app_usbd_vendor_tx_completed(uint8_t class_nbr,
(3)
void *p_buf,
uint32_t buf_len,
uint32_t xfer_len,
void *p_callback_arg,
sl_status_t status)
{
თუ (სტატუსი! SL_STATUS_OK) {
/* $$$$ Do some processing. */
} სხვა {
/* $$$$ შეცდომის მართვა. */
}
}
(1) The class instance number provides an internal reference to the Vendor class to route the transfer to the proper bulk OUT or IN endpoint. (2) The application must ensure that the buffer provided is large enough to accommodate all the data. Otherwise, there may be synchronization issues. (3) The application provides a callback function pointer passed as a parameter. Upon completion of the transfer, the device stack calls this callback function so that the application can finalize the transfer by analyzing the transfer result. For instance, on completion of a read operation, the application might perform processing on the received data. Upon write completion, the application can indicate if the write was successful and how many bytes were sent.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
57/174
დასრულდაview
(4) An argument associated with the callback can be also passed. Then in the callback context, some private information can be retrieved. (5) The application provides the initialized transmit buffer. (6) If this flag is set to true , and the transfer length is a multiple of the endpoint maximum packet size, the device stack will send a zero-length packet to the host to signal the end of transfer. The use of interrupt endpoint communication functions, sl_usbd_vendor_read_interrupt_async() and sl_usbd_vendor_write_interrupt_async() , is similar to the bulk endpoint communication functions presented in Example Asynchronous Bulk Read and Write.
Vendor Request
The USB 2.0 specification defines three types of requests: standard, class, and vendor. All standard requests are handled directly by the core layer, while class requests are managed by the proper associated class. Vendor requests can be processed by the vendor class. To process vendor requests, you must provide an application callback as a parameter of sl_usbd_vendor_create_instance() . After a vendor request is received by the USB device, it must be decoded properly. The example below shows vendor request decoding. Certain requests may be required to receive from or send to the host during the data stage of a control transfer. If no data stage is present, you only have to decode the Setup packet. This example shows the three types of data stage management: no data, data OUT and data IN.
Example – Vendor Request Decoding
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
58/174
დასრულდაview
#define APP_VENDOR_REQ_NO_DATA
0x01u
#define APP_VENDOR_REQ_RECEIVE_DATA_FROM_HOST 0x02u
#define APP_VENDOR_REQ_SEND_DATA_TO_HOST 0x03u
#define APP_VENDOR_REQ_DATA_BUF_SIZE
50u
static uint8_t app_vendor_req_buf[APP_VENDOR_REQ_DATA_BUF_SIZE];
static bool app_usbd_vendor_req (uint8_t
class_nbr,
const sl_usbd_setup_req_t *p_setup_req)
(1)
{
bool valid;
sl_status_t სტატუსი;
uint16_t req_len;
uint32_t xfer_len;
(void)class_nbr;
switch(p_setup_req->bRequest) { case APP_VENDOR_REQ_NO_DATA: valid = true; break;
(2) (3)
case APP_VENDOR_REQ_RECEIVE_DATA_FROM_HOST:
(4)
req_len = p_setup_req->wLength;
if (req_len > APP_VENDOR_REQ_DATA_BUF_SIZE) {
// Not enough room to receive data.
return (false);
}
// Receive data via Control OUT EP. // Wait transfer completion forever. status = sl_usbd_core_read_control_sync((void *)&app_vendor_req_buf[0u],
req_len, 0u, &xfer_len); if (status ! SL_STATUS_OK) { valid = false; } else { valid = true; } break;
case APP_VENDOR_REQ_SEND_DATA_TO_HOST:
(5)
req_len = APP_VENDOR_REQ_DATA_BUF_SIZE;
// Fill buf with a pattern. Mem_Set((void *)&AppVendorReqBuf[0u],
'A',
req_len);
// Send data via Control IN EP. // Wait transfer completion forever. status = sl_usbd_core_write_control_sync((void *)&app_vendor_req_buf[0u],
req_len, 0u, false, &xfer_len); if (status ! SL_STATUS_OK) { valid = DEF_FAIL; } else { valid = DEF_OK; } break;
ნაგულისხმევი:
(6)
// Request is not supported.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
59/174
დასრულდაview
valid =true;break;
case APP_VENDOR_REQ_RECEIVE_DATA_FROM_HOST:(4) req_len = p_setup_req->wLength;if(req_len > APP_VENDOR_REQ_DATA_BUF_SIZE){// Not enough room to receive data.return(false);}// Receive data via Control OUT EP.// Wait transfer completion forever. status =sl_usbd_core_read_control_sync((void *)&app_vendor_req_buf[0u],
req_len,0u,&xfer_len);if(status ! SL_STATUS_OK){ valid =false;}else{ valid =true;}break;
case APP_VENDOR_REQ_SEND_DATA_TO_HOST:(5) req_len = APP_VENDOR_REQ_DATA_BUF_SIZE;// Fill buf with a pattern.Mem_Set((void *)&AppVendorReqBuf[0u],’A’,
req_len);// Send data via Control IN EP.// Wait transfer completion forever. status =sl_usbd_core_write_control_sync((void *)&app_vendor_req_buf[0u],
req_len,0u,false,&xfer_len);if(status ! SL_STATUS_OK){ valid = DEF_FAIL;}else{ valid = DEF_OK;}break;
default:(6)// Request is not supported. valid = DEF_FAIL;break;}return(valid);}
(1) The core will pass the Setup packet content to your application. The structure sl_usbd_setup_req_t contains the same fields as defined by the USB 2.0 specification (refer to section “9.3 USB Device Requests” of the specification for more details):
typedef struct {
uint8_t bmRequestType; /* Characteristics of request.
*/
uint8_t bRequest; /* Specific request.
*/
uint16_t wValue; /* Varies according to request.
*/
uint16_t wIndex; /* Varies according to request; typically used as index.*/
uint16_t wLength; /* Transfer length if data stagაწმყო.
*/
} sl_usbd_setup_req_t;
(2) Determine the request. You may use a switch statement if you are using different requests. In this example, there are three different requests corresponding to the three types of the data stage: APP_VENDOR_REQ_NO_DATA, APP_VENDOR_REQ_RECEIVE_DATA_FROM_HOST, and APP_VENDOR_REQ_SEND_DATA_TO_HOST.
(3) If no data stage is present, you only need to decode the other fields. The presence of a data stage or not is indicated by the field wLength being non-null or null.
(4) If the host sends data to the device, you must call the function sl_usbd_core_read_control_sync() . The buffer provided should be able to contain up to wLength bytes. If any error occurs, return false to the core that will stall the status stage of the control transfer, indicating to the host that the request cannot be processed. true is returned in case of success.
(5) If the host receives data from the device, you must call the function sl_usbd_core_write_control_sync() . If any error occurs, return false to the core that will stall the status stage of the control transfer, indicating to the host that the request cannot be processed. true is returned in case of success.
(6) In this example, all requests not recognized are marked by returning false to the core. This one will stall the data or status stage of the control transfer indicating to the host that the request is not supported.
The host sends vendor requests through a host vendor application. USb libraries, such as libusb, can be used to help you develop your custom host vendor application.
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
60/174
API დოკუმენტაცია
API დოკუმენტაცია
API დოკუმენტაცია
მოდულების სია
USB Device API USB Device ACM API USB Device CDC API USB Device Core API USB Device HID API USB Device MSC API USB Device MSC SCSI API USB Device Vendor API
აღწერა
USB Device API USB Device ACM API USB Device CDC API USB Device Core API USB Device HID API USB Device MSC API USB Device MSC SCSI API USB Device Vendor API
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
61/174
USB Device API
USB Device API
USB Device API
USB Device API.
მოდულები
USB Device ACM API USB Device CDC API USB Device Core API USB Device HID API USB Device MSC API USB Device MSC SCSI API USB Device Vendor API
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
62/174
USB Device ACM API
USB Device ACM API
USB Device ACM API
USB Device CDC ACM API.
მოდულები
a sl_usbd_cdc_ cm_line_coding_t sl_usbd_cdc_acm_callbacks_t
ფუნქციები
sl_status_t sl_status_t
sl_status_t sl_status_t sl_status_t
sl_status_t
sl_status_t
sl_status_t
sl_status_t sl_status_t sl_status_t sl_status_t sl_status_t
a sl_usbd_cdc_ cm_init(void)
GLOBAL VARIABLES.
ssll__uussbbdd__ccddcc__aaccmm__ccraellabtaec_kins_stta*npc_ea(cumin_tc1a6l_lbtalicnkes_,sutaintte8__int t*eprv_saul,bucinlats1s6__nt bcra)ll_mgmt_capabilities,
Add a new instance of the CDC ACM serial emulation subclass.
a a a a sl_usbd_cdc_ cm_ dd_to_configur tion(uint8_t subcl ss_nbr, uint8_t config_nbr)
Add a CDC ACM subclass class instance into USB device configuration.
a a sl_usbd_cdc_ cm_is_en bled(uint8_t subclass_nbr, bool *p_enabled)
Get the CDC ACM serial emulation subclass enable state.
a a a sl_usbd_cdc_ cm_re d(uint8_t subcl ss_nbr, uint8_t *p_buf, uint32_t buf_len, uint16_t timeout, uint32_t
*p_xfer_len) Receive data on the CDC ACM serial emulation subclass.
a a a a sl_usbd_cdc_ cm_re d_ sync(uint8_t subcl ss_nbr, uint8_t *p_buf, uint32_t buf_len, a a a a sl_usbd_cdc_ sync_function_t sync_fnct, void *p_ sync_ rg)
Receive data on the CDC ACM serial emulation subclass asynchronously.
a a sl_usbd_cdc_ cm_write(uint8_t subcl ss_nbr, uint8_t *p_buf, uint32_t buf_len, uint16_t timeout, uint32_t
*p_xfer_len) Send data on the CDC ACM serial emulation subclass.
a a a sl_usbd_cdc_ cm_write_ sync(uint8_t subcl ss_nbr, uint8_t *p_buf, uint32_t buf_len, a a a a sl_usbd_cdc_ sync_function_t sync_fnct, void *p_ sync_ rg)
Send data on the CDC ACM serial emulation subclass asynchronously.
a a a sl_usbd_cdc_ cm_get_line_control_st te(uint8_t subcl ss_nbr, uint8_t *p_line_ctrl)
Return the state of control lines.
a a a sl_usbd_cdc_ cm_get_line_coding(uint8_t subcl ss_nbr, sl_usbd_cdc_ cm_line_coding_t *p_line_coding)
Get the current state of the line coding.
a a a sl_usbd_cdc_ cm_set_line_coding(uint8_t subcl ss_nbr, sl_usbd_cdc_ cm_line_coding_t *p_line_coding)
Set a new line coding.
a a a sl_usbd_cdc_ cm_set_line_st te_event(uint8_t subcl ss_nbr, uint8_t events)
Set a line state event(s).
a a a a sl_usbd_cdc_ cm_cle r_line_st te_event(uint8_t subcl ss_nbr, uint8_t events)
Clear a line state event(s).
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
63/174
USB Device ACM API
მაკროები
#define SL_USBD_CDC_ACM_NBR_NONE 255u
მოდული.
#define SL_USBD_CDC_ACM_PARITY_NONE 0u
PORT SETTINGS DEFINES.
#define SL_USBD_CDC_ACM_PARITY_ODD 1u #define SL_USBD_CDC_ACM_PARITY_EVEN 2u #define SL_USBD_CDC_ACM_PARITY_MARK 3u #define SL_USBD_CDC_ACM_PARITY_SPACE 4u #define SL_USBD_CDC_ACM_STOP_BIT_1 0u #define SL_USBD_CDC_ACM_STOP_BIT_1_5 1u #define SL_USBD_CDC_ACM_STOP_BIT_2 2u #define SL_USBD_CDC_ACM_CTRL_BREAK 0 01u
LINE EVENTS FLAGS DEFINES.
#define SL_USBD_CDC_ACM_CTRL_RTS 0 02u #define SL_USBD_CDC_ACM_CTRL_DTR 0 04u #define SL_USBD_CDC_ACM_STATE_DCD 0 01u #define SL_USBD_CDC_ACM_STATE_DSR 0 02u #define SL_USBD_CDC_ACM_STATE_BREAK 0 04u #define SL_USBD_CDC_ACM_STATE_RING 0 08u #define SL_USBD_CDC_ACM_STATE_FRAMING 0 10u #define SL_USBD_CDC_ACM_STATE_PARITY 0 20u #define SL_USBD_CDC_ACM_STATE_OVERUN 0 40u #define SL_USBD_CDC_ACM_CALL_MGMT_DEV 0 01u
CALL MANAGEMENT CAPABILITIES.
#define SL_USBD_CDC_ACM_CALL_MGMT_DATA_CCI_DCI 0 02u #define SL_USBD_CDC_ACM_CALL_MGMT_DATA_OVER_DCI 0 02u | 0 01u)
Function Documentation
sl_usbd_cdc_acm_init
sl_status_t sl_usbd_cdc_acm_init (void )
GLOBAL VARIABLES. Parameters
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
64/174
USB Device ACM API
ტიპი
ბათილად
Direction N/A
Argument Name
MACROS GLOBAL CONSTANTS FUNCTION PROTOTYPES CDC ACM FUNCTIONS
Initialize the CDC ACM serial emulation subclass.
ბრუნდება
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.
აღწერა
sl_usbd_cdc_acm_create_instance
sl_status_t sl_usbd_cdc_acm_create_instance (uint16_t line_state_interval, uint16_t call_mgmt_capabilities, sl_usbd_cdc_acm_callbacks_t * p_acm_callbacks, uint8_t * p_subclass_nbr)
Add a new instance of the CDC ACM serial emulation subclass.
პარამეტრები
ტიპი
uint16_t
uint16_t
Direction Argument Name
აღწერა
N/A
line_state_interval Line state notification interval in milliseconds (value must
be a power of 2).
N/A
call_mgmt_capabilities Call Management Capabilities bitmap. OR’ed of the
following flags:
SL_USBD_CDC_ACM_CALL_MGMT_DEV Device handles call management itself. SL_USBD_CDC_ACM_CALL_MGMT_DATA_CCI_DCI Device can send/receive call management information over a Data Class interface.
sl_usbd_cdc_acm_callbacks_t N/A
*
uint8_t *
N/A
p_acm_callbacks p_subclass_nbr
Optional pointers to callback functions to be called on various events.
Param to variable that will receive CDC ACM serial emulation subclass instance number.
ბრუნდება
Return SL_STATUS_OK on success or another SL_STATUS code on failure.
sl_usbd_cdc_acm_add_to_configuration
sl_status_t sl_usbd_cdc_acm_add_to_configuration (uint8_t subclass_nbr, uint8_t config_nbr)
Add a CDC ACM subclass class instance into USB device configuration.
პარამეტრები
ტიპი
uint8_t uint8_t
Direction N/A N/A
Argument Name
subclass_nbr config_nbr
Description CDC ACM serial emulation subclass instance number. Configuration index to add new test class interface to.
ბრუნდება
საავტორო უფლება © 2025 Silicon Laboratories. Ყველა უფლება დაცულია.
65/174
USB Device ACM API
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.
sl_usbd_cdc_acm_is_enabled
sl_status_t sl_usbd_cdc_acm_is_enabled (uint8_t subclass_nbr, bool * p_enabled)
Get the CDC ACM serial emulation subclass enable state.
პარამეტრები
ტიპი
მიმართულება
Argument Name
აღწერა
uint8_t N/A
subclass_nbr CDC ACM serial emulation subclass instance number.
bool * N/A
p_enabled
Boolean to a variable that will receive enable status. The variable is set to true, CDC ACM serial emulation is enabled. The va
დოკუმენტები / რესურსები
![]() |
SILICON LABS USB Device Stack [pdf] ინსტრუქციის სახელმძღვანელო USB Device Stack, Device Stack, Stack |