Buka ea litaelo tsa SILICON LABS USB Device Stack

Sesebelisoa sa Sesebelisoa sa USB

Litlhaloso

  • Mofuta oa USB: 1.5.1
  • Letsatsi la ho Hlahisa: Phupu 21, 2025
  • Mofuta o bonolo oa SDK: 2025.6.1

Sehlahisoa se Felletseview

Thepa ea sesebelisoa sa USB ke Silicon Labs e fana ka mefuta e mengata le
Khokahano ea USB e bonolo bakeng sa merero ea IoT, ea thusa
puisano pakeng tsa li-network co-processors le mabotho.

Likaroloana

  • Setaki se sebetsang hantle sa sesebelisoa sa USB
  • E loketse merero ea IoT
  • Tšehetso ea puisano lipakeng tsa li-network co-processors le
    mabotho

Litaelo tsa Tšebeliso ea Sehlahisoa

Tlhophiso ea Sesebelisoa sa USB

Hlophisa li-setting tsa sesebelisoa sa USB ho latela morero oa hau
ditlhoko ka ho bua ka karolo ea USB Device Configuration
litokomaneng.

Tataiso ea Mananeo ea Sesebelisoa sa USB

Latela Tataiso ea Mananeo ea Sesebelisoa sa USB ho utloisisa mokhoa oa ho
Lenaneo le ho sebelisana le sesebelisoa sa USB bakeng sa mefuta e fapaneng
lits'ebetso.

Lihlopha tsa lisebelisoa tsa USB

Karolo ea Lihlopha tsa Lisebelisoa tsa USB e fana ka ho fetaview ea fapaneng
litlelase tse kang CDC ACM, HID, MSC SCSI, le Vendor Class. Khetha ea
sehlopha se nepahetseng se ipapisitse le ts'ebetso ea sesebelisoa sa hau.

Tharollo ea Mathata a Sesebelisoa sa USB

Haeba u kopana le mathata leha e le afe ka sesebelisoa sa USB, sheba ho
Karolo ea Tharollo ea Sesebediswa sa USB bakeng sa tharollo le bothata
malebela.

Microsoft Windows OS USB Host

Haeba u sebelisa sesebelisoa sa USB se nang le Microsoft Windows OS USB
Moamoheli, etsa bonnete ba hore o latela litataiso tse fanoeng ho
litokomane bakeng sa kopanyo e se nang moeli.

LBH

P: Ke life tse ling tse tloaelehilengamplisebelisoa tse fokolang tseo nka li hahang ke sebelisa
stack ena ea USB?

A: The USB stack lumella u ho haha ​​disebediswa tse kang
Li-adapter tsa USB-to-serial, litoeba kapa likonopo, polokelo e ka ntšoang
lisebelisoa, le lisebelisoa tse ikhethileng.

P: Na ho na le litlhoko tse khethehileng tsa software bakeng sa ho sebelisa see?
Sesebelisoa sa sesebelisoa sa USB?

A: Software e lumellanang e kenyelletsa SDK e bonolo, e bonolo
Studio, Molaoli oa Bonolo, GCC (The GNU Compiler Collection),
IAR Embedded Workbench bakeng sa ARM, le IAR EWARM.

Universal Serial Bus USB

Universal Serial Bus USB

USB e Felletseview Fetileview
Hlakola Lintlha tsa USB
Litlhaloso le Likarolo Ho Fetileview
Tlhophiso ea sesebelisoa sa USB e felileview
Tataiso ea Mananeo ea Sesebediswa sa USB Overview
Litlelase tsa Sesebediswa sa USB Fetileview Sehlopha sa CDC ACM Overview FIHLA Class Hofetaview MSC SCSI Sehlopha se Felletseview Morekisi Sehlopha Feletsengview
USB 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 Core Device API
sl_usbd_device_config_t sl_usbd_setup_req_t
sl_usbd_cl ss_driver_t Sesebelisoa sa USB HID API
sl_usbd_hid_callbacks_t Sesebelisoa sa USB MSC API
sl_usbd_msc_subcl ss_driver_t Sesebelisoa sa USB MSC SCSI API
sl_usbd_msc_callbacks_t

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

1/174

Universal Serial Bus USB
sl_usbd_msc_lun_ pi
sl_usbd_msc_scsi_lun_info sl_usbd_msc_scsi_lun
USB Device Vendor API sl_usbd_vendor_callbacks_t
API Documentation USB Device Troubleshooting
Fetileview Microsoft Windows OS USB Host
Fetileview

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

2/174

Fetileview
Fetileview
Sesebelisoa sa USB
USB ke e 'ngoe ea likhokahano tse atlehileng ka ho fetesisa nalaneng ea litsamaiso tsa likhomphutha ebile ke tekanyetso ea de facto bakeng sa ho hokahanya lisebelisoa tsa khomphutha. Silicon Labs USB Device stack ke mojule oa sesebelisoa sa USB o etselitsoeng litsamaiso tse kentsoeng ka kotloloho. E hahiloe ho tloha fatše ka boleng ba Silicon Labs, scalability, le ts'epahalo, e fetile ts'ebetsong e tiileng ea ho netefatsa ho latela litlhaloso tsa USB 2.0. Litokomane tsena li hlalosa mokhoa oa ho qala, ho qala, le ho sebelisa stack ea Silicon Labs USB Device. E hlalosa maemo a fapaneng a tlhophiso le ts'ebeliso ea ona. E boetse e kenyelletsa ho fetaview ea theknoloji, mefuta ea menyetla ea tlhophiso, mekhoa ea ts'ebetsong, le mohlalaampe fokolang ea tšebeliso e tloaelehileng bakeng sa sehlopha se seng le se seng se fumanehang.
Ho u thusa ho utloisisa mehopolo ea USB kapele, litokomane li na le ba bangata ba examples ea USB e nang le mesebetsi ea mantlha. Tsena examples e tla u fa moralo o lumellang hore u hahe lisebelisoa kapele. Tsena examptse ling li kenyelletsa:
Adapter ea USB-to-serial (Sesebediswa sa Disebediswa tsa Dikgokahano) Tweba kapa keyboard (Sehlopha sa Sesebediswa sa Sebopeho sa Motho) Sesebediswa sa polokelo se ka ntshuwang (Sehlopha sa Polokeho ya Bongata) Sesebediswa se kgethehileng (Sehlopha sa Barekisi)
Se latelang ke se fedileview ea likarolo tsa litokomane:
Litlhaloso le Likarolo Peakanyo ea Sesebediswa sa USB Tataiso ea Mananeo ea Sesebediswa sa USB Melato ya Sesebediswa sa USB
CDC ACM Class HID Class MSC SCSI Class Vendor Class USB Device Mathata a ho rarolla mathata Microsoft Windows OS USB Host

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

3/174

USB
USB

USB Version 1.5.1 July 21, 2025 - Lintlha tsa Phatlalatso
Mofuta o bonolo oa SDK 2025.6.1
Silicon Labs' e sebetsang hantle ea sesebelisoa sa USB e fana ka khokahanyo ea USB e fumanehang habonolo, e bonolo ho e sebelisa bakeng sa merero ea IoT, ho kenyelletsa le puisano lipakeng tsa li-co-processor tsa marang-rang le baamoheli. Tobetsa mona bakeng sa likhatiso tsa pejana.
Kakaretso ea Phatlalatso
Lintlha tsa Bohlokoa | Liphetoho tsa API | Litokiso tsa Litšitiso | Tšebeliso ea Chip
Likarolo tsa Bohlokoa
Sethala se ka tlase se fetoha feela.
Liphetoho tsa API
Ha ho letho.
Litokiso tsa Litšitiso
Ha ho letho.
Tšebeliso ea Chip
Ha ho letho.
Likarolo tsa Bohlokoa
Likarolo tse Ncha | Lintlafatso | Likarolo Tse Tlositsoeng | Likarolo tse Nyahamisitsoeng
Likarolo tse Ncha
Ha ho letho.
Lintlafatso
Sethala se ka tlase se fetoha feela.
Likarolo Tse Tlositsoeng
Ha ho letho.
Likarolo tse Theotsoeng
Ha ho letho.
Liphetoho tsa API
Li-API tse ncha | Li-API tse fetotsoeng | Li-API tse tlositsoeng | Li-API tse sa sebetseng
Li-API tse ncha

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

4/174

USB
Ha ho letho.
Li-API tse fetotsoeng
Ha ho letho.
Li-API tse tlositsoeng
Ha ho letho.
Li-API tse sa sebetseng
Ha ho letho.
Litokiso tsa Litšitiso
Ha ho letho.
Tšebeliso ea Chip
Ha ho letho.
Kopo Example Liphetoho
Exampjoalo | Fetotse Exampjoalo | E tlositsoe Exampjoalo | E tlositsoe Examples
Examples
Ha ho letho.
Fetotse Examples
Ha ho letho.
E tlositsoe Examples
Ha ho letho.
E tlositsoe Examples
Ha ho letho.
Tšusumetso ea Liphetoho tsa Phallo
Lipolelo tsa Tšusumetso | Tataiso ea ho falla
Lipolelo tsa Tšusumetso
Ha ho letho.
Tataiso ea ho falla
Ha ho letho.
Mathata a Tsejoang le Mefokolo
Ha ho letho.
Ho Sebelisa Phatlalatso Ena

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

5/174

USB

Ho na le eng Tokollong? | Software e Tšoanang | Ho kenya le ho Sebelisa | Thuso le Maikutlo

Ho na le eng Tokollong?

Sesebelisoa sa Stack ea Sesebelisoa sa USB Examples
Software e lumellanang

Software
Bonolo SDK Bonolo Studio Bonolo Commander GCC The GNU Compiler Collection) IAR Embedded Workbench bakeng sa ARM IAR EWARM

Phetolelo e lumellanang kapa e fapaneng
2025.6.0 5.11.0 1.18.2 (e fanoe ka Simplicity Studio) 12.2.1 (e fanoe ka Simplicity Studio) 9.40.1 (e fanoe ka Simplicity Studio)

Ho kenya le ho Sebelisa

Ho qala nts'etsopele ea hau, sheba rona:
Tataiso ea Mananeo ea Sesebelisoa sa USB. Litokomane tsa API.
Ho fumana leseli mabapi le Khokahano e Sireletsehileng ea Vault, bona Secure Vault.
Ho review Ts'ireletso le Litsebiso tsa Keletso ea Software le ho laola likhetho tsa hau tsa tsebiso:
ò Eya ho https://community.silabs.com/. ó Kena ka lintlha tsa akhaonto ea hau. ô Tobetsa setsebi sa haufile aekhone hukung e kaholimo ho le letona la leqephe.
õ Khetha Litsebiso ho menu e theoha. ö Karolong ea Litsebiso, e-ea tabeng ea Litsebiso tsa Sehlahisoa sa Ka ho boelaview Histori Security le Software Advisory
litsebiso
÷ Ho laola lintho tseo u li ratang, sebelisa thebo ea Laola Litsebiso ho iketsetsa lintlafatso le likeletso tsa sehlahisoa sa hau.
amohela.
Bakeng sa litlhophiso tse khothaletsoang, bona mona.
Ho ithuta haholoanyane ka software tokollong ena, kenella ka har'a litokomane tsa rona tsa inthanete.
Thuso le Maikutlo

Ikopanye le Silicon Labs Support. Ho sebelisa sesebelisoa sa rona sa Botsa AI ho fumana likarabo, sheba sebaka sa ho batla se kaholimo ho leqephe lena.

Tlhokomeliso: Botsa AI ke liteko.

Fumana thuso ho tsoa sechabeng sa rona sa bahlahisi.
Pholisi ea Phallo le Tlhokomelo ea SDK
Sheba Leano la rona la Tokollo le Tlhokomelo ea SDK.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

6/174

Fetileview
Fetileview
Litlhaloso
E dumellana le "Universal Serial Bus specification revision 2.0" E kenya tshebetsong "Interface Association Descriptor Engineering Notice Notice (ECN)" Mefuta ea Phetisetso
Control Bulk Interrupt USB class Class (CDC) Abstract Control Model (ACM) Human Interface Device (HID) Mass Storage Class (MSC) Framework ea sehlopha sa barekisi
Likaroloana
Scalable ho kenyelletsa likarolo tse hlokahalang feela ho fokotsa mohopolo oa mohopolo E ts'ehetsa lebelo le felletseng (12 Mbit / s) E ts'ehetsa lisebelisoa tse kopaneng (mesebetsi e mengata) E ts'ehetsa lisebelisoa tse ngata tsa tlhophiso E ts'ehetsa ts'ebetso ea ho boloka matla a USB (sesebelisoa se emisa le ho qala hape) Kopanyo e felletseng ea Sehlopha sa polokelo ea 'Misa ho Micrium OS. File Mojule oa Sistimi O ntlafalitsoe ka sekhahla sa abstraction sa CMSIS-RTOS2 hore e tsebe ho sebetsa le li-OS tse fapaneng. Silicon Labs GSDK e tla le likou tsa FreeRTOS le Micrium OS.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

7/174

Fetileview
Fetileview

Tlhophiso ea Sesebelisoa sa USB

Karolo ena e bua ka mokhoa oa ho lokisa Silicon Labs USB Device. Ho na le lihlopha tse tharo tsa li-parameter tsa tlhophiso, tse latelang:
Tlhophiso ea Sesebediswa sa USB Core Tlhahisoleseding ya Sesebediswa sa USB Tlhophiso ya Sesebediswa sa USB Tokiso
Tlhophiso ea mantlha ea sesebelisoa sa USB
Sesebelisoa sa USB sa Silicon Labs se ka hlophisoa ka nako ea pokello ka sete ea #defines e fumanehang ho sl_usbd_core_config.h file. Sesebelisoa sa USB se sebelisa #defines ha ho khoneha hobane li lumella khoutu le boholo ba data hore bo fokotsoe ka nako ea ho bokella ho latela hore na ke likarolo life tse lumelletsoeng. Sena se lumella memori ea ho bala feela (ROM) le memori ea phihlello e sa reroang (RAM) ea Silicon Labs USB Device hore e fetoloe ho latela litlhoko tsa ts'ebeliso ea hau.
E khothalelitsoe: Qala ts'ebetso ea tlhophiso ka litekanyetso tsa kamehla (tse totobalitsoeng ka mongolo o motenya).
Likarolo tse ka tlase li hlophisitsoe ho latela tatellano ea tlhophiso ea template file, sl_usbd_core_config.h.
Tlhophiso ea Lihlopha tsa Tlhophiso ea Core
Tlhophiso ea mantlha
Tafole - Li-Constants tsa Configuration tsa Sesebelisoa sa USB

Kamehla Tlhaloso

Boleng ba kamehla

SL_USBD_TA SK_STACK_ SIZE

E lokisa boholo ba stack ka li-byte tsa mosebetsi oa mantlha oa USBD

4096

SL_USBD_TA SK_PRIORIT Y

E lokisa lintho tse tlang pele tsa mosebetsi oa mantlha oa USBD. Ena ke CMSIS-RTOS2 e tlang pele.

osPriorityHigh

SL_USBD_A UTO_START _USB_DEVIC E

Ha e butswe, sesebediswa sa USB se tla qalwa ka boyona hang ha kernel e se e qadile mme mosebetsi o le mong wa USBD o reretswe kgetlo la pele. Haeba e koetsoe, kopo ea hau e tla hloka ho letsetsa sl_usbd_core_start_device() ha e se e loketse ho bonoa ke moamoheli oa USB.

SL_USBD_C Palo eohle ea litlhophiso tse tla eketsoa ka sl_usbd_add_configuration()

1

Mosebetsi oa ONFIGURATI.

ON_QUANTI

TY

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

8/174

Fetileview

Kamehla
SL_USBD _INTERF ACE_QU ANTITY
SL_USBD _ALT_INT ERFACE_ QUANTI
TY
SL_USBD _INTERF ACE_GR
OUP_QU
ANTITY
SL_USBD _DESCRI
PTOR_Q
KHABANE
SL_USBD _STRING _QUANTI
TY
SL_USBD _OPEN_E NDPOIN TS_QUA NTITY

Tlhaloso Palo eohle ea likhokahano tsa USB tse tla eketsoa bakeng sa litlhophiso tsohle tsa hau. Sena se itšetlehile haholo ka sehlopha (li) se sebelisoang. Bakeng sa tlhaiso-leseling e batsi mabapi le hore na mohlala oa sehlopha o hloka li-interfaces tse kae, sheba karolo ea "Litlhoko tsa Mohloli ho tloha mantlha" tsa sehlopha sa hau.
Palo eohle ea likhokahano tse ling tsa USB tse tla eketsoa bakeng sa litlhophiso tsohle tsa hau. Sena se itšetlehile haholo ka sehlopha (li) se sebelisoang. Nomoro ena e tlameha ho lekana kamehla kapa e kholo ho feta SL_USBD_INTERFACE_QUANTITY . Bakeng sa tlhaiso-leseling e batsi mabapi le hore na mohlala oa sehlopha o hloka li-interfaces tse kae, sheba karolo ea "Resource Needs From Core" ea sehlopha sa hau.
Palo eohle ea lihlopha tsa USB interface tse tla eketsoa bakeng sa litlhophiso tsohle tsa hau. Sena se itšetlehile haholo ka sehlopha (li) se sebelisoang. Bakeng sa tlhaiso-leseling e batsi mabapi le hore na ke lihlopha tse kae tsa li-interface tse hlokang mohlala oa sehlopha, sheba karolo ea "Resource Needs From Core" ea sehlopha (tsa).
Palo eohle ea litlhaloso tsa Endpoint tse tla ekeletsoa bakeng sa litlhophiso tsohle tsa hau. Sena se itšetlehile haholo ka sehlopha (li) se sebelisoang. Bakeng sa tlhaiso-leseling e batsi mabapi le hore na mohlala oa sehlopha o hloka litlhaloso tse kae tsa li-endpoint, sheba "Palo ea lintlha tsa ho qetela" karolong ea "Resource Needs from Core" ea sehlopha (tsa). Hlokomela hore lintlha tsa taolo ha li hloke ho nahanoa mona. Palo eohle ea likhoele tsa USB. Ho beha bongata ho zero ho tla tima tšobotsi. Ho thibela sena ho tla etsa hore sesebelisoa se se boloke likhoele tsa litlhaloso tsa USB tse fetisoang ho tsoa ts'ebelisong. Sena se bolela hore moamoheli a ke ke a khona ho khutlisa likhoele tsa litlhaloso (joalo ka moetsi le lebitso la sehlahisoa). Kakaretso ea li-endpoints tse butsoeng ho latela tlhophiso. Sesebelisoa se hloka bonyane lintlha tse peli tse bulehileng bakeng sa phetisetso ea taolo, empa hape u tlameha ho eketsa lintlha tsa sehlopha (li) se sebelisitsoeng. Bakeng sa tlhaiso-leseling e batsi mabapi le hore na mohlala oa sehlopha o hloka lintlha tse kae tse butsoeng, sheba "Palo ea lintlha tsa ho qetela" karolong ea "Resource Needs from Core" ea sehlopha (tsa).

Boleng ba kamehla
10 10
2
20 30 20

Tlhophiso ea Lihlopha
Litlelase li na le litlhophiso tse khethehileng tsa nako ea pokello. Sheba ho Lihlopha tsa Sesebediswa sa USB bakeng sa tlhahisoleseding e eketsehileng.
Tlhophiso ea Boitsebiso ba Sesebelisoa sa USB

sl_usbd_device_config.h tlhophiso file regroups compile-time #define-s ho theha lintlha tsa mantlha mabapi le sesebelisoa sa hau, joalo ka Vendor/Product ID, likhoele tsa sesebelisoa, joalo-joalo. Tafole e ka tlase e hlalosa tlhaloso e 'ngoe le e 'ngoe ea tlhaiso-leseling e fumanehang tokisetsong ena. file.

Tafole - Tlhophiso ea Tlhahisoleseding ea Sesebelisoa sa USB ea Hlalosa

Kamehla
SL_USBD_DEVIC E_VENDOR_ID
SL_USBD_DEVIC E_PRODUCT_ID

Tlhaloso Nomoro ea hau ea boitsebahatso ea morekisi joalo ka ha e fanoe ke Seboka sa Basebelisi ba USB. Ho fumana lintlha tse ling mabapi le hore na u ka fumana ID ea morekisi joang, bona http://www.usb.org/developers/vendor/. Nomoro ea boitsebiso ba sehlahisoa sa hau.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

9/174

Fetileview

Kamehla

Tlhaloso

SL_USBD_DEVICE_RELEASE Nomoro ea tokollo ea sesebelisoa sa hau. _NUMBER

SL_USBD_DEVICE_MANUFA Mohala o hlalosang moetsi oa sesebelisoa sa hau. Tlhophiso ena e hlokomolohuoa ha

CTURER_STRING

tlhophiso SL_USBD_STRING_QUANTITY e behiloe ho 0.

SL_USBD_DEVICE_PRODUC Khoele e hlalosang sehlahisoa sa hau. Tokiso ena e hlokomolohuoa ha ho etsoa

T_STRING

SL_USBD_STRING_QUANTITY e behiloe ho 0.

SL_USBD_DEVICE_SERIAL_N Mohala o nang le nomoro ea serial ea sesebelisoa sa hau. Tlhophiso ena e hlokomolohuoa ha

UBER_STRING

tlhophiso SL_USBD_STRING_QUANTITY e behiloe ho 0.

SL_USBD_DEVICE_LANGUA Nomoro ea boitsebiso ea puo ea lithapo tsa sesebediswa sa hao. Maemo a ka bang teng ke:
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_GREEK

– SL_USBD_LANG_ID_ITALIAN

– SL_USBD_LANG_ID_PORTUGUESE

– SL_USBD_LANG_ID_SANSKRIT

Tokiso ena e hlokomolohuoa ha SL_USBD_STRING_QUANTITY e behiloe ho 0.

Tlhophiso ea Hardware ea Sesebelisoa sa USB

Ho ipapisitse le sesebelisoa sa Silicon Labs seo u se sebelisang, mohlomong u tla ba le phini ea GPIO le boema-kepe ho hlophisa lets'oao la USB VBUS Sense. Litlhaloso tsa tlhophiso li ho sl_usbd_hardware_config.h hlooho file.

Kamehla
SL_USBD_DRIVER_VBUS_SENSE_PORT SL_USBD_DRIVER_VBUS_SENSE_PIN

Tlhaloso
GPIO Port bakeng sa lets'oao la USB VBUS Sense botong ea hau. GPIO Pin bakeng sa lets'oao la USB VBUS Sense botong ea hau.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

10/174

Fetileview
Fetileview
Tataiso ea Mananeo ea Sesebelisoa sa USB
Karolo ena e hlalosa mokhoa oa ho sebelisa mojule oa Sesebelisoa sa USB.
Tlhophiso ea Pele ea Mojule oa Sesebelisoa sa USB
Karolo ena e hlalosa mehato ea mantlha e hlokahalang ho qala mojule oa Sesebelisoa sa USB le ho eketsa, ho lokisa, le ho qala sesebelisoa. Ho Qalisa Mojule oa Sesebediswa sa USB Ho Qala Sesebediswa sa USB Core Ho Qala ss(es) tsa aCl Ho Tsenya Sesebediswa sa Hao sa USB Ho aha Sesebediswa sa Hao sa USB Ho Eketsa ditlhophiso Ho Kenya Mesebetsi (me) USB Ho Qala Sesebediswa sa Hao sa USB.
Event Hook Functions
Ho qala Module ea Sesebelisoa sa USB
Ho qala sesebelisoa sa USB Core
a US a Qala ka ho qala mojule oa mochine oa B ka ho etsa mosebetsi sl_usbd_core_init() . T aa mohlala o ka tlase o bonts'a c lling sl_usbd_core_init() .
Example - Ho letsetsa sl_usbd_core_init()
sl_status_t boemo; boemo = sl_usbd_core_init(); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}
Ho qala Sehlopha (li)
Ka mor'a hore mochine oa mochine oa USB o qale, o tlameha ho qala sehlopha ka seng seo u rerileng ho se sebelisa. Sheba karolo ea "Programming Guide" ea acl ss(e) ea hau bakeng sa lintlha tse ling.
Ho aha sesebelisoa sa hau sa USB
Eketsa Litlhophiso
Kamora ho qala sesebelisoa sa hau ka katleho, o ka qala ho kenyelletsa mesebetsi ea USB ho eona, ho qala ka tlhophiso e ncha. Sesebelisoa se tlameha ho ba le bonyane tlhophiso e le 'ngoe. Ho kenya litlhophiso, letsetsa tšebetso aa sl_usbd_core_ dd_configur tion() function. Tshebetso ena e tlameha ho bitswa bakeng sa tlhophiso e nngwe le e nngwe eo o batlang ho e kenya. ExampLe ka tlase e bontša mokhoa oa ho eketsa Full-speed.
Example - Eketsa litlhophiso ho sesebelisoa sa hau

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

11/174

Fetileview

sl_status_t boemo; uint8_t config_nbr_fs;

/* Ho eketsa tlhophiso ea lebelo le felletseng ho sesebelisoa. */

boemo = sl_usbd_core_add_configuration(0,

/* Ha ho na litšobotsi tse khethehileng tsa tlhophiso. */

100u,

/* Matla a sebelisoang haholo: 100mA.

*/

SL_USBD_DEVICE_SPEED_FULL,

/* Tlhophiso ea lebelo le felletseng.

*/

“Lokisa Add Example Full-Speed ​​config”,

&config_nbr_fs);

haeba (boemo! SL_STATUS_OK) {

/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */

}

Ho eketsa mesebetsi ea USB
Ka mor'a hore u kenyelle bonyane tlhophiso e le 'ngoe sesebelisoa sa hau, u ka eketsa li-interfaces le li-endpoints ho sesebelisoa sa hau. Sehlopha se seng le se seng sa USB se na le litlhoko tsa sona ho latela sebopeho le mofuta oa li-endpoints, bongata le liparamente tse ling. Silicon Labs USB Device e eketsa li-interfaces le li-endpoints lihlopheng tseo e fanang ka tsona.
Ho tsoa ts'ebelisong ea hau, o ka kenya sehlopha sa USB 'me oa se eketsa ho tlhophiso. Bakeng sa tlhaiso-leseling e batsi mabapi le mohopolo oa maemo a sehlopha sa sesebelisoa sa USB, bona Lihlopha tsa Sesebelisoa sa USB. Hlokomela hore o ka tiisa le ho eketsa maemo a mangata a fapaneng a sehlopha ho tlhophiso ho theha sesebelisoa se nang le mesebetsi e mengata (e kopaneng).
ExampLe ka tlase e bonts'a mokhoa oa ho theha mohlala oa sehlopha le ho o kenya ho tlhophiso.
Example - Ho eketsa Boemo ba Sehlopha ho Sesebelisoa sa Hau

sl_status_t boemo; uint8_t class_nbr;
/* Etsa mohlala oa sehlopha seo u batlang ho se sebelisa.*/ /* Hlokomela hore ho itšetlehile ka sehlopha mosebetsi ona o ka ba le likhang tse ngata. */ boemo = sl_usbd_ _create_instance(&class_nbr); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}
/* Eketsa mohlala oa sehlopha ho tlhophiso ea Full-Speed. */ boemo = sl_usbd_ _add_to_configuration(class_nbr, /* Nomoro ea sehlopha e khutlisitsoe ke sl_usbd_ _bopa_mohlala. */
config_nbr_fs); /* Nomoro ea tlhophiso e khutlisitsoe ke sl_usbd_core_add_configuration(). */ haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}
Ho qala sesebelisoa sa hau sa USB
Ka mokhoa o ikhethileng, sesebelisoa se tla qalisoa ka boiketsetso ke ts'ebetso ea mantlha ea sesebelisoa sa USB kamora hore ts'ebetso ea sesebelisoa e phetheloe mme kernel e qale. Ho laola hore na sesebelisoa se qala neng 'me se qala ho bonahala ho moamoheli oa USB, sebelisa litlhophiso tse hlalosang SL_USBD_AUTO_START_USB_DEVICE ho tima sesebelisoa sa ho iqalla. Ha e holofetse, ka mor'a hore u hahe / u lokisetse sesebelisoa sa hau, u ka se qala 'me ua etsa hore se bonahale ho moamoheli oa USB ka ho letsetsa ts'ebetso sl_usbd_core_start_device() .
ExampLe ka tlase e bonts'a mokhoa oa ho qala sesebelisoa sa hau ka ts'ebetso ea sl_usbd_core_start_device().
Example - Ho qala sesebelisoa sa hau

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

12/174

Fetileview

sl_status_t boemo;
boemo = sl_usbd_core_start_device(); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}

Event Hook Functions
Mojule oa mantlha oa Sesebelisoa sa USB o fana ka likarolo tse peli tse fokolang tsa hook tseo o ka li hlalosang hape ts'ebelisong ea hau. Sepheo sa bona ke ho tsebisa ha liketsahalo tsa libese le tsa tlhophiso li etsahala.
Tafole - Mesebetsi ea Hook ea Ketsahalo ea USB

Ketsahalo

Tlhaloso

Bese

E bitsoa ha ketsahalo ea Bese ea USB e etsahala

Tlhophiso E bitswa ha ketsahalo ya Tlhophiso ya USB e etsahala

Mosebetsi Tshaeno
void sl_usbd_on_bus_event(ketsahalo ea sl_usbd_bus_event_t); void sl_usbd_on_config_event(sl_usbd_config_event_t ketsahalo, uint8_t config_nbr);

Example – Event Hook Functions

void sl_usbd_on_bus_event(sl_usbd_bus_event_t ketsahalo) { switjha (ketsahalo) { case SL_USBD_EVENT_BUS_CONNECT:
// e bitsoa ha thapo ea USB e kenngoa ka khefu ea molaoli oa baeti;
case SL_USBD_EVENT_BUS_DISCONNECT: // e bitsoa ha thapo ea USB e tlosoa ho khefu ea molaoli oa moamoheli;
case SL_USBD_EVENT_BUS_RESET: // e bitsoa ha moamoheli a romella khefu ea taelo ea reset;
case SL_USBD_EVENT_BUS_SUSPEND: // e bitsoa ha moamoheli a romella taelo ea ho emisa;
case SL_USBD_EVENT_BUS_RESUME: // bitsoa ha moamoheli a romela taelo ea ho tsoha;
kamehla: khefu; }}
void sl_usbd_on_config_event(sl_usbd_config_event_t ketsahalo, uint8_t config_nbr) { switjha (ketsahalo) { case SL_USBD_EVENT_CONFIG_SET:
// e bitsoa ha moamoheli a beha khefu ea tlhophiso;
case SL_USBD_EVENT_CONFIG_UNSET: // e bitsoa ha tlhophiso e sa hlophisoa;
kamehla: khefu; }}

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

13/174

Fetileview

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

14/174

Fetileview
Fetileview

Lihlopha tsa lisebelisoa tsa USB

Litlelase tsa USB tse fumanehang ho Silicon Labs USB Device li arolelana litšobotsi tse ling tse tloaelehileng. Karolo ena e hlalosa litšobotsi tsena le likamano tsa tsona le lera la mantlha.
Bakeng sa tlhaiso-leseling e batsi ka sehlopha se ikhethileng, sheba tse latelang:
CDC ACM Class HID Sehlopha sa MSC SCSI Sehlopha sa Barekisi
Mabapi le Maemo a Sehlopha
Litlelase tsa USB tse fumanehang ho Sesebelisoa sa USB li kenya tšebetsong mohopolo oa maemo a sehlopha. Mohlala oa sehlopha o emela tšebetso e le 'ngoe ka har'a sesebelisoa. Mosebetsi o ka hlalosoa ka sebopeho se le seng kapa ka sehlopha sa li-interfaces mme ke oa sehlopha se itseng.
Ts'ebetso e 'ngoe le e' ngoe ea sehlopha sa USB e na le litlhophiso le mesebetsi e tšoanang, ho latela mohopolo oa mohlala oa sehlopha. Litlhophiso tse tloaelehileng le mesebetsi li hlahisoa tafoleng e ka tlase. Sehloohong sa kholomo ea 'Constants or Function', setšoantšisi XXXX se ka nkeloa sebaka ke lebitso la sehlopha: CDC, HID, MSC, CDC_ACM kapa VENDOR (Morekisi oa mabitso a tšebetso).
Lethathamo - Li-Constants le Mesebetsi e Amanang le Mohopolo oa Maemo a Mangata a Sehlopha

Kamehla kapa Mosebetsi
SL_USBD_XXX_CL ASS_INS TANCE_QUANTITY
SL_USBD_XXX_CONFIGUR ATION_QUANTITY
sl_usb d _XXX_cre e jele _insta nce ()
sl_usbd_XXX_add_to_conf iguration()

Tlhaloso
E lokisa boholo ba palo ea maemo a sehlopha.
E lokisa boholo ba palo ea litlhophiso. Nakong ea ho qala sehlopha, mohlala oa sehlopha o entsoeng o tla eketsoa ho tlhophiso e le 'ngoe kapa ho feta. E theha mohlala o mocha oa sehlopha.
E eketsa mofuta o teng oa sehlopha ho litlhophiso tse boletsoeng tsa sesebelisoa.

Mabapi le ts'ebetsong ea khoutu, sehlopha se tla phatlalatsa phetoho ea lefats'e ea lehae e nang le sebopeho sa taolo ea sehlopha. Sebopeho sena sa taolo ea sehlopha se amahanngoa le mohlala oa sehlopha se le seng 'me se tla ba le lintlha tse khethehileng ho laola mohlala oa sehlopha.
Lipalo tse latelang li bontša maemo a 'maloa a liketsahalo. Palo e 'ngoe le e 'ngoe e kenyelletsa khoutu ea example tse tsamaellanang le boemo ba nyeoe.
Setšoantšo - Maemo a Mangata a Lihlopha - FS Device (1 Configuration with 1 Interface) e emela sesebelisoa se tloaelehileng sa USB. Sesebelisoa ke Full-Speed ​​(FS) mme se na le tlhophiso e le 'ngoe. Mosebetsi oa sesebelisoa o hlalosoa ke sebopeho se le seng se entsoeng ka li-endpoints tsa puisano ea data. Mohlala o le mong oa sehlopha o entsoe 'me o tla u lumella ho laola sebopeho sohle ka ntlha e amanang le eona.
Setšoantšo - Maemo a mangata a lihlopha - FS Device 1 Configuration with 1 Interface)

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

15/174

Fetileview

Khoutu e tsamaellanang le Figure - Multiple Class Instances - FS Device (1 Configuration with 1 Interface) e bonts'itsoe ho ex.ample ka tlase.
Example - Maemo a mangata a Sehlopha - Sebopeho sa FS Device 1 se nang le 1 Interface)

sl_status_t boemo; uint8_t class_0;

void app_usbd_XXX_enable(uint8_t class_nbr) {/* Tšoara ketsahalo ea Class. */}

void app_usbd_XXX_disable(uint8_t class_nbr) {/* Tšoara ketsahalo e thibelang Sehlopha. */}

sl_usbd_XXXX_callbacks_t class_callbacks = {

(1)

.enable = app_usbd_XXX_ nolofalletsa,

.disable = app_usbd_XXX_disable

};

boemo = sl_usbd_XXX_init();

(2)

haeba (boemo! SL_STATUS_OK) {

/* $$$$ Tšoara phoso. */

}

boemo = sl_usbd_XXX_create_instance(&class_callbacks,

(3)

&class_0);

haeba (boemo! SL_STATUS_OK) {

/* $$$$ Tšoara phoso. */

}

boemo = sl_usbd_XXX_add_to_configuration(class_0, config_0);

(4)

haeba (boemo! SL_STATUS_OK) {

/* $$$$ Tšoara phoso. */

}

(1) Sehlopha se seng le se seng se fana ka sete ea lits'ebetso tsa callback bakeng sa ho hokela lisebelisoa / ho hakolla liketsahalo le liketsahalo tse ikhethileng tsa sehlopha. Ntho ea sebopeho sa callback e fetisoa e le khang ha ho etsoa mohlala oa sehlopha ka sl_usbd_XXX_create_instance()
tshebetso.
(1) Simolola tlelase. Liphetoho tsohle tsa ka hare, mehaho, le likou tsa lihlopha li tla qalisoa. Hlokomela hore mosebetsi oa Init() lihlopheng tse ling o ka nka likhang tse ling.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

16/174

Fetileview
(2) Theha mohlala oa sehlopha, e leng class_0 . Mosebetsi sl_usbd_XXXX_create_instance() o fana ka sebopeho sa taolo ea sehlopha se amanang le class_0 . Ho ipapisitsoe le sehlopha, sl_usbd_XXX_create_instance() e kanna ea ba le liparamente tse ling kantle ho nomoro ea sehlopha e emelang tlhaiso-leseling e ikhethileng e bolokiloeng sebopehong sa taolo ea sehlopha. aaa (3) Kenya cl ss inst nce, class_0 , ho nomoro ea tlhophiso e boletsoeng, config_0 . sl_usbd_XXXX_add_to_configuration() e tla theha sebopeho 0 le lintlha tse amanang le eona tsa IN le OUT. Ka lebaka leo, mohlala oa sehlopha o kenyelletsa sebopeho sa 0 le lintlha tsa eona tsa ho qetela. Puisano efe kapa efe e etsoang ho interface 0 e tla sebelisa nomoro ea mohlala ea sehlopha, class_0 . Figure - Multiple Class Instances - FS Device (2 Configurations and Multiple Interfaces) e emela ex e rarahaneng ho fetaample. Sesebelisoa sa lebelo le felletseng se entsoe ka litlhophiso tse peli. Sesebelisoa se na le mesebetsi e 'meli ea sehlopha se le seng, empa ts'ebetso e' ngoe le e 'ngoe e hlalosoa ka li-interfaces tse peli' me e na le li-endpoints tse peli. Ho sena mohlalaample, maemo a mabeli a lihlopha a entsoe. Mohlala o mong le o mong oa sehlopha o amahanngoa le sehlopha sa li-interfaces ho fapana le Figure - Multiple Class Instances - FS Device (1 Configuration with 1 Interface) le Figure - Multiple Class Instances - FS Device (2 Configurations and Multiple Interfaces) moo mohlala oa sehlopha o neng o amahanngoa le sebopeho se le seng.
Setšoantšo - Mekhahlelo e Mengata ea Lihlopha - Litlhophiso tsa FS Device 2 le li-interfaces tse ngata)

Khoutu e tsamaellanang le Figure - Multiple Class Instances - FS Device (2 Configurations and Multiple Interfaces) e bonts'itsoe ho ex.ample ka tlase. Phoso e siiloe bakeng sa ho hlaka.
Example - Mehato e mengata ea Lihlopha - Litlhophiso tsa FS Device 2 le li-interfaces tse ngata)

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

17/174

Fetileview

sl_status_t boemo; uint8_t class_0; uint8_t class_1;
boemo = sl_usbd_XXX_init();
boemo = sl_usbd_XXX_create_instance(&class_0); boemo = sl_usbd_XXX_create_instance(&class_1);
boemo = sl_usbd_XXX_add_to_configuration(class_0, cfg_0); boemo = sl_usbd_XXX_add_to_configuration(class_1, cfg_0);
boemo = sl_usbd_XXX_add_to_configuration(class_0, cfg_1); boemo = sl_usbd_XXX_add_to_configuration(class_1, cfg_1);

(1)
(2) (3)
(4) (5)
(6) (6)

(1) Simolola tlelase. Liphetoho life kapa life tsa ka hare, meaho, le likou tsa maemo li tla qalisoa.
(2) Theha mohlala oa sehlopha, sehlopha_0 . Mosebetsi sl_usbd_XXXX_create_instance() o fana ka sebopeho sa taolo ea sehlopha se amanang le class_0 .
(3) Theha mohlala oa sehlopha, sehlopha_1 . Mosebetsi sl_usbd_XXXX_create_instance() o fana ka sebopeho se seng sa taolo ea sehlopha se amanang le class_1 .
(4) Kenya mohlala oa sehlopha, class_0 , ho tlhophiso, cfg_0 . sl_usbd_XXXX_add_to_configuration() e tla theha segokanyimmediamentsi sa 0, segokanyimmediamentsi sa 1, li-interfaces tse ling, le li-endpoints tse amanang le IN le OUT. Nomoro ea mohlala ea sehlopha, class_0 , e tla sebelisoa bakeng sa puisano leha e le efe ea data ho interface 0 kapa interface 1.
(5) Kenya mohlala oa sehlopha, class_1 , ho tlhophiso, cfg_0 . sl_usbd_XXXX_add_to_configuration() e tla theha segokanyimmediamentsi sa 2, sebopeho sa 3 le lintlha tse amanang le tsona tsa IN le OUT. Nomoro ea mohlala ea sehlopha, class_1 , e tla sebelisoa bakeng sa puisano leha e le efe ea data ho interface 2 kapa interface 3.
(6) Eketsa maemo a tšoanang a sehlopha, class_0 le class_1 , ho tlhophiso e 'ngoe, cfg_1 .
Sehlopha se seng le se seng se hlalosa sebopeho sa mofuta sl_usbd_XXX_callbacks_t . Sepheo sa eona ke ho fa sehlopha se seng le se seng sehlopha sa mesebetsi ea callback e tla bitsoa ha ketsahalo e etsahala. Mesebetsi e 'meli ea callback e teng sehlopheng ka seng. Li hlahisoa tafoleng e ka tlase.
Tafole - Mesebetsi e Tloaelehileng ea Callback Class

Fields Description .enable E bitsitsoe ha mohlala oa sehlopha sa USB o buletsoe ka katleho. .disable E bitswa ha mohlala wa sehlopha sa USB o timilwe.

Tšebeliso e sa sebetseng ea Signature_usbd_XXX_enable(uint8_t class_nbr); sesebelisoa sa lefeela_usbd_XXX_disable(uint8_t class_nbr);

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

18/174

Fetileview
Fetileview
Sesebediswa sa USB CDC ACM Sehlopha
Sesebelisoa sa USB CDC Base Class Overview Sesebediswa sa USB CDC ACM Class Resource Litlhoko ho tloha Core USB Device CDC ACM Subclass Overview Sesebediswa sa USB CDC ACM Sehlopha sa Tlhophiso Sesebediswa sa USB Sesebediswa sa CDC ACM Class Programming Guide
Karolo ena e hlalosa sehlopha sa Disebediswa tsa Dikgokahano (CDC) le sehlopha se amanang le CDC se tshehetswang ke Silicon Labs' USB Device stack. Silicon Labs USB-Device hajoale e ts'ehetsa "Abstract Control Model" (ACM) subclass, e sebelisoang hangata bakeng sa emulation ea serial.
CDC e kenyelletsa lisebelisoa tse fapaneng tsa puisano le marang-rang. Lisebelisoa tsa puisano li kenyelletsa li-modem tsa analog, lithelefono tsa analog le tsa digital, li-adapter tsa terminal tsa ISDN, joalo-joalo.ample, lisebelisoa tsa marang-rang li na le ADSL le modem tsa cable, li-adapter tsa Ethernet, le hubs. CDC e hlalosa moralo oa ho kenyelletsa maemo a teng a litšebeletso tsa puisano, joalo ka V.250 (bakeng sa li-modem holim'a marang-rang a thelefono) le Ethernet (bakeng sa lisebelisoa tsa marang-rang sebakeng sa heno), ho sebelisa sehokelo sa USB. Sesebediswa sa puisano se laola taolo ya sesebediswa, taolo ya mehala ha ho hlokahala, le phetiso ya data.
CDC e hlalosa lihlopha tse supileng tse kholo tsa lisebelisoa. Sehlopha se seng le se seng ke sa mohlala oa puisano, o ka kenyelletsang lihlopha tse 'maloa. Sehlopha se seng le se seng sa lisebelisoa se na le tokomane ea sona e ikhethileng ntle le sehlopha sa motheo sa CDC. Lihlopha tse supileng ke:
Public Switched Telephone Network (PSTN), lisebelisoa tse kenyelletsang li-modem tsa voiceband, mehala, le lisebelisoa tsa serial emulation. Lisebelisoa tsa Integrated Services Digital Network (ISDN), ho kenyeletsoa li-adapter tsa terminal le mehala. Lisebelisoa tsa Ethernet Control Model (ECM), ho kenyelletsa le lisebelisoa tse tšehetsang lelapa la IEEE 802 (mohlala: cable le modem tsa ADSL, li-adapter tsa WiFi). Lisebelisoa tsa Asynchronous Transfer Mode (ATM), ho kenyeletsoa modem tsa ADSL le lisebelisoa tse ling tse hokahaneng le marang-rang a ATM (lits'ebetso, lirutha, li-switch tsa LAN). Lisebelisoa tsa Wireless Mobile Communications (WMC), ho kenyeletsoa lisebelisoa tse ngata tsa puisano tse sebelisoang ho laola likhokahano tsa lentsoe le data. Lisebelisoa tsa Ethernet Emulation Model (EEM) tse fapanyetsanang data e entsoeng ka foreimi ea Ethernet. Lisebelisoa tsa Network Control Model (NCM), ho kenyeletsoa lisebelisoa tsa marang-rang tsa lebelo le phahameng (modem tsa ho fihlella ka lebelo le phahameng, lisebelisoa tsa mohala)
CDC le ts'ebetsong e amanang le eona e tsamaisana le lintlha tse latelang:
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.
Sesebelisoa sa USB CDC Base Class Overview
Sesebelisoa sa CDC se entsoe ka likhokahano tse latelang ho kenya tšebetsong bokhoni ba puisano:
Communications Class Interface (CCI) e ikarabella bakeng sa taolo ea sesebelisoa le taolo ea mehala ka boikhethelo. The
taolo ea sesebelisoa e etsa hore ho be le tlhophiso e akaretsang le taolo ea sesebelisoa le tsebiso ea liketsahalo ho moamoheli. Tsamaiso ea mehala e thusa ho theha le ho emisa mehala. Taolo ea mehala e kanna ea atolosoa ka DCI. CCI e tlama bakeng sa lisebelisoa tsohle tsa CDC. E khetholla mosebetsi oa CDC ka ho totobatsa mokhoa oa puisano o tšehetsoeng ke mochine oa CDC. Khokahano (s) e latelang CCI e ka ba sebopeho sefe kapa sefe se hlalositsoeng sa sehlopha sa USB, joalo ka Audio kapa sebopeho se ikhethileng sa morekisi. Sehokelo se ikhethileng sa morekisi se emeloa ka kotloloho ke DCI.
Data Class Interface (DCI) e ikarabella bakeng sa phetiso ea data. Lintlha tse fetisitsoeng le/kapa tse amoheloang ha li latele e itseng
sebopeho. Lintlha e ka ba data e tala ho tsoa mocheng oa puisano, data e latelang sebopeho sa mong'a ntlo, joalo-joalo. Li-DCI tsohle tse latelang CCI li ka bonoa e le li-interfaces tse tlase.
Sesebelisoa sa CDC se tlameha ho ba le bonyane CCI e le 'ngoe le zero kapa ho feta tsa DCI. CCI e le 'ngoe le DCI efe kapa efe e ka tlase hammoho li fana ka tšobotsi ho moamoheli. Bokhoni bona bo boetse bo bitsoa mosebetsi. Ka sesebelisoa se kopantsoeng sa CDC, u ka ba le tse 'maloa

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

19/174

Fetileview
mesebetsi. Ka hona, sesebelisoa se ne se tla etsoa ka lihlopha tse 'maloa tsa CCI le DCI (s) joalokaha ho bontšoa ho Figure - CDC Composite Device.
Setšoantšo - CDC Composite Device

Sesebelisoa sa CDC se kanna sa sebelisa motsoako o latelang oa li-endpoints:
Likarolo tse peli tsa taolo IN le OUT tse bitsoang "default endpoint". Bongata bo ikgethang kapa sitisa IN qetellong. Likarolo tse peli tse ngata kapa tsa isochronous IN le OUT. Hlokomela hore "Silicon Labs" sesebelisoa sa USB ha hajoale ha se tšehetse li-endpoints tsa isochronous.
Tafole e ka tlase e bonts'a ts'ebeliso ea li-endpoints tse fapaneng le hore na li sebelisoa ka sebopeho sefe sa CDC.
Tafole - CDC Endpoint Tšebeliso

Qetello
Laola IN
Laola TSOA
Thibela kapa bongata KA Bongata kapa isochronous IN Bulk kapa isochronous
TSOA

Tataiso
Sesebediswa-moamoheli
Host-todevice
Sesebediswa-moamoheli
Sesebediswa-moamoheli
Host-todevice

Tšebeliso ea Interface

CCI

Likopo tse tloaelehileng tsa ho baloa, likopo tse ikhethileng tsa sehlopha, sesebelisoa

tsamaiso, le boikhethelo letsetsa tsamaiso.

CCI

Likopo tse tloaelehileng tsa ho baloa, likopo tse ikhethileng tsa sehlopha, sesebelisoa

tsamaiso, le boikhethelo letsetsa tsamaiso.

CCI

Tsebiso ea diketsahalo, joalo ka ring detect, serial line status, network status.

DCI

Khokahano ea data e tala kapa e hlophisitsoeng.

DCI

Khokahano ea data e tala kapa e hlophisitsoeng.

Lisebelisuoa tse ngata tsa puisano li sebelisa sebaka sa ho qetela ho tsebisa bongata ba liketsahalo. Li-endpoints tsa Isochronous ha lia lokela ho sebelisoa bakeng sa phetisetso ea data ha protocol ea mong'a ntlo e itšetleha ka phetiso ea data ha ho ka ba le liphoso tsa protocol ea USB. Puisano ea Isochronous e ka lahleheloa ke data ka tlhaho kaha ha e na mekhoa ea ho leka hape.
Mefuta e supileng e meholo ea puisano e akaretsa likaroloana tse 'maloa. Sehlopha se senyenyane se hlalosa tsela eo sesebelisoa se lokelang ho sebelisa CCI ho sebetsana le tsamaiso ea lisebelisoa le tsamaiso ea mohala. Tafole e ka tlase e bonts'a lihlotšoana tsohle tse ka khonehang le mokhoa oa puisano oo ba leng ho oona.
Tafole - CDC Subclasses

Sehlopha se tlase
Direct Line Control Model Abstract Control Model

Mohlala oa puisano
PSTN
PSTN

Example ea Lisebelisoa tse Sebelisang Sehlopheng sena
Lisebelisoa tsa modem tse laoloang ka kotloloho ke moamoheli oa USB
Lisebelisoa tsa serial emulation, lisebelisoa tsa modem tse laoloang ka sete ea taelo ea serial

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

20/174

Fetileview

Sehlopha se tlase

Mohlala oa puisano

Example ea Lisebelisoa tse Sebelisang Sehlopheng sena

Mohlala oa Taolo ea Mohala

PSTN

Litsela tse ngata tsa ho laola ISDN Model

CAP Control Model ISDN

Ethernet Networking ECM Control Model

ATM Networking

ATM

Mohlala oa Taolo

Wireless Handset Control Model

WMC

Tsamaiso ea lisebelisoa WMC

Mobile Direct Line Model

WMC

OBEX

WMC

Ethernet Emulation EEM Model

Mohlala oa Taolo ea Marang-rang

NCM

Lisebelisoa tsa mohala oa lentsoe
Li-adapter tsa li-terminal tsa litekanyetso tsa mantlha, li-adapter tsa litekanyetso tsa mantlha, mehala
Li-adapter tsa litekanyetso tsa mantlha, li-adapter tsa litheminale tsa mantlha, li-modem tsa cable tsa DOC-SIS tsa mehala, li modem tsa ADSL tse tšehetsang mohlala oa PPPoE, li-adapter tsa Wi-Fi (IEEE 802.11-family), IEEE 802.3 adapters ADSL modem
Thepa ea mohala e hokelang lisebelisoa tse se nang mohala
Thepa ea mohala e hokelang ho lisebelisoa tsa waelese Thepa ea mohala e hokelang ho lisebelisoa tsa waelese
Thepa ea mohala e hokelang ho lisebelisoa tse se nang mohala Lisebelisoa tse sebelisang liforeimi tsa Ethernet joalo ka karolo e latelang ea lipalangoang. Ha ea rereloa lisebelisoa tsa ho tsamaisa le ho hokela Marang-rang li-adapter tsa IEEE 802.3 tse tsamaisang data ea lebelo le holimo marang-rang.

Sesebediswa sa USB CDC ACM Class Resource Litlhoko ho tloha Core

Nako le nako ha u eketsa mohlala oa sehlopha sa CDC ACM ho tlhophiso ea USB ka mohala ho ts'ebetso sl_usbd_cdc_acm_add_to_configuration() , lisebelisoa tse latelang li tla abeloa ho tloha mantlha.

Mohlodi
Li-interfaces Mefuta e meng ea lihokelo Lihlopha tsa Endpoints Interface

Bongata
2 2 3 1

Hlokomela hore linomoro tseo ke tsa tlhophiso. Ha o theha SL_USBD_INTERFACE_QUANTITY , SL_USBD_ALT_INTERFACE_QUANTITY , SL_USBD_INTERFACE_GROUP_QUANTITY le SL_USBD_DESCRIPTOR_QUANTITY litekanyetso tsa lipeakanyo, u seke oa lebala ho ela hloko hore na ke litlhophiso tse kae tse tla eketsoa. Bakeng sa boleng ba tlhophiso ea SL_USBD_OPEN_ENDPOINTS_QUANTITY, kaha li-endpoints li buloa feela ha tlhophiso e behiloe ke moamoheli, o hloka feela ho ela hloko palo ea lintlha tse hlokahalang bakeng sa mohlala oa sehlopha.
Sesebelisoa sa USB CDC ACM Subclass Overview

Sehlopha sa motheo sa CDC se entsoe ka Interface Class Class (CCI) le Data Class Interface (DCI), tse tšohloang ka botlalo ho USB Device CDC Base Class Over.view . Karolo ena e bua ka CCI ea mofuta oa ACM. E na le ntlha ea kamehla ea ho qetela bakeng sa karolo ea tsamaiso le ntlha e sitisang ea karolo ea tsebiso. Li-endpoints tse ngata li sebelisoa ho tsamaisa data e sa hlalosoang holim'a DCI.
ACM subclass e sebelisoa ke mefuta e 'meli ea lisebelisoa tsa puisano:
Lisebelisoa tse tšehetsang litaelo tsa AT (mohlala, li-modem tsa voiceband). Lisebelisoa tsa serial emulation tseo hape li bitsoang lisebelisoa tsa boema-kepe tsa Virtual COM.
Ho na le likopo tse 'maloa tse ikhethileng tsa sehlopha sa ACM. Li u lumella ho laola le ho lokisa sesebelisoa. Lethathamo le felletseng le tlhaloso ea likopo tsohle tsa ACM li ka fumanoa ho tse boletsoeng

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

21/174

Fetileview Subclass for PSTN Devices, revision 1.2, February 9, 2007=, karolo ea 6.2.2.
Ho tsoa lethathamong lena, Silicon Labs9 ACM subclass e tšehetsa tse latelang:
Tafole - Likopo tsa ACM tse Tšehetsoeng ke Silicon Labs

Tlhaloso ea Kopo ea Sehlopha se Senyenyane

SetCommFeature GetCommFeature ClearCommFeature

Moamoheli o romella kopo ena ho laola litlhophiso tsa karolo e fanoeng ea likhokahano. Ha e sebelisoe ho etsisa mohlala oa serial.
Moamoheli o romella kopo ena ho fumana litlhophiso tsa hajoale bakeng sa karolo e fanoeng ea likhokahano. Ha e sebelisoe ho etsisa mohlala oa serial.
Moamoheli o romella kopo ena ho hlakola litlhophiso tsa karolo e fanoeng ea likhokahano. Ha e sebelisoe ho etsisa mohlala oa serial.

SetLineCoding

Moamoheli o romella kopo ena ho lokisa litlhophiso tsa sesebelisoa sa ACM: sekhahla sa baud, palo ea li-stop bits, mofuta oa parity le palo ea likotoana tsa data. Bakeng sa emulation ea serial, kopo ena e romelloa ka bo eona ke serial terminal nako le nako ha u lokisa li-setting tsa serial bakeng sa boema-kepe ba COM bo bulehileng.

FumanaLineCoding

Moamoheli o romella kopo ena ho fumana litlhophiso tsa hajoale tsa ACM (sekhahla sa baud, li-stop bits, parity, data bits). Bakeng sa emulation ea serial, liteishene tsa serial li romella kopo ena ka bo eona nakong ea ha ho buloa boema-kepe ba COM.

SetControlLineState Motho ea amohelang molaetsa o romela kopo ena ho laola mofani oa li-modem tsa halofo-duplex le ho bontša hore Sesebelisoa sa Data Terminal Equipment (DTE) se lokile kapa che. Tabeng ea serial emulation, DTE ke serial terminal. Bakeng sa emulation ea serial, liteishene tse ling tsa serial li u lumella ho romella kopo ena ka li-control tse behiloeng.

SetBreak

Moamoheli o romella kopo ena ho hlahisa khefu ea mofuta oa RS-232. Bakeng sa emulation ea serial, liteishene tse itseng tsa serial li u lumella ho romella kopo ena.

Silicon Labs9 ACM subclass e sebelisa interrupt IN endpoint ho tsebisa moamoheli ka boemo ba hajoale ba serial line. The serial
line state ke bitmap e tsebisang moamoheli ka:

Lintlha li lahliloe ka lebaka la phoso e fetelletseng ea Parity Phoso ea ho theha Boemo ba ho fumanwa ha lets'oao la selikalikoe.

Ts'ebetsong ea sehlopha sa Silicon Labs9 ACM e lumellana le lintlha tse latelang:
Universal Serial Bus, Communications, Subclass for PSTN Devices, revision 1.2, February 9, 2007.
Sesebediswa sa USB CDC ACM Class Configuration

Karolo ena e bua ka mokhoa oa ho hlophisa Sehlopha sa CDC ACM (Sehlopha sa Sesebelisoa sa Puisano, Mohlala oa Taolo ea Abstract). Ho na le lihlopha tse peli tsa paramente ea tlhophiso:
Sesebediswa sa USB CDC ACM Class Application
Sesebediswa sa USB CDC ACM Class Kopo Litlhophiso tse Khethehileng

CDC Base Class ACM Subclass
Sehlopha sa motheo sa CDC

Taba ea pele, ho sebelisa mochini oa CDC oa sesebelisoa sa Silicon Labs USB, o tla hloka ho lokisa CDC compile-time configuration #define-s ho latela litlhoko tsa kopo ea hau. Li kopantsoe hape ka har'a sehlooho sa sl_usbd_core_config.h file tlas'a karolo ea CDC. Sepheo sa bona ke ho tsebisa mojule oa sesebelisoa sa USB mabapi le hore na u ka abela lintho tse kae tsa USB CDC.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

22/174

Fetileview

Tafole e ka tlase e hlalosa sebaka se seng le se seng sa tlhophiso se fumanehang sebopehong sena sa tlhophiso.
Tafole - Sesebediswa sa USB CDC Configuration e Hlalosa

Lebitso la Tlhophiso
SL_USBD_CDC_CL AS S_INSTANCE_QUANT ITY
SL_USBD_CDC_CONF IGURATION_QUANTI
TY
SL_USBD_CDC_DATA _INTERFACE_QUANTI
TY

Tlhaloso
Palo ea maemo a phaposi eo u tla e abela ka mohala ho tšebetso
sl_usbd_cdc_acm_create_instance() .
Palo ea litlhophiso. Maemo a sehlopha sa ACM a ka eketsoa ho tlhophiso e le 'ngoe kapa tse ngata tsa aaaa vi c ll ho sl_usbd_cdc_acm_add_to_configuration() .
Kakaretso ea palo ea likhokahano tsa data (DCI) bakeng sa mesebetsi eohle ea CDC. Mosebetsi o mong le o mong oa CDC ACM aaaaaaaaa o kentse vi c ll mosebetsing sl_usbd_cdc_acm_create_instance() o tla dd dt interf ce.

Boleng ba kamehla
2
1
2

Sehlopha sa ACM
ACM subclass e na le tlhophiso e le 'ngoe ea nako ea pokello e bontšitsoeng tafoleng e ka tlase.
Tafole - Sesebediswa sa USB CDC ACM Configuration Define

Lebitso la Tlhophiso
SL_USBD_CDC_ACM_SUBCL ASS_I NSTANCE_QUANTITY

Tlhaloso
E hlophisa palo ea maemo a subclass ao u tla a abela ka mohala ho
tshebetso sl_usbd_cdc_acm_create_instance() .

Boleng ba kamehla
2

Sesebelisoa sa USB CDC ACM Class Instance Configurations

Karolo ena e hlalosa litlhophiso tse amanang le maemo a serial a CDC ACM. Class Instance Creation line interval state call mgmt capabilities p_acm_callbacks
Pōpo ea Boemo ba Sehlopha

Ho theha mohlala oa serial oa CDC ACM, letsetsa tšebetso T a sl_usbd_cdc_acm_create_instance() . mosebetsi oa hae t ke mabaka a mararo a tlhophiso, joalo ka ha ho hlalositsoe mona.

line_state_interval
Ena ke nako (ka milliseconds) eo mohlala oa hau oa serial oa CDC ACM o tla tlaleha litemoso tsa boemo ba mohala ho moamoheli oa T aa. lets'oao la hae e tlameha ho ba matla a mabeli (1, 2, 4, 8, 16, joalo-joalo).

call_mgmt_capabilities
Bitmap ea Bokhoni ba Tsamaiso ea Call. Lintlha tse ka bang teng tsa bitmap ke tse latelang:

Boleng (bit)
SL_USBD_ACM_SERIAL_CALL_MGMT_DEV
SL_USBD_ACM_SERIAL_CALL_MGMT_DATA_CCI _DCI

Tlhaloso
Sesebelisoa se sebetsana le taolo ea mohala ka boyona. Sesebediswa se ka romela/amohela lesedi la taolo ya mehala ka sehokelo sa Data Class.

p_acm_callbacks

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

23/174

Fetileview

aa M aa p_acm_callbacks ke sesupo sa sebopeho sa mofuta sl_usbd_cdc_acm_callbacks_t . Sepheo sa eona ke ho fa CDC AC Cl ss sete ea mesebetsi ea callback e tla bitsoa ha ketsahalo ea CDC ACM e etsahala. Ha se li-callback tsohle tse tlamang 'me null pointer (NULL) e ka fetisoa ka mokhoa o fapaneng oa sebopeho sa callback ha callback e sa hlokahale. Tafole e ka tlase e hlalosa sebaka se seng le se seng sa tlhophiso se fumanehang sebopehong sena sa tlhophiso.
Tafole – sl_usbd_cdc_acm _callbacks_t Sebopeho sa Tlhophiso

Masimo

Tlhaloso

.nontsha

E bitsoa ha mohlala oa sehlopha sa USB o buletsoe

ka katleho.

.thibela

E bitsoa ha mohlala oa sehlopha sa USB o koetsoe.

.line_control_changed E bitsoa ha phetoho ea taolo ea mohala e amoheloa.

line_coding_changed E bitsoa ha phetoho ea likhoutu tsa mohala e amoheloa.

Mosebetsi Tshaeno
sesebelisoa sa lefeela_usbd_cdc_acm_enable(uint8_t subclass_nbr);
sesebelisoa sa lefeela_usbd_cdc_acm_disable(uint8_t subclass_nbr);
app e se nang letho_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

Sheba karolo ea Ho Ngolisa Melaetsa ea Tsebiso ea Ketsahalo bakeng sa lits'ebetso tsa callback example.
Sesebelisoa sa USB CDC ACM Class Programming Guide

Karolo ena e hlalosa mokhoa oa ho sebelisa sehlopha sa CDC Abstract Control Model. Ho Qala Sesebediswa sa USB CDC Sehlopha sa ACM Ho Kenyelletsa Sesebediswa sa USB CDC ACM Class Boemo ho Sesebediswa sa Hao se Buisanang ka ho Sebelisa Sehlopha sa CDC ACM
Ho qala Sesebediswa sa USB CDC ACM Sehlopha

Ho eketsa ts'ebetso ea sehlopha sa CDC ACM sesebelisoa sa hau, o tlameha ho qala sehlopha sa CDC le sehlopha se senyenyane sa ACM ka aac lling the functions sl_usbd_cdc_init() nd sl_usbd_cdc_acm_init() . T aaaaa mohlala o ka tlase o bonts'a mokhoa oa ho cll sl_usbd_cdc_init() nd sl_usbd_cdc_acm_init() u sebelisa likhang tse ngata.

Example - Ho qalisoa ha Sehlopha sa CDC ACM

sl_status_t boemo;
boemo = sl_usbd_cdc_init(); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}
boemo = sl_usbd_cdc_acm_init(); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}
Ho eketsa Sesebediswa sa USB CDC ACM Class Instance ho sesebelisoa sa hau
Ho kenya ts'ebetso ea sehlopha sa CDC ACM sesebelisoa sa hau, o tlameha ho theha mohlala, ebe o o kenya ho litlhophiso tsa sesebelisoa sa hau.
Ho theha Boemo ba Sehlopha sa CDC ACM

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

24/174

Fetileview
E kenyelletsa Boemo ba Sehlopha sa CDC ACM ho Litlhophiso tsa Sesebediswa sa Hao Li-callbacks tsa Tsebiso ea Ketsahalo.
Ho theha Boemo ba Sehlopha sa CDC ACM
aa M aaa Crete CDC AC cl ss inst nce ka ho etsa mosebetsi sl_usbd_cdc_acm_create_instance() . T aaa M aaa mohlala o ka tlase o bonts'a mokhoa oa ho theha CDC AC cl ss inst nce vi sl_usbd_cdc_acm_create_instance() .
Example - Ho theha Mosebetsi oa CDC ACM ka sl_usbd_cdc_acm_create_instance()

uint8_t subclass_nbr; sl_status_t boemo;
boemo = 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);
haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}
E kenyelletsa Boemo ba Sehlopha sa CDC ACM ho Litlhophiso tsa Sesebediswa sa Hao
Ka mor'a hore u thehe mohlala oa sehlopha sa CDC ACM, u ka o kenya ho tlhophiso ka ho letsetsa mosebetsi
sl_usbd_cdc_acm_add_to_configuration() .
Mohlala o ka tlase o bonts'a mokhoa oa ho cll sl_usbd_cdc_acm_add_to_configuration() .
Example – Letsetsa ho USBD ACM sl_usbd_cdc_acm_add_to_configuration()

sl_status_t boemo;

boemo = sl_usbd_cdc_acm_add_to_configuration(subclass_nbr,

(1)

config_nbr_fs);

(2)

haeba (boemo! SL_STATUS_OK) {

/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */

}

aaa (1) Cl ss nomoro ho dd to tion tlhophiso e khutliselitsoeng ke sl_usbd_cdc_acm_create_instance() . (2) Nomoro ea tlhophiso (mona e e eketsa ho tlhophiso ea Full-Speed).
Ho Ngolisa Mehala ea Tsebiso ea Ketsahalo
Sehlopha sa CDC ACM Serial se ka tsebisa ts'ebeliso ea hau ka liphetoho life kapa life taolong ea mohala kapa khouto ka mesebetsi ea tsebiso. Sebopeho sa mesebetsi ea callback se ka fetisoa e le khang nakong ea tlhahiso ea mohlala ea ACM. Hlokomela hore li-callback tseo ke boikhethelo. Example - CDC ACM Callbacks Registration e bonts'a ts'ebeliso ea mesebetsi ea ngoliso ea callback. Example – CDC ACM Callbacks Implementation bontša e example ts'ebetsong ea mesebetsi ea callback.
Example – CDC ACM Callbacks Ngoliso

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

25/174

Fetileview

uint8_t subclass_nbr; sl_status_t boemo;
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_acm_control
boemo = 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_callbacknbr);
haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}
Example – CDC ACM Callbacks Kemplementation

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 parity_ncha;

uint8_t stop_bits_new;

uint8_t data_bits_new;

/* TODO Kenya line coding tse ncha.*/ 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;

khutla ('nete);

(1)

}

app e se nang letho_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;

/* TODO Sebelisa taolo e ncha ea mohala. */ rts_state = ((ketsahalo & SL_USBD_CDC_ACM_CTRL_RTS) ! 0) ? 'nete : bohata; rts_state_changed = ((event_changed & SL_USBD_CDC_ACM_CTRL_RTS) ! 0) ? 'nete : bohata; dtr_state = ((ketsahalo & SL_USBD_CDC_ACM_CTRL_DTR) ! 0) ? 'nete : bohata; dtr_state_changed = ((event_changed & SL_USBD_CDC_ACM_CTRL_DTR) ! 0) ? 'nete : bohata; brk_state = ((ketsahalo & SL_USBD_CDC_ACM_CTRL_BREAK) ! 0) ? 'nete : bohata; brk_state_changed = ((ketsahalo_changed & SL_USBD_CDC_ACM_CTRL_BREAK) ! 0) ? 'nete : bohata;
}

(1) Ho bohlokoa ho khutlisa phoso mosebetsing ona haeba khouto ea mohala e hlolehile. Ho seng joalo, khutlela 'nete.
Ho Buisana ka ho Sebelisa Sehlopha sa CDC ACM
Boemo ba serial
Line Coding Line Control

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

26/174

Fetileview

Line State Subclass Instance Communication
Boemo ba serial
Line Coding
Moamoheli oa USB o laola likhoutu tsa mohala (sekhahla sa baud, parity, joalo-joalo) ea sesebelisoa sa CDC ACM. Ha ho hlokahala, kopo e na le boikarabelo ba ho beha line coding. Ho na le mesebetsi e 'meli e fanoeng ho khutlisa le ho seta likhoutu tsa mohala oa hajoale, joalo ka ha ho hlalositsoe tafoleng e ka tlase.
Letlapa - CDC ACM Line Coding Functions

Mosebetsi
sl_usbd_cdc_acm_g e t_line _co d ing ()
sl_usbd_cdc_acm_s e t_line _co d ing ()

Tlhaloso
Sesebelisoa sa hau se ka fumana litlhophiso tsa hajoale tsa likhoutu tse behiloeng ho moamoheli ka likopo tsa SetLineCoding kapa ka tšebetso sl_usbd_cdc_acm_set_line_coding() .
Sesebelisoa sa hau se ka seta khouto ea mohala. Moamoheli a ka fumana litlhophiso ka kopo ea GetLineCoding.

Taolo ea Line
Moamoheli oa USB o laola taolo ea mohala (RTS le DTR pin, lets'oao la khefu, joalo-joalo) ea sesebelisoa sa CDC ACM. Ha ho hlokahala, kopo ea hau e na le boikarabello ba ho sebelisa li-line controls. Ho fanoe ka ts'ebetso ea ho khutlisa le ho seta litaolo tsa mela ea hajoale, joalo ka ha ho hlalositsoe tafoleng e ka tlase.
Letlapa - CDC ACM Line Control Functions

Mosebetsi
sl_usb d _cd c_acm_g e t_line _co ntr o l_state ()

Kopo ea hau e ka fumana boemo ba mohala oa taolo ea hajoale e behiloeng ke moamoheli ka kopo ea SetControlLineState.

Line State
Moamoheli oa USB o khutlisa boemo ba mohala ka nako e itseng. Kopo ea hau e tlameha ho ntlafatsa boemo ba mohala nako le nako ha e fetoha. Ha ho hlokahala, kopo ea hau e na le boikarabello ba ho beha boemo ba mohala. Ho fanoe ka mesebetsi e 'meli ea ho khutlisa le ho beha li-control tsa morao-rao tsa mela, joalo ka ha ho hlalositsoe tafoleng e ka tlase.
Letlapa - CDC ACM Line S tate Functions

Mosebetsi
sl_usb d _cd c_acm_se t _line _state _e ve nt()
sl_usbd_cdc_acm_cle ar_line _state _e ve nt()

Sesebelisoa sa hau se ka hlophisa ketsahalo efe kapa efe ea boemo ba mohala. Ha u ntse u hlophisa boemo ba mohala, ho fetisoa ha tšitiso ho IN ho romelloa ho moamoheli ho tsebisa ka eona phetoho ea boemo ba serial line.
Kopo e ka hlakola liketsahalo tse peli tsa boemo ba mohala: sepalangoang sa phetisetso le ho lemoha sejari sa moamoheli. Liketsahalo tse ling kaofela li itlhoekisa ke sehlopha sa ACM serial emulation subclass.

Subclass Instance Communication

Silicon Labs 'ACM subclass e fana ka mesebetsi e latelang ho buisana le moamoheli. Bakeng sa lintlha tse ling mabapi le liparamente tsa function9, bona CDC ACM Subclass Functions reference.

Lebitso la tshebetso
sl_usb d _cd c_acm_ papatso () sl_usb d _cd c_acm_write ()

Tshebetso
E fumana lintlha ho tsoa ho moamoheli ka bongata ba OUT endpoint. Mosebetsi ona oa thibela. E romella lintlha ho moamoheli ka bongata IN endpoint. Mosebetsi ona oa thibela.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

27/174

Fetileview

Tafole – CDC ACM Communication API Kakaretso aaaaa sl_usbd_cdc_acm_read() nd sl_usbd_cdc_acm_write() fana ka puisano e ts'oanang, eo ke e thibelang. Ka mantsoe a mang, ha o bitsa ts'ebetso, ts'ebeliso e thibela ho fihlela phetisetso e felile ka phoso kapa ntle le phoso. Nako ea nako e ka hlalosoa ho qoba ho ema ka ho sa feleng. Example ka tlase e bonts'a ex ea ho bala le ho ngolaample e amohelang data ho tsoa ho moamoheli a sebelisa boholo ba OUT endpoint mme e romella data ho moamoheli a sebelisa bongata IN endpoint.
Lenane - Serial Bala 'me Ngola Example

__ALIGNED(4) uint8_t rx_buf[2];

__ALIGNED(4) uint8_t tx_buf[2];

uint32_t

xfer_len;

sl_status_t

boemo;

boemo = sl_usbd_cdc_acm_read(subclass_nbr,

(1)

rx_buf,

(2)

2u,

0u,

(3)

&xfer_len);

haeba (boemo! SL_STATUS_OK) {

/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */

}

boemo = sl_usbd_cdc_acm_write(subclass_nbr,

(1)

tx_buf,

(4)

2u,

0u,

(3)

&xfer_len);

haeba (boemo! SL_STATUS_OK) {

/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */

}

T aaaaa M (1) he cl ss inst nce number cre ted with sl_usbd_cdc_acm_create_instance() e fana ka ntšupiso ea intern l ho sehlopha sa AC ho tsamaisa phetiso ho ea bongata bo nepahetseng OUT kapa IN endpoint. (2) Kopo ea hau e tlameha ho netefatsa hore buffer e fanoeng ts'ebetsong e kholo ho lekana ho amohela lintlha tsohle. Ho seng joalo, mathata a khokahano a ka etsahala. (3) Ho qoba boemo bo sa feleng ba ho thibela, bolela nako ea ho qeta nako e hlalositsoeng ka milliseconds. Boleng ba 809 bo etsa hore mosebetsi oa kopo o eme ka ho sa feleng. (4) Sesebelisoa se fana ka buffer e qalileng ea ho fetisa.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

28/174

Fetileview
Fetileview

Sesebediswa sa USB HID Sehlopha

Sesebediswa sa USB HID Sehlopha Fedileview Sesebediswa sa USB HID Sehlopha sa Mohloli o Hlokahalang ho tswa ho Core Sesebediswa sa USB HID Sehlopha sa Tlhophiso Sesebediswa sa USB HID Sehlopha sa Tataiso ya Mananeo a HID Mosebetsi wa Ditlaleho tsa Nako le Nako
Karolo ena e hlalosa sehlopha sa Human Interface Device (HID) se tšehetsoang ke Silicon Labs USB Device.
Sehlopha sa HID se akaretsa lisebelisoa tse sebelisoang ke batho ho laola ts'ebetso ea likhomphutha, joalo ka likonopo, litoeba, lisebelisoa tse supang, le lisebelisoa tsa papali.
Sehlopha sa HID se ka boela sa sebelisoa sesebelisoa se kopantsoeng se nang le li-control tse kang likonopo, li-switches, likonopo le li-slider. Bakeng sa mohlalaample, limumu le litaolo tsa molumo semameding sa molumo li laoloa ke tšebetso ea HID ea semamedi. Sehlopha sa HID se ka fapanyetsana data ka sepheo sefe kapa sefe se sebelisa taolo feela le ho sitisa phetisetso.
Sehlopha sa HID ke se seng sa litlelase tsa khale ka ho fetisisa tsa USB tse sebelisoang haholo. Litsamaiso tsohle tse kholo tsa ts'ebetso ea moamoheli li fana ka mokhanni oa matsoalloa ho laola lisebelisoa tsa HID, ke ka lebaka leo mefuta e fapaneng ea lisebelisoa tse khethehileng tsa barekisi li sebetsang le sehlopha sa HID. Sehlopha sena se boetse se kenyelletsa mefuta e fapaneng ea lintho tse hlahisoang joalo ka li-LED, molumo, maikutlo a tactile, jj.
Ts'ebetsong ea HID e lumellana le lintlha tse latelang:
Tlhaloso ea Sehlopha sa Sesebelisoa bakeng sa Lisebelisoa tsa Interface ea Batho (HID), 6/27/01, Version 1.11. Litafole tsa Tšebeliso ea Universal Serial Bus HID, 10/28/2004, Version 1.12.
Sesebediswa sa USB HID Sehlopha Fedileview
Fetileview
Sesebelisoa sa HID se entsoe ka lintlha tse latelang:
Litaolo tse peli tsa IN le OUT tse bitsoang "default endpoint" "In interrupt IN endpoint" (E-interrupt IN endpoint)
Tafole e ka tlase e hlalosa tšebeliso ea liphetho tse fapaneng:
Tafole - Tšebeliso ea lintlha tsa ho qetela tsa sehlopha sa HID

Tšebeliso ea tataiso ea ho qetela

Laola IN
Taolo
TSOA
Thibela IN
Thibela
TSOA

Sesebediswa-moamoheli
Host-todevice
Sesebediswa-moamoheli
Host-todevice

Likopo tse tloaelehileng tsa ho baloa, likopo tse ikhethileng tsa sehlopha, le likhokahano tsa data (Kenyeletso, Litlaleho tsa likarolo li rometsoe ho moamoheli ka kopo ea GET_REPORT). Likopo tse tloaelehileng tsa ho baloa, likopo tse ikhethileng tsa sehlopha le likhokahano tsa data (Sephetho, Litlaleho tse amohetsoeng ho tsoa ho moamoheli ka kopo ea SET_REPORT). Puisano ea data (Litlaleho tsa Maiketsetso le Likarolo).
Puisano ea data (Litlaleho tsa Output le Feature).

Tlaleho

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

29/174

Fetileview

Moamoheli le sesebelisoa sa HID ba fapanyetsana lintlha ba sebelisa litlaleho. Tlaleho e na le data e hlophisitsoeng e fanang ka leseli mabapi le litaolo le likarolo tse ling tsa sesebelisoa sa HID. Taolo e ka sebelisoa ke mosebelisi mme e sebetsa karolo e 'ngoe ea sesebelisoa. Bakeng sa mohlalaample, taolo e ka ba konopo ea mouse kapa keyboard, switch, joalo-joalo. Mekhatlo e meng e tsebisa mosebedisi ka boemo ba lisebelisoa tse itseng. Bakeng sa mohlalaample, li-LED tse holim'a keyboard li tsebisa mosebelisi ka senotlolo sa senotlolo, konopo ea linomoro e sebetsa, jj.
Sebopeho le ts'ebeliso ea data ea tlaleho li utloisisoa ke moamoheli ka ho sekaseka litaba tsa tlhaloso ea Tlaleho. Tlhahlobo ea litaba e etsoa ke mohlahlobisisi. Tlhaloso ea Tlaleho e hlalosa lintlha tse fanoeng ke taolo e 'ngoe le e' ngoe sesebelisoa. E entsoe ka lintho tseo e leng likotoana tsa tlhahisoleseling mabapi le sesebelisoa mme e na le sehlohlolo sa 1-byte le bolelele bo fapaneng.
data. Bakeng sa lintlha tse ling mabapi le sebopeho sa ntho, sheba ho
1.11=, karolo ea 5.6 le 6.2.2.
Ho na le mefuta e meraro ea mantlha ea lintho:
Ntho e ka sehloohong e hlalosa kapa e kopanya mefuta e meng ea libaka tsa data.
Ntho ea lefats'e e hlalosa litšobotsi tsa data tsa taolo.
Ntho ea lehae e hlalosa litšobotsi tsa data tsa taolo.
Mofuta o mong le o mong oa ntho o hlalosoa ka mesebetsi e fapaneng. Mosebetsi oa ntho e ka boela ea bitsoa a tag. Ts'ebetso ea ntho e ka bonoa e le karoloana eo e leng ea e 'ngoe ea mefuta e meraro ea mantlha. Tafole e ka tlase e fana ka tlhaloso e khutšoanyaneview ea mesebetsi ea ntho9 mofuteng ka mong oa ntho. Bakeng sa tlhaloso e felletseng ea lintho tse sehlopheng ka seng, bona
Lethathamo - Tlhaloso ea Mosebetsi oa Ntho bakeng sa Mofuta o mong le o mong oa Ntho

Mosebetsi oa Mofuta oa Ntho

Tlhaloso

Kenyo e ka Sehloohong

E hlalosa lintlha tse mabapi le data e fanoeng ke taolo e le 'ngoe kapa ho feta.

Main Output E hlalosa data e rometsoeng sesebelisoa.

Karolo e ka Sehloohong

E hlalosa lintlha tsa tlhophiso ea sesebelisoa tse rometsoeng kapa tse amohetsoeng ho tsoa sesebelisoa tse susumetsang boitšoaro ka kakaretso ba sesebelisoa kapa e 'ngoe ea likarolo tsa sona.

Lintho tse amanang le Sehlopha sa Pokello e ka Sehloohong (Se Kenyellelitsoeng, Se hlahisoang kapa Sebopeho).

Qetello e ka Sehloohong ea ho Koala pokello. Pokello

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

30/174

Fetileview

Mosebetsi oa Mofuta oa Ntho

Tlhaloso

Leqephe la Tšebeliso ea Lefatše

E hlwaya tshebetso e fumanehang ka hara sesebediswa.

Global Logical E hlalosa moeli o tlase oa boleng bo tlalehiloeng ka likarolo tse utloahalang. Bonyane

Global Logical E hlalosa moeli o ka holimo oa boleng bo tlalehiloeng ka likarolo tse utloahalang. Boholo

Global Physical E hlalosa moedi o tlase wa boleng bo tlalehiloeng ho diyuniti tsa mmele, e leng Logical Minimum Minimum e hlahiswang ka diyuniti tsa mmele.

Global Physical E hlalosa moedi o ka hodimo wa boleng bo tlalehiloeng ho diyuniti tsa mmele, ke hore Logical Maximum Maximum e hlahiswang ka diyuniti tsa mmele.

Global Unit

E bontša yuniti exponent motheong oa 10. Exponent e tloha ho -8 ho ea ho +7.

Exponent

Global Unit

E bonts'a karolo ea boleng bo tlalehiloeng. Mohlala, bolelele, boima, likarolo tsa mocheso, joalo-joalo.

Boholo ba Tlaleho ea Lefatše

E bontša boholo ba likarolo tsa tlaleho ka likotoana.

Global Report ID E bontša sehlomathiso se kenyellelitsoeng tlalehong e itseng.

Palo ea Tlaleho ea Lefatše

E bontša palo ea libaka tsa data bakeng sa ntho e itseng.

Global Push

E beha kopi ea tafole ea boemo ba ntho ea lefats'e ho "CPU" stack.

Global Pop

E fetola tafole ea boemo ba ntho ka sebopeho sa ho qetela sa stack.

Tšebeliso ea Sebakeng

E emela index ea ho hlahisa Tšebeliso e itseng ka har'a Leqephe la Tšebeliso. E supa tšebeliso e khothaletsoang ke barekisi9 bakeng sa taolo e itseng kapa sehlopha sa taolo. Ts'ebeliso e fana ka leseli ho moetsi oa sesebelisoa mabapi le hore na taolo e lekanya eng.

Tšebeliso ea Sebakeng

E hlalosa ts'ebeliso ea ho qala e amanang le array kapa bitmap.

Bonyane

Tšebeliso ea Sebakeng

E hlalosa ts'ebeliso ea pheletso e amanang le array kapa bitmap.

Boholo

Moqapi oa Sebaka O khetha karolo ea 'mele e sebelisoang ho laola. Index e supa moqapi ho Physical

Index

mohlalosi.

Moqapi oa Lehae O hlalosa index ea moqapi ea qalang e amanang le array kapa bitmap. Bonyane

Moqapi oa Sebaka o Hlalosa index ea moqapi oa pheletso e amanang le array kapa bitmap. Boholo

Index ea Likhoele Tsa Sebaka

Lenane la likhoele bakeng sa tlhaloso ea Khoele. E lumella khoele ho amahanngoa le ntho e itseng kapa taolo.

Mohala oa Sebaka

E totobatsa index ea pele ea likhoele ha e abela sehlopha sa likhoele tse latellanang ho li laola ka lethathamo

Bonyane kapa bitmap.

Local Local

Khoele Maximum
Delimiter

E hlakisa index ea lithapo tsa ho qetela ha e abela sehlopha sa likhoele tse latellanang ho li laola ka sehlopha kapa bitmap.
E hlalosa qalo kapa pheletso ea sehlopha sa lintho tsa lehae.

Lintlha tsa control9 li tlameha ho hlalosa bonyane lintho tse latelang:
Kenyeletso, Se hlahisoang kapa Sebopeho Lintho tse ka sehloohong Tšebeliso ea Ntho ea lehae Tšebeliso Leqephe la Global Tee e utloahalang Bonyane Bonyane ntho e utloahalang ea Global Teeme ea Lefatše Report Boholo

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

31/174

Fetileview
Report Count Global Tafole e ka tlase e bonts'a kemelo ea litaba tse hlalosang Tlaleho ea Mouse ho tsoa ho motho ea amohelang HID. Toeba e na le likonopo tse tharo (ka ho le letšehali, ho le letona le lebili). Khoutu e hlahisitsoeng ho exampLe ka tlase ke ts'ebetsong ea khoutu e tsamaellanang le toeba ena e hlalosang boemeli ba tlhaloso.
Setšoantšo - Tlaleho ea Descriptor Content ho tsoa ho Host HID Parser View

(1) Ts'ebetso ea ntho ea Leqephe la Tšebeliso e bolela mosebetsi o akaretsang oa sesebelisoa. Ho sena mohlalaample, sesebelisoa sa HID ke sa a
taolo ea komporo ea generic.
(2) Lihlopha tsa Kopo ea Pokello Lintho tse ka sehloohong tse nang le morero o tšoanang 'me li ka ba tse tloaelehileng ho likopo. Setšoantšong, sehlopha se entsoe ka lintho tse tharo tsa Input Main. Bakeng sa pokello ena, ts'ebeliso e khothaletsoang bakeng sa litsamaiso ke toeba joalo ka ha ho bonts'itsoe ke ntho ea Tšebeliso. (3) Lipokello tse bolokiloeng li ka sebelisoa ho fana ka lintlha tse eketsehileng mabapi le tšebeliso ea taolo e le 'ngoe kapa sehlopha sa taolo lits'ebetsong. Ho sena mohlalaample, Pokello ea 'mele, e kentsoeng ka har'a Kopo ea Pokello, e entsoe ka lintho tse tharo tse Kenyellelitsoeng tse etsang Kopo ea Pokello. Pokello Physical e sebelisoa bakeng sa sete ea lintlha tsa data tse emelang lintlha tsa data tse bokelletsoeng sebakeng se le seng sa geometri. Ka mohlalaample, ts'ebeliso e sisintsoeng ke pointer joalo ka ha ho bonts'itsoe ke ntho ea Tšebeliso. Mona ts'ebeliso ea pointer e bua ka lihokela tsa boemo ba toeba mme software ea sistimi e tla fetolela likhokahano tsa toeba ha li ntse li tsamaea ka sesupo sa skrine. (4) Maqephe a ts'ebeliso ea Nested a ka khoneha hape 'me a fana ka lintlha tse ling mabapi le karolo e itseng ka har'a ts'ebetso e akaretsang ea sesebelisoa. Tabeng ena, lintho tse peli tsa Inputs li arotsoe ka lihlopha 'me li lumellana le likonopo tsa mouse. Ntho e le 'ngoe ea Kenyeletso e hlalosa likonopo tse tharo tsa toeba (ka ho le letona, ka ho le letšehali le lebili) ho latela palo ea libaka tsa data bakeng sa ntho eo (Athethe ea Palo ea Tlaleho), boholo ba sebaka sa data (Report Size item) le boleng bo ka bang teng bakeng sa sebaka ka seng sa data (Bonyane ba Tšebeliso le Boholo, Lintho tse fokolang tse utloahalang le tse phahameng). Ntho e 'ngoe ea Kenyeletso ke 13-bit e sa fetoheng e lumellang data ea Tlaleho ea Kenyeletso hore e tsamaellane le moeli oa li-byte. Ntho ena e Kentsweng e sebediswa feela molemong wa ho phuthela. (5) Leqephe le leng la ts'ebeliso ea sehlaha le buang ka taolo ea komporo ea generic le hlalositsoe bakeng sa lihokela tsa maemo a toeba. Bakeng sa leqephe lena la tšebeliso, ntho ea Input e hlalosa likarolo tsa data tse tsamaellanang le x- le y-axis joalo ka ha ho hlalositsoe ke Ts'ebeliso e 'meli.
lintho.
Kamora ho hlahlobisisa litaba tse hlalosang panya e fetileng, mohlahlobi oa HID oa host9 o khona ho toloka data ea Input Report e rometsoeng ke sesebelisoa ka phetiso e sitisang IN kapa ka ho arabela kopo ea GET_REPORT. Lintlha tsa tlaleho ea Input tse tsamaellanang le tlhaloso ea toeba ea Tlaleho e bontšitsoeng Figure - Report Descriptor Content ho tsoa ho Host HID Parser. View is

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

32/174

Fetileview

e bontšitsoeng tafoleng e ka tlase. Kakaretso ea boholo ba data ea tlaleho ke li-byte tse 4. Mefuta e fapaneng ea litlaleho e ka romelloa sebakeng se le seng. Bakeng sa ho khetholla mefuta e fapaneng ea litlaleho, ho kenyeletsoa sehlomathiso sa ID sa tlaleho ea 1-byte tlalehong ea data. Haeba ID ea tlaleho e ne e sebelisoa ho exampka tlaleho ea mouse, boholo ba kakaretso ea data ea tlaleho e ka ba li-byte tse 5.
Lethathamo - Tlaleho ea Kenyelletso E Rometsoe ho Moamoheli 'me e Lumellana le Boemo ba Toeba ea Likonopo tse 3

Bit Offset
0 1 2 3 16 24

Palo e nyane 1 1 1 13 8 8

Tlhaloso Konopo ea 1 (konopo e ka ho le letšehali). Konopo 2 (konopo e nepahetseng). Konopo ea 3 (konopo ea mabili). Ha e sebelisoe. Boemo ho axis X. Boemo ho axis Y.

Tlhaloso ea 'mele e supa karolo kapa likarolo tsa' mele tse reretsoeng ho kenya taolo kapa taolo. Sesebelisoa se ka sebelisa lintlha tsena ho abela tšebetso taolong ea sesebelisoa. Tlhaloso ea 'mele ke tlhaloso e ikhethileng ea sehlopha' me lisebelisoa tse ngata li na le phaello e fokolang ea ho e sebelisa. Sheba
Sesebediswa sa USB HID Class Resource Litlhoko tse tsoang ho Core

Nako le nako ha u eketsa mohlala oa sehlopha sa HID ho tlhophiso ea USB ka mohala ho ts'ebetso sl_usbd_hid_add_to_configuration() , lisebelisoa tse latelang li tla abeloa ho tloha mantlha.

Mohlodi
Li-interfaces Mefuta e meng ea lihokelo Lihlopha tsa Endpoints Interface

Bongata
1 1 1 (2 haeba sebaka sa ho sitisa OUT se lumelletsoe) 0

Hlokomela hore linomoro tseo ke tsa tlhophiso. Ha o theha SL_USBD_INTERFACE_QUANTITY , SL_USBD_ALT_INTERFACE_QUANTITY , SL_USBD_INTERFACE_GROUP_QUANTITY le SL_USBD_DESCRIPTOR_QUANTITY litekanyetso tsa lipeakanyo, u seke oa lebala ho ela hloko hore na ke litlhophiso tse kae tse tla eketsoa. Bakeng sa boleng ba tlhophiso ea SL_USBD_OPEN_ENDPOINTS_QUANTITY, kaha li-endpoints li buloa feela ha tlhophiso e behiloe ke moamoheli, o hloka feela ho ela hloko palo ea lintlha tse hlokahalang bakeng sa mohlala oa sehlopha.
Sesebediswa sa USB HID Class Configuration

Ho sebelisoa lihlopha tse peli tsa paramente ea tlhophiso ho hlophisa sehlopha sa HID:
Sesebediswa sa USB sa HID Sehlopha sa Ts'ebeliso-Litlhophiso tse Khethehileng Sesebediswa sa USB sa HID Class Maemo a Maemo
Sesebediswa sa USB sa HID Class Kopo-Litlhophiso tse Ipehileng

Taba ea pele, ho sebelisa module ea sehlopha sa HID ea sesebelisoa sa Silicon Labs, fetola sebopeho sa nako ea HID se hlalosang ho latela litlhoko tsa kopo ea hau. Li kopantsoe hape ka har'a sehlooho sa sl_usbd_core_config.h file tlas'a karolo ea HID. Li ka aroloa ka likarolo tse peli, tlhophiso ea bongata le tlhophiso ea mesebetsi ea HID. Morero oa tlhophiso ea bongata ke ho tsebisa mojule oa sesebelisoa sa USB mabapi le hore na o ka abela lintho tse kae tsa USB HID.
Tafole e ka tlase e hlalosa mofuta o mong le o mong oa tlhophiso.
Tafole - Sesebediswa sa USB HID Configuration e Hlalosa

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

33/174

Fetileview

Lebitso la Tlhophiso
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

Tlhaloso
Palo ea maemo a phaposi eo u tla e abela ka mohala ho tšebetso
sl_usbd_hid_create_instance() .
Palo ea litlhophiso. Maemo a sehlopha sa HID a ka eketsoa ho tlhophiso e le 'ngoe kapa tse ngata tsa aaaa vi c ll ho ts'ebetso sl_usbd_hid_add_to_configuration() . E lokisa kakaretso ea li-ID tsa tlaleho tse tla ajoa.
E lokisa palo yohle ya dintho tsa Push/Pop ho abela batho.
Mosebetsi oa nako o sebetsana le ts'ebetso eohle ea HID e thehiloeng ho nako. Tlhophiso ena e u lumella ho beha boholo ba stack (ka palo ea li-byte). Ntho ea pele ea mosebetsi oa HID. hae ke ntho e tlang pele ho CMSIS-RTOS2.

Boleng ba kamehla
2 1 2 0 2048
osPriorityHigh

Sesebediswa sa USB HID Class Instance Configurations Class Instance Creation subclass
protocol country_code
interval_in and interval_out p_hid_callback HID Class Report Descriptor ExampLe Karolo ena e hlalosa litlhophiso tse amanang le maemo a sehlopha sa HID.
Pōpo ea Boemo ba Sehlopha
Ho theha mohlala oa sehlopha sa HID ho etsoa ka ho bitsa mosebetsi aaa sl_usbd_hid_create_instance() , e leng ho felisang likhang tsa ho lokisa tse hlalositsoeng ka tlase.
sehlopha se senyane
Khoutu ea sehlopha sa HID. Maemo a ka bang teng ke:
SL_USBD_HID_SUBCL ASS_NONE SL_USBD_HID_SUBCL ASS_BOOT
Sesebelisoa sa HID se sebelisang boot subclass se tlameha ho sebelisa lifomate tse tloaelehileng tsa tlaleho. Bakeng sa tlhaiso-leseling e batsi mabapi le likhoutu tsa subclass, bona karolo ea 4.2 ea HID specification revision 1.11.
protocol
Protocol e sebelisoang ke sesebelisoa sa HID. Maemo a ka bang teng ke:
SL_USBD_HID_PROTOCOL_NONE SL_USBD_HID_PROTOCOL_KBD SL_USBD_HID_PROTOCOL_MOUSE
Haeba ts'ebetso ea HID ea hau e le toeba, protocol e lokela ho hlophisoa ho aa SL_USBD_HID_PROTOCOL_MOUSE . Haeba e le keybo rd, e lokela ho hlongoa ho SL_USBD_HID_PROTOCOL_KBD . ka hona, protocol e lokela ho hlophisoa ho SL_USBD_HID_PROTOCOL_NONE . Bakeng sa tlhaiso-leseling e batsi mabapi le likhoutu tsa sehlopha se tlase, bona karolo ea 4.3 ea tlhahlobo ea litlhaloso tsa HID 1.11.
naha_khoutu
ID ea khoutu ea naha. Maemo a ka bang teng ke:
SL_USBD_HID_COUNTRY_CODE_NOT_SUPPORTED

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

34/174

Fetileview
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_CZE_CZE 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_BREEK 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_ICAL_ACODE_KOREAN 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 LE SL_USBD_HID_COUNTRY_CODE_SLDRUDRY_CODERUS_USB_CODE 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_CODE_SWISS_GERMAN_CODE_SWISS_GERMAN_ 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_IRKD_CODE_HID
Khouto ea naha e supa hore na hardware e behiloe sebakeng sa naha efe. Lisebelisoa tse ngata ha li sebakeng sa heno, kahoo aaaav lue ena e ka ba SL_USBD_HID_COUNTRY_CODE_NOT_SUPPORTED (0). Leha ho le joalo, keybo e re ke sebelise tšimo ho bontša puo ea linotlolo tsa linotlolo.
Bakeng sa tlhaiso-leseling e batsi ka likhoutu tsa naha, sheba karolo ea 6.2.1 ea tlhahlobo ea lintlha tsa HID 1.11.
interval_in le interval_out
interval_in and interval_out li emela nako ea likhetho ea IN interval endpoint le OUT interval endpoint.
Sena se emela nako ea likhetho ea sebaka sa ho qetela, ka milliseconds. Ho beha boleng bona ho ipapisitse le hore na sesebelisoa sa hau se kotsing e kae ho hlahisa tlaleho e ncha bakeng sa moamoheli. Mohlala, haeba tlaleho e hlahisoa ka li-milliseconds tse ling le tse ling tse 16, nako e lokela ho ba 16 kapa ka tlase ho moo.
Boleng bo tlameha ho ba matla a 2 (1, 2, 4, 8, 16, joalo-joalo).
a interval_out v lue e hlokomolohuoa haeba ctrl_rd_en e behiloe ho 'nete.
p_hid_callback
aaaa p_hid_callback ke sesupo sa sebopeho sa mofuta sl_usbd_hid_callbacks_t . Sepheo sa eona ke ho fa HID Cl ss sete ea mesebetsi ea callback e tla bitsoa ha ketsahalo ea HID e etsahala.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

35/174

Fetileview

Ha se li-callback tsohle tse tlamang 'me null pointer (NULL) e ka fetisoa ka mokhoa o fapaneng oa sebopeho sa callback ha callback e sa hlokahale. Tafole e ka tlase e hlalosa sebaka se seng le se seng sa tlhophiso se fumanehang sebopehong sena sa tlhophiso.
Tafole – sl_usbd_hid_callbacks_t Sebopeho sa Tlhophiso

Masimo

Tlhaloso

Mosebetsi Tshaeno

.enable .disable .get_report_desc
.get_phy_desc
.set_output_report .get_feature_report .set_feature_report

E bitsoa ha mohlala oa sehlopha sa USB o buletsoe ka katleho. E bitsoa ha mohlala oa sehlopha sa USB o koetsoe.
E letsetsoa nakong ea tlhahiso ea HID Instance ho fetisa tlhaloso ea tlaleho ea hau. Ho e 'ngoe le e 'ngoe ea mesebetsi ea hau ea HID, u tlameha ho fana ka tlhaloso ea tlaleho. Tlhaloso ea tlaleho e bontša moamoheli hore na tlaleho ea nako le nako e tla romelloa ke sesebelisoa e lokela ho aroloa joang. Ho ngola tlhaloso ea tlaleho ea hau ho ka ba thata, ke ka lebaka leo ho nang le lisebelisoa tse ka u thusang. Ena ke eona feela tšebetso e tlamang ea ho letsa. E bitsoa nakong ea popo ea HID Instance ho fetisa tlhaloso ea hau ea 'mele. Tlhaloso ea 'mele ke tlhaloso e fanang ka tlhahisoleseding mabapi le karolo e itseng kapa likarolo tsa' mele oa motho tse kenyang taolo kapa taolo. Bakeng sa tlhaiso-leseling e batsi ka litlhaloso tsa 'mele, sheba karolo ea 6.2.3 ea tlhahlobo ea litlhaloso tsa HID 1.11. Tlhaloso ea 'mele ke khetho' me boholo ba nako e hlokomolohuoa. Buffer e fetisitsoeng mona e ka hlophisoa ho NULL 'me bolelele bo behiloe ho 0. E bitsoa ha moamoheli a beha tlaleho joalo ka ha ho hlalositsoe ho tlhaloso ea tlaleho ea hau (ha e romela tlaleho).
E bitsoa ha moamoheli a kopa tlaleho ea tšebetso joalo ka ha e hlalositsoe ho tlhaloso ea tlaleho ea hau.
E bitsoa ha moamoheli a seta tlaleho ea likarolo joalo ka ha e hlalositsoe ho tlhaloso ea tlaleho ea hau.

void app_usbd_hid_enable(uint8_t class_nbr); sesebelisoa sa lefeela_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);
app e se nang thuso_usbd_hid_set_output_report(uint8_t class_nbr, uint8_t report_id, uint8_t *p_report_buf, uint16_t report_len); app e se nang thuso_usbd_hid_get_feature_report(uint8_t class_nbr, uint8_t report_id, uint8_t *p_report_buf, uint16_t report_len); app e se nang thuso_usbd_hid_set_feature_report(uint8_t class_nbr, uint8_t report_id, uint8_t *p_report_buf, uint16_t report_len);

.fumana_protocol

E khutlisa protocol e sebetsang ea hajoale.

app e se nang thuso_usbd_hid_get_protocol(uint8_t class_nbr, uint8_t *p_protocol);

.set_protocol

E beha protocol e sebetsang ea hajoale.

void app_usbd_hid_set_protocol(uint8_t class_nbr, uint8_t protocol);

HID Class Report Descriptor Example

Sehlopha sa HID sa Silicon Labs sample kopo e fana ka example ea tlhaloso ea tlaleho bakeng sa toeba e bonolo. ExampLe ka tlase e bontša tlhaloso ea tlaleho ea mouse.
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)

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

36/174

Fetileview

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_ENDCOLLECTION,(10)

SL_USBD_HID_MAIN_ENDCOLLECTION

(11)};

(1) Tafole e emelang tlhaloso ea tlaleho ea mouse e qalisoa ka tsela eo mola o mong le o mong o lumellanang le ntho e khutšoanyane. Ea ho qetela e entsoe ho tloha ho sehlohlolong sa 1-byte le data ea 1-byte. Sheba viewe hlophisitsoeng ke mohlahlobi oa HID ea amohelang Sets'oants'o - Tlaleho ea Descriptor Content ho tsoa ho Host HID Parser View.
(2) Leqephe la Tšebeliso ea Li-Desktop tse Tloaelehileng le sebelisoa.
(3) Ka har'a Leqephe la Tšebeliso ea Desktop e Tloaelehileng, ts'ebeliso tag e fana ka maikutlo a hore sehlopha sa taolo ke sa ho laola toeba. Pokello ea litoeba hangata e na le lilepe tse peli (X le Y) le likonopo tse le 'ngoe, tse peli kapa tse tharo.
(4) Pokello ea litoeba e qalile.
(5) Ka har'a pokello ea litoeba, tšebeliso tag e fana ka maikutlo a hore li-taolo tsa mouse ke tsa pokello ea lisupa. Pokello ea li-pointer ke pokello ea lilepe tse hlahisang boleng ba ho tsamaisa, ho bonts'a, kapa ho supa sepheo sa mosebelisi ho kopo.
(6) Pokello ea litsupa e qalile.
(7) Leqephe la Tšebeliso ea Likonopo le hlalosa ntho e Kenyelelitsoeng e entsoeng ka likarolo tse tharo tsa 1-bit. Sebaka se seng le se seng sa 1-bit se emela konopo ea mouse9s 1, 2 le 3 ka ho latellana 'me e ka khutlisa boleng ba 0 kapa 1.
(8) Ntho e Kenyelelitsoeng bakeng sa Leqephe la Tšebeliso ea Likonopo e kentsoe ka likotoana tse ling tse 13.
9
(10) Pokello ea litsupa e koetsoe.
(11) Pokello ea litoeba e koetsoe.
USB.org Leqephe le HID

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

37/174

Fetileview
Seboka sa Basebelisi ba USB (USB-IF) se fana ka sesebelisoa se bitsoang "HID Descriptor Tool" hammoho le lintlha tse ling mabapi le sebopeho sa tlhaloso ea tlaleho. Shebahttp://www.usb.org/developers/hidpage/ bakeng sa tlhahisoleseding e eketsehileng.
Sesebediswa sa USB HID Class Programming Guide
Karolo ena e hlalosa mokhoa oa ho sebelisa sehlopha sa HID. Ho qala Sehlopha sa HID sa Sesebediswa sa USB Ho Kenya Sesebediswa sa USB HID Class Boemo ho Sesebediswa sa hao Ho Buisana le Sesebediswa sa USB HID Class
Ho qala Sesebediswa sa USB HID Sehlopha
Ho eketsa ts'ebetso ea HID Class sesebelisoa sa hau, o tlameha ho qala sehlopha ka ho letsetsa tšebetso sl_usbd_hid_init() . ExampLe ka tlase e bonts'a mokhoa oa ho letsetsa sl_usbd_hid_init() ho sebelisa likhang tsa kamehla. Ho fumana lintlha tse ling mabapi le likhang tsa tlhophiso tse lokelang ho fetisetsoa ho sl_usbd_hid_init() , sheba Litlhophiso tse Tobileng tsa Sesebediswa sa USB sa HID .
Example – Ho letsetsa sl_usbd_hid_init()
sl_status_t boemo;
boemo = sl_usbd_hid_init(); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}
Ho eketsa Sesebediswa sa USB HID Class Instance ho Sesebediswa sa Hao
Ho kenya ts'ebetso ea sehlopha sa HID sesebelisoa sa hau, o tlameha ho theha mohlala, ebe o o kenya ho litlhophiso tsa sesebelisoa sa hau.
Ho theha Boemo ba Sehlopha sa HID
Etsa mohlala oa sehlopha sa HID ka ho bitsa mosebetsi sl_usbd_hid_create_instance() . ExampLe ka tlase e bonts'a mokhoa oa ho theha ts'ebetso e bonolo ea toeba ka sl_usbd_hid_create_instance() u sebelisa likhang tsa kamehla. Ho fumana lintlha tse ling mabapi le likhang tsa tlhophiso tse lokelang ho fetisetsoa ho sl_usbd_hid_create_instance() , bona Litlhophiso tsa Boemo ba Sesebediswa sa USB HID Class .
Example - Ho eketsa Mosebetsi oa Mouse ka sl_usbd_hid_create_instance()

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

38/174

Fetileview
/* Liphetoho tsa lefats'e. */ 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_COLLE 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_CP_POINTER, SL_USBD_HID_MAIN_COLLECTION + 1, SL_USBD_HID_COLLECTION_PHYSICAL, SL_USBD_USD_HID_HID 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, 0DLOG_USB_0000USB, 0 SLG_000 USB 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_GLOBAL_REPORT_SIZE + 1, 0 0D, SL_USBD_HID_MAIN_INPUT + 1, SL_USBD_HID_GLOBAL_REPORT_SIZE 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_USD_USAGE + 1, SL_USBD_HID_DV_X, SL_USBD_HID_LOCAL_USD_USB 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 _2, 0 COUNT_REPORT_2, 0 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};
/* Mefuta e fapaneng ea lehae.*/ uint8_t class_nbr; sl_status_t boemo;
sl_usbd_hid_callbacks_t app_usbd_hid_callbacks = { NULL, NULL, app_usbd_hid_get_report_desc, NULL, NULL, NULL, NULL, NULL, NULL };
app e se nang thuso_usbd_hid_get_report_desc(uint8_t class_nbr, const uint8_t **p_report_ptr, uint16_t *p_report_len)
{(feela)class_nbr;
*p_report_ptr = app_usbd_hid_mouse_report_desc; *p_report_len = sizeof(app_usbd_hid_mouse_report_desc); }
boemo = 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(Desc_USB_ReportDesc),Report_USB_USB 'nete, &app_usbd_hid_callbacks, &class_nbr);
Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

39/174

Fetileview
/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}
Ho kenyelletsa Boemo ba Sehlopha sa HID ho Litlhophiso tsa Sesebediswa sa Hao Kamora hore o thehe mohlala oa sehlopha sa HID, o ka o kenyelletsa ho tlhophiso ka ho letsetsa ts'ebetso.
sl_usbd_hid_add_to_configuration() .
ExampLe ka tlase e bonts'a mokhoa oa ho letsetsa sl_usbd_hid_add_to_configuration() .
Example - Ho letsetsa sl_usbd_hid_add_to_configuration()

sl_status_t boemo;

sl_usbd_hid_add_to_configuration(class_nbr,

(1)

config_nbr_fs); (2)

haeba (boemo! SL_STATUS_OK) {

/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */

}

(1) Nomoro ea sehlopha eo u ka e kenyang ho tlhophiso e khutlisitsoeng ke sl_usbd_hid_create_instance(). (2) Nomoro ea tlhophiso (mona e e eketsa ho tlhophiso ea Full-Speed).
Ho Buisana ka ho Sebelisa Sesebediswa sa USB HID Sehlopha
Class Instance Communication Synchronous Communication Class Instance Communication Sehlopha sa HID se fana ka mesebetsi e latelang ho buisana le moamoheli.
Letlapa - Kakaretso ea HID Communication API

Lebitso la tshebetso
sl_usb d _hid _ re ad _sy nc() sl_usb d _hid _write _sy nc()

Ts'ebetso e Fumana data ho tsoa ho moamoheli ka ho sitisa pheletso ea OUT. Mosebetsi ona oa thibela. E romela lintlha ho moamoheli ka tšitiso IN endpoint. Mosebetsi ona oa thibela.

Puisano ya Synchronous Puisano ya kamahanyo e bolela hore phetiso e a thiba. Ha o letsetsoa, ​​lits'ebetso lia thibela ho fihlela phetiso e phetheloa ka phoso kapa ntle le phoso. Nako ea nako e ka hlalosoa ho qoba ho ema ka ho sa feleng. Example ka tlase e bonts'a ho bala le ho ngola ho amohelang data ho tsoa ho moamoheli a sebelisa sebaka sa ho emisa sa OUT mme a romella data ho moamoheli a sebelisa tšitiso ea IN endpoint.
Example – Synchronous HID Bala le ho Ngola

__ALIGNED(4) uint8_t rx_buf[2];

__ALIGNED(4) uint8_t tx_buf[2];

uint32_t

xfer_len;

sl_status_t

boemo;

boemo = sl_usbd_hid_read_sync(class_nbr,

(1)

(ha ho letho *) rx_buf,

(2)

2u,

0u,

(3)

&xfer_len);

haeba (boemo! SL_STATUS_OK) {

/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */

}

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

40/174

Fetileview
boemo =sl_usbd_hid_read_sync(class_nbr,(1)(void *)rx_buf,(2)2u,0u,(3)&xfer_len);if(status ! SL_STATUS_OK){/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}
boemo =sl_usbd_hid_write_sync(class_nbr,(1)(void *)tx_buf,(4)2u,0u,(3)&xfer_len);if(status ! SL_STATUS_OK){/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}
(1) Nomoro ea mohlala ea sehlopha e entsoeng ho tloha sl_usbd_hid_create_instance() e fana ka referense ea ka hare bakeng sa sehlopha sa HID ho tsamaisa phetiso ho ea ho OUT kapa IN endpoint e nepahetseng.
(2) Kopo e tlameha ho netefatsa hore buffer e fanoeng ts'ebetsong e kholo ho lekana ho amohela data eohle. Ho seng joalo, mathata a khokahano a ka etsahala. Ka hare, ts'ebetso ea ho bala e etsoa ka mokhoa oa ho qetela oa taolo kapa ka ntlha ea ho emisa, ho itšetlehile ka taolo ea ho bala folakha e behiloeng ha u bitsa sl_usbd_hid_create_instance() .
(3) Ho qoba boemo bo sa feleng ba ho thibela, nako ea nako e hlalositsoeng ka milliseconds e ka hlalosoa. Boleng ba 809 bo etsa hore mosebetsi oa kopo o eme ka ho sa feleng.
(4) Sesebelisoa se fana ka buffer e qalileng ea ho fetisa.
Mosebetsi oa Litlaleho tsa Nako le Nako tse HID
Ho boloka bandwidth, moamoheli o na le bokhoni ba ho khutsisa litlaleho ho tsoa ho tšitiso ea IN endpoint ka ho fokotsa khafetsa ea tlaleho. Ho etsa joalo, moamoheli o tlameha ho romella kopo ea SET_IDLE. Sehlopha sa HID se kenngoeng ke Silicon Labs se na le mosebetsi o ka hare o hlomphang moeli oa ho tlaleha khafetsa oo o ka o sebelisang tlalehong e le 'ngoe kapa tse' maloa tsa tlhahiso. Litlaleho tsa Periodic Input Reports Mosebetsi o bonts'a ts'ebetso ea mesebetsi ea litlaleho tsa nako le nako.
Setšoantšo - Mosebetsi oa Litlaleho tsa Periodic Input

(1) Sesebelisoa se fumana kopo ea SET_IDLE. Kopo ena e totobatsa nako e sa sebetseng bakeng sa ID ea tlaleho e fanoeng. Ho fumana lintlha tse ling mabapi le kopo ea SET_IDLE, bona
(2) Sebopeho sa ID ea tlaleho (e fanoeng nakong ea mohato oa ho qala sehlopha sa HID) e nchafatsoa ka nako e sa sebetseng. Khaontara ea nako e sa sebetseng e qalisoa ka boleng ba nako e sa sebetseng. Sebopeho sa ID sa tlaleho se kentsoe qetellong ea lenane le hokahaneng le nang le libopeho tsa ID tsa litlaleho tsa lintlha. Boleng ba nako e sa sebetseng bo hlahisoa ka yuniti ea 4-ms e fanang ka mefuta e fapaneng ea 4 ho isa ho 1020 ms.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

41/174

Fetileview
Haeba nako ea ho se sebetse e le ka tlase ho nako ea likhetho ea nako ea ho emisa IN, litlaleho li hlahisoa ka nako ea likhetho.
(3) Nako e 'ngoe le e 'ngoe ea 4 ms, mosebetsi oa tlaleho ea nako le nako o sheba lethathamo la litlaleho tsa boitsebiso. Bakeng sa ID e 'ngoe le e' ngoe ea tlaleho ea ho kenya, mosebetsi o etsa ts'ebetso e 'ngoe ea tse peli tse ka khonehang. Nako ea nako ea mosebetsi e tsamaisana le yuniti ea 4-ms e sebelisoang bakeng sa nako e sa sebetseng. Haeba ha ho likopo tsa SET_IDLE tse rometsoeng ke moamoheli, lenane la boitsebiso ba litlaleho tsa boitsebiso ha le na letho 'me mosebetsi ha o na ho sebetsa. Ts'ebetso ea mosebetsi e tlaleha feela li-ID tse fapaneng le 0 le nako e telele ho feta 0.
(4) Bakeng sa ID ea tlaleho ea tlhahiso e fanoeng, mosebetsi o netefatsa hore na nako ea ho se sebetse e fetile. Haeba nako ea ho se sebetse e so ka e feta, khaonta e fokotsehile 'me ha ho tlaleho ea tlhahiso e romelloang ho moamoheli.
5
6 Mosebetsi oa kopo o ka letsetsa sl_usbd_hid_write_sync() ts'ebetso ho romella tlaleho ea tlhahiso. Kamora ho romella lintlha tsa tlaleho, sl_usbd_hid_write_sync() e nchafatsa buffer ea kahare e amanang le ID ea tlaleho ka data e sa tsoa romelloa. Ebe, mosebetsi oa litlaleho tsa nako le nako o romella lintlha tse tšoanang tsa tlaleho ka mor'a hore nako e 'ngoe le e 'ngoe ea ho se sebetse e fete le ho fihlela mosebetsi oa ts'ebeliso o ntlafatsa lintlha tse ka har'a buffer. Ho na le mokhoa o itseng oa ho notlela ho qoba bobolu ba data ea ID ea tlaleho ha phetoho e etsahala ka nako e nepahetseng ea phetiso e entsoeng ke mosebetsi oa tlaleho ea nako le nako.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

42/174

Fetileview
Fetileview
Sesebediswa sa USB MSC Sehlopha
Sesebelisoa sa USB MSC Sehlopha se Felletseview Mohlodi wa Mohlodi wa Sesebediswa sa USB MSC o Hlokahala ho tswa ho Core USB Sesebediswa sa MSC Sehlopha sa Tlhophiso ya Sesebediswa sa USB Sesebediswa sa MSC Tataiso ya Mananeo Sesebediswa sa USB Sesebediswa sa USB sa MSC Bakhanni ba Bobolokelo ba Sehlopha.
Karolo ena e hlalosa sehlopha sa sesebelisoa sa polokelo ea bongata (MSC) se tšehetsoang ke Silicon Labs USB Device. MSC ke protocol e nolofalletsang phetiso ea tlhahisoleseling lipakeng tsa sesebelisoa sa USB le moamoheli. Tlhahisoleseding e fetisetsoang ke ntho leha e le efe e ka bolokoang ka mokhoa oa elektroniki, joalo ka mananeo a phethisoang, khoutu ea mohloli, litokomane, litšoantšo, data ea tlhophiso, kapa lintlha tse ling tsa mongolo kapa linomoro. Sesebelisoa sa USB se hlaha e le sebaka sa polokelo sa kantle ho moamoheli, se nolofalletsang phetiso ea files ka ho hula le ho theola.
A file tsamaiso e hlalosa kamoo ho files li hlophisitsoe mecheng ea litaba tsa polokelo. Tlhaloso ea sehlopha sa polokelo ea boima ba USB ha e hloke letho file sistimi e tla sebelisoa ho lisebelisoa tse lumellanang. Ho e-na le hoo, e fana ka sebopeho se bonolo sa ho bala le ho ngola likarolo tsa data ho sebelisa "Small Computer System Interface" (SCSI) sete ea taelo e hlakileng. Ka hona, lits'ebetso tsa ts'ebetso li ka tšoara drive ea USB joalo ka hard drive, 'me li ka e fomata le efe kapa efe file tsamaiso eo ba e ratang.
Sehlopha sa sesebelisoa sa polokelo ea boima ba USB se tšehetsa liprothokholo tse peli tsa lipalangoang, tse latelang:
Lipalangoang tse ngata feela (BOT) Control/Bulk/Interrupt (CBI) Transport (e sebelisoa feela bakeng sa li-floppy disk drives)
Sehlopha sa lisebelisoa tsa polokelo ea boima se sebelisa taelo e hlakileng ea SCSI e behiloeng ho sebelisa protocol ea BOT feela, e bolelang hore ho tla sebelisoa lintlha tse ngata feela ho fetisa lintlha le tlhahisoleseding ea boemo. Ts'ebetsong ea MSC e tšehetsa likarolo tse ngata tse utloahalang.
Ts'ebetsong ea MSC e tsamaellana le lintlha tse latelang:
Universal Serial Bus Storage Class Specification Overview, Revision 1.3 Sept. 5, 2008. Universal Serial Bus Mass Storage Class Bulk-Only Transport, Revision 1.0 Sept. 31, 1999.
Sesebelisoa sa USB MSC aCl ss Overview
Protocol Endpoints Class e Kopa Sehokelo sa Sistimi e Nyane ea Khomphutha (SCSI)
Protocol
Karolong ena, re tla tšohla protocol ea Bulk-Only Transport (BOT) ea Sehlopha sa Polokelo ea Boipheliso. Protocol ea Bulk-Feela ea Lipalangoang e na le likarolo tse tharotages:
The Command Transport The Data Transport The Status Transport
Litaelo tsa polokelo ea bongata li romeloa ke moamoheli ka sebopeho se bitsoang Command Block Wrapper (CBW). Bakeng sa litaelo tse hlokang sepalangoang sa data stage, moamoheli o tla leka ho romella kapa ho amohela palo e nepahetseng ea li-byte ho tsoa sesebelisoa joalo ka ha ho boletsoe ke bolelele le masimo a folakha ea CBW. Ka mor'a hore data transport stage, moamoheli o leka ho fumana Command Status Wrapper (CSW) ho tsoa sesebelisoa se hlalosang boemo ba taelo hammoho le masala afe kapa afe a data (haeba

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

43/174

Fetileview
efe kapa efe). Bakeng sa litaelo tse sa kenyelletseng sepalangoang sa data stage, moamoheli o leka ho amohela CSW ka kotloloho kamora hore CBW e romeloe. Protocol e hlalositsoe ka botlalo ho Figure - MSC Protocol.
Setšoantšo - MSC Protocol

Lintlha tsa ho qetela
Lehlakoreng la lisebelisoa, ho latela litlhaloso tsa BOT, MSC e entsoe ka lintlha tse latelang: Li-endpoints tse peli tsa taolo IN le OUT tse bitsoang "default endpoint". Likarolo tse peli tse ngata tsa IN le OUT.
Tafole e ka tlase e bonts'a ts'ebeliso e fapaneng ea li-endpoints.
Tafole - Tšebeliso ea MSC Endpoint

Qetello
Control IN Control OUT Bulk IN Bulk OUT

Tataiso
Sesebediswa ho Host Host ho Sesebediswa Sesebediswa ho Host Sesebediswa

Tšebeliso
Palo le likopo tse ikhethileng tsa sehlopha sa MSC Palo le likopo tse ikhethileng tsa sehlopha sa MSC Romela CSW le data Amohela CBW le data

Likopo tsa Sehlopha
Ho na le likopo tse peli tse hlalositsoeng tsa taolo bakeng sa protocol ea MSC BOT. Likopo tsena le litlhaloso tsa tsona li hlalositsoe ka botlalo tafoleng e ka tlase.

Tafole - Likopo tsa Sehlopha sa Polokelo ea Boipheliso

Likopo tsa Sehlopha
Ho seta Botjha ho Boloka Bongata-Bongata

Tlhaloso
Kopo ena e sebelisetsoa ho tsosolosa sesebelisoa sa polokelo ea bongata le sebopeho se amanang le sona. Kopo ena e lokisa sesebelisoa ho amohela thibelo e latelang ea taelo.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

44/174

Fetileview

Likopo tsa Sehlopha

Tlhaloso

Fumana Max Kopo ena e sebelisetsoa ho khutlisa nomoro ea yuniti e phahameng ka ho fetesisa (LUN) e tšehetsoang ke sesebelisoa. Bakeng sa mohlalaample, a

LETSATSI

sesebelisoa se nang le LUN 0 le LUN 1 se tla khutlisa boleng ba 1. Sesebelisoa se nang le yuniti e le 'ngoe e utloahalang se tla khutlisa 0 kapa se tlose

kopo. Theko e phahameng e ka khutlisoang ke 15.

Sebopeho sa Tsamaiso ea Khomphutha e Nyenyane SCSI

Boemong ba sebopeho sa lenaneo, sesebelisoa sa MSC se sebelisa e 'ngoe ea liprothokholo tsa puisano tsa media tsa polokelo, joalo ka SCSI le SFF-8020i (ATAPI). "Programming Interface" e bolela hore na ke protocol efe e kenngoeng tšebetsong, 'me e thusa mokhanni oa sesebelisoa ho kenya mokhanni ea loketseng oa sesebelisoa bakeng sa ho buisana le sesebelisoa sa polokelo ea USB. SCSI ke protocol e atileng haholo e sebelisoang ka lisebelisoa tsa polokelo tsa USB MSC. Re fana ka ts'ebetsong bakeng sa sehlopha sa MSC SCSI seo basebelisi ba rona ba GSDK ba ka se sebelisang ka ntle ho lebokose.
SCSI ke sete ea litekanyetso tsa ho sebetsana le puisano lipakeng tsa likhomphutha le lisebelisoa tsa peripheral. Litekanyetso tsena li kenyelletsa litaelo, liprothokholo, li-interface tsa motlakase le li-interface tsa optical. Lisebelisoa tsa polokelo tse sebelisang likhokahano tse ling tsa Hardware, joalo ka USB, li sebelisa litaelo tsa SCSI bakeng sa ho fumana leseli la sesebelisoa/moamoheli le ho laola ts'ebetso ea sesebelisoa le ho fetisetsa li-block tsa data mecheng ea polokelo.
Litaelo tsa SCSI li akaretsa mefuta e mengata e fapaneng ea lisebelisoa le mesebetsi, ka hona, lisebelisoa li hloka sehlopha sa litaelo tsena. Ka kakaretso, litaelo tse latelang lia hlokahala bakeng sa puisano ea mantlha:
LIPOTSO BALA BOKHOA(10) BALA(10) KOPO UNITI YA TEKO YA MAIKUTLO E LOKILE HO NGOLA(10)
Sesebediswa sa USB MSC Class Resource Litlhoko ho tloha Core

Nako le nako ha o kenya mohlala oa sehlopha sa MSC ho tlhophiso ea USB ka ts'ebetso sl_usbd_msc_add_to_configuration() , lisebelisoa tse latelang li tla abeloa ho tloha mantlha.

Mohlodi
Li-interfaces Mefuta e meng ea lihokelo Lihlopha tsa Endpoints Interface

Bongata
1 1 2 0

Hlokomela hore linomoro tseo ke tsa tlhophiso. Ha o theha SL_USBD_INTERFACE_QUANTITY , SL_USBD_ALT_INTERFACE_QUANTITY , SL_USBD_INTERFACE_GROUP_QUANTITY le SL_USBD_DESCRIPTOR_QUANTITY litekanyetso tsa lipeakanyo, u seke oa lebala ho ela hloko hore na ke litlhophiso tse kae tse tla eketsoa. Bakeng sa boleng ba tlhophiso ea SL_USBD_OPEN_ENDPOINTS_QUANTITY, kaha li-endpoints li buloa feela ha tlhophiso e behiloe ke moamoheli, o hloka feela ho ela hloko palo ea lintlha tse hlokahalang bakeng sa mohlala oa sehlopha.
Sesebediswa sa USB MSC Class Configuration

Ho sebelisoa lihlopha tse peli tsa liparamente tsa tlhophiso ho hlophisa sehlopha sa MSC:
Sesebediswa sa USB MSC Class Kopo-Litlhophiso tse Tobileng Sesebediswa sa USB Sesebediswa sa MSC Sehlopha sa Logical Unit Configuration
Sesebediswa sa USB sa MSC Class Application-Specific Configurations

Sehlopha sa Kopanya-Nako Litlhophiso tsa Sehlopha sa Boemo Pōpo

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

45/174

Fetileview

Litlhophiso tsa Nako ea Kopanya ea Sehlopha
Silicon Labs USB Device sehlopha sa MSC le SCSI subclass li ka lokisoa ka nako ea ho kopanya ka #defines e fumanehang ho sl_usbd_core_config.h file.
Tafole - Li-Constant Configuration Constants

Lebitso la Tlhophiso

Tlhaloso

SL_USBD_MSC_CLASS_INST Nomoro ea maemo a phaposi eo u tla e abela ka mohala ho tšebetso.

ANCE_QUANTITY

sl_usbd_msc_scsi_create_instance() .

SL_USBD_MSC_CONFIGURA Palo ea tlhophiso eo ketsahalo ea sehlopha e ka eketsoang ka mohala ho

TION_QUANTITY

tshebetso sl_usbd_msc_scsi_add_to_configuration() .

SL_USBD_MSC_LUN_QUANT Nomoro ya diyuniti tse utlwahalang ho latela sehlopha seo o tla se eketsa ka mohala ho

ITY

tshebetso sl_usbd_msc_scsi_lun_add() .

SL_USBD_MSC_SCSI_64_BIT E nolofalletsa kapa e tima ts'ehetso ea Logical Block Address (LBA) ea 64 bits.
_LBA_EN

SL_USBD_MSC_DATA_BUFF Boholo ba buffer ea data ka mohlala oa sehlopha ka li-byte ER_SIZE

Boleng ba kamehla
2
1
2
0
512

Pōpo ea Boemo ba Sehlopha
Ho theha mohlala oa sehlopha sa USB MSC SCSI ho etsoa ka ho letsetsa sl_usbd_msc_scsi_create_instance() mosebetsi. Ts'ebetso ena e nka khang e le 'ngoe ea tlhophiso e hlalositsoeng ka tlase.
p_scsi_callbacks
p_scsi_callbacks ke sesupo sa sebopeho sa tlhophiso ea mofuta sl_usbd_msc_scsi_callbacks_t . Ho phaella ho di-callback tse tlwaelehileng tsa sehlopha sa usb di hokela/hakolwa, e fa sehlopha sa MSC sete ya ditshebetso tsa boikgethelo tse bitswang ha ketsahalo e etsahala yuniting e utloahalang. Null pointer ( NULL ) e ka fetisetsoa khang ena haeba ho se na li-callback tse hlokahalang.
Tafole e ka tlase e hlalosa sebaka se seng le se seng sa tlhophiso se fumanehang sebopehong sena sa tlhophiso.
Tafole – sl_usbd_msc_scsi_callbacks_t Sebopeho sa Tlhophiso

Masimo

Tlhaloso

.nontsha

E bitsoa ha mohlala oa sehlopha sa USB o buletsoe ka katleho.

.disable E bitswa ha mohlala wa sehlopha sa USB o timilwe.

.host_eject Mosebetsi o bitsoang ha yuniti e utloahalang e ntšoa ho moamoheli.

Mosebetsi Tshaeno
void app_usbd_msc_scsi_enable(uint8_t class_nbr);
sesebelisoa sa lefeela_usbd_msc_scsi_disable(uint8_t class_nbr); app e se nang letho_usbd_msc_scsi_host_eject(uint8_t class_nbr, uint8_t lu_nbr);

Sesebediswa sa USB MSC Class Logical Unit Configuration

Ho kenyelletsa yuniti e utloahalang ho sehlopha sa MSC ho etsoa ka ho letsetsa mosebetsi sl_usbd_msc_lun_add() . Ts'ebetso ena e nka khang e le 'ngoe ea tlhophiso e hlalositsoeng ka tlase.

p_lu_info

p_lu_info ke sesupo sa sebopeho sa mofuta sl_usbd_msc_scsi_lun_info_t . Sepheo sa eona ke ho fana ka tlhahisoleseding e mabapi le yuniti e utloahalang ho sehlopha sa MSC.
Tafole e ka tlase e hlalosa sebaka se seng le se seng sa tlhophiso se fumanehang sebopehong sena sa tlhophiso.

Tafole – sl_usbd_msc_scsi_lun_info_t Sebopeho sa Tlhophiso

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

46/174

Fetileview

Tšimo

Tlhaloso

Tšimo
.scsi_lun_api_p tr

Tlhaloso
Sesupa ho media driver API e tla sebetsana le yuniti ena e utloahalang. Sheba Li-Driver tsa Polokelo tsa Sesebediswa sa USB sa MSC bakeng sa tlhaiso-leseling e batsi ka bakhanni ba polokelo.

.ve n o r_id _ p tr
.product_id_ptr
.p ro d uct_ re v isi on_level .is_ ad _o nly

Supa thapo e nang le boitsebiso ba morekisi ba yuniti e utloahalang. Boholo ba bolelele ba khoele ke litlhaku tse 8. Supa thapo e nang le tlhahiso ea sehlahisoa sa yuniti e utloahalang. Bolelele bo boholo ba khoele ke litlhaku tse 16. Boemo ba ntlafatso ea sehlahisoa.
Tšoaea e bontšang hore na yuniti e utloahalang e lokela ho bonoa e baloa feela ho tloha ntlheng ea view ea moamoheli ( 'nete) kapa che ( bohata ).

Sesebediswa sa USB MSC Class Programming Guide

Karolo ena e hlalosa mokhoa oa ho sebelisa sehlopha sa MSC.
Ho qala Sehlopha sa MSC ea Sesebediswa sa USB Ho Kenya Sesebediswa sa USB MSC SCSI Class Instance ho Sesebediswa sa Hao Sesebediswa sa USB MSC Class Logical Unit Handling.
Ho qala Sesebediswa sa USB MSC Sehlopha

Ho kenyelletsa tšebetso ea sehlopha sa MSC SCSI sesebelisoa sa hau, qala pele sehlopha sa MSC le sehlopha sa SCSI ka ho letsetsa tšebetso sl_usbd_msc_init() le sl_usbd_mscsi_init() .
ExampLe ka tlase e bonts'a mokhoa oa ho letsetsa sl_usbd_msc_init() le sl_usbd_msc_scsi_init() .

Example - Ho letsetsa sl_usbd_msc_init() le sl_usbd_msc_scsi_init()

sl_status_t boemo;
boemo = sl_usbd_msc_init(); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}
boemo = sl_usbd_msc_scsi_init(); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}
Ho eketsa Sesebediswa sa USB MSC SCSI Class Instance ho Sesebediswa sa Hao
Ho kenya ts'ebetso ea sehlopha sa MSC SCSI sesebelisoa sa hau, qala ka ho etsa mohlala, ebe u o kenya litlhophisong tsa sesebelisoa sa hau. O tlameha ho eketsa bonyane yuniti e le 'ngoe e utloahalang ketsahalong ea hau.
Ho theha Boemo ba Sehlopha sa MSC SCSI
Theha mohlala oa sehlopha sa MSC SCSI ka ho letsetsa tšebetso sl_usbd_msc_scsi_create_instance() .
ExampLe ka tlase e bonts'a mokhoa oa ho letsetsa sl_usbd_msc_create_instance() u sebelisa likhang tsa kamehla. Ho fumana lintlha tse ling mabapi le likhang tsa tlhophiso tse lokelang ho fetisetsoa ho sl_usbd_msc_scsi_create_instance() , sheba Litlhophiso tse Tobileng tsa Sesebediswa sa MSC .
Example – Ho letsetsa sl_usbd_ msc_scsi_create_instance()

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

47/174

Fetileview

uint8_t class_nbr; sl_status_t boemo;
sl_usbd_msc_scsi_callbacks_t app_usbd_msc_scsi_callbacks = {.enable = NULL, .disable = NULL, .host_eject = NULL };
boemo = sl_usbd_msc_scsi_create_instance(&app_usbd_msc_callbacks,0 &class_nbr);
haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}
Ho kenyelletsa Boemo ba Sehlopha sa MSC ho Litlhophiso tsa Sesebediswa sa Hao (s)
Ka mor'a hore u thehe mohlala oa sehlopha sa MSC, u ka e eketsa ho tlhophiso ka ho letsetsa mosebetsi
sl_usbd_msc_add_to_configuration() .
Exampka tlase e bonts'a mokhoa oa ho letsetsa sl_usbd_mscsi_add_to_configuration() u sebelisa likhang tsa kamehla.
Example - Ho letsetsa sl_usbd_ msc_scsi_add_to_configuration()

sl_status_t boemo;

boemo = sl_usbd_msc_scsi_add_to_configuration(class_nbr,

(1)

config_nbr_fs);

(2)

haeba (boemo! SL_STATUS_OK) {

/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */

}

(1) Nomoro ea sehlopha eo u ka e kenyang ho tlhophiso e khutlisitsoeng ke sl_usbd_msc_scsi_create_instance() . (32) Nomoro ea tlhophiso (mona e e eketsa ho tlhophiso ea Full-Speed).
Sesebediswa sa USB MSC Class Logical Unit Ho sebetsana le
Ho Eketsa Yuniti e utloahalang Ho hokela/Ho Khetla Bohareng ba Polokelo
Ho eketsa yuniti e utloahalang
Ha o eketsa yuniti e utloahalang sehlopheng sa hau sa MSC SCSI, e tlameha ho tlamahanngoa le sebaka sa polokelo (RAMDisk, karete ea SD, memori ea flash, joalo-joalo). Sehlopha sa MSC se sebelisa mokhanni oa polokelo ho buisana le mecha ea litaba ea polokelo. Mokhanni enoa o tla hloka ho fana ka thepa ha a eketsa yuniti e utloahalang.
ExampLe ka tlase e bonts'a mokhoa oa ho eketsa yuniti e utloahalang ka sl_usbd_msc_scsi_lun_add() .
Example - Ho eketsa yuniti e utloahalang ka sl_usbd_msc_scsi_lun_add()

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

48/174

Fetileview

sl_usbd_msc_scsi_lun_t *lu_object_ptr = NULL;

sl_usbd_msc_scsi_lun_info_t lu_info;

sl_status_t

boemo;

lu_info.sl_usbd_msc_scsi_lun_api_t = &app_usbd_scsi_storage_block_device_api;

lu_info.vendor_id_ptr

= "Li-Labs tsa Silicon";

lu_info.product_id_ptr

= "thibela sesebelisoa example”;

lu_info.product_revision_level = 0x1000u;

lu_info.e_bala_feela

= bohata;

boemo = sl_usbd_msc_scsi_lun_add(class_nbr, &lu_info, &lu_object_ptr);
haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}

Ho hokela/ Ho Ntsha Sebaka sa Bobolokelo
Ka mor'a hore yuniti e utloahalang e eketsoe, sebaka sa polokelo se tlameha ho kenngoa hore se fumanehe ho tloha lehlakoreng la moamoheli. Sehlopha sa MSC se fana ka mesebetsi e 'meli ho laola mokhatlo oa mecha ea litaba ea polokelo ho yuniti e utloahalang: sl_usbd_msc_scsi_lun_attach() le sl_usbd_msc_scsi_lun_detach() . Mesebetsi ena e u lumella ho etsisa ho tlosoa ha sesebelisoa sa polokelo e le hore u boele u fumane mokhoa oa ho kena ho sesebelisoa se kentsoeng ha ho hlokahala.
ExampLe ka tlase e bonts'a mokhoa oa ho sebelisa ts'ebetso sl_usbd_msc_scsi_lun_attach() le sl_usbd_msc_scsi_lun_detach() .
Example – Hokela Media/Detach

sl_status_t boemo;

boemo = sl_usbd_msc_scsi_lun_attach(lu_object_ptr); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}

(1)

boemo = sl_usbd_msc_scsi_lun_detach(lu_object_ptr); haeba (boemo ! SL_STATUS_OK) {
/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}

(2)

boemo = sl_usbd_msc_scsi_lun_attach(lu_object_ptr) haeba (boemo ! SL_STATUS_OK) {
/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */
}

(3)

(1) Ho tloha motsotsong ona, haeba sesebelisoa sa MSC se hokahane le moamoheli, mecha ea litaba ea polokelo ea fumaneha.
(2) Haeba sesebelisoa sa MSC se hokahane le moamoheli, mecha ea litaba joale e tla bonahala e le sieo. Ka nako ena, ts'ebetso e ka etsoa mecheng ea litaba ho tsoa ts'ebelisong e kentsoeng.
(3) Hape, haeba sesebelisoa sa MSC se hokahane le moamoheli, mecha ea litaba ea polokelo e tla hlaha e hokahane.
Sesebediswa sa USB MSC Class Storage Drivers
Sehlopha sa MSC sa Sesebelisoa sa USB se hloka mokhanni oa polokelo ho buisana le sebaka sa polokelo. Hajoale, Silicon Labs ha e fane ka bakhanni.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

49/174

Fetileview
TPY aa he driver AI e hlalosoa ka typedef sl_usbd_msc_scsi_lun_api_t . sl_usbd_msc_scsi_lun_api_t v rible ea rona e tlameha ho kenyelletsoa ho aaaaaaaa sl_usbd_msc_scsi_lun_info_t v ri ble, p ssed s rgument ha u dd logic l unit with sl_usbd_msc_ddsi_lun_a. Sheba karolo ea Sesebelisoa sa USB MSC SCSI API bakeng sa lintlha tse ling mabapi le meaho. Ts'ebetso ea mokhanni oa polokelo e ka ba bonolo joalo ka likarolo tse ngata tsa RAM. Boholo bo tloaelehileng ba lekala (ke hore, boholo ba block) ke 512 bakeng sa lisebelisoa tsa polokelo ea bongata, le 2048 bakeng sa li-CD-ROM.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

50/174

Fetileview
Fetileview
Sehlopha sa Barekisi ba Sesebelisoa sa USB
Sehlopha sa barekisi ba sesebelisoa sa USB se Felletseview Litlhoko tsa Sehlopha sa Barekisi ba Sesebediswa sa USB ho tloha ho Core USB Device Vendor Class Configuration Tataiso ea Mananeo a Sehlopha sa Barekisi ba Sesebediswa sa USB Sehlopha sa Barekisi se o dumella ho aha disebediswa tse kgethehileng tsa barekisi tse ka kenyang tshebetsong protocol ya mong. E ipapisitse le li-endpoints tse ngata ho fetisetsa data lipakeng tsa moamoheli le sesebelisoa. Ho fetisoa ha bongata ho loketse bakeng sa ho fetisa lintlha tse ngata tse sa hlophisoang le ho fana ka phapanyetsano e tšepahalang ea data ka ho sebelisa mokhoa oa ho lemoha phoso le ho leka hape. Ntle le li-endpoints tse ngata, sehlopha sa Vendor se ka boela sa sebelisa li-endpoints tsa boikhethelo. Sistimi efe kapa efe ea ts'ebetso (OS) e ka sebetsa le sehlopha sa Vendor ha feela OS e na le mokhanni oa ho sebetsana le sehlopha sa barekisi. Ho itšetlehile ka OS, mokhanni e ka ba letsoalloa kapa morekisi-ka ho khetheha. Mohlala, tlasa Microsoft Windows®, sesebelisoa sa hau se sebelisana le mokhanni oa WinUSB o fanoeng ke Microsoft ho buisana le sesebelisoa sa morekisi.
Sehlopha sa barekisi ba sesebelisoa sa USB se Felletseview
Setšoantšo - General Architecture Pakeng tsa Windows Host le Vendor Class e bonts'a meralo e akaretsang lipakeng tsa moamoheli le sesebelisoa se sebelisang sehlopha sa barekisi. Ho sena mohlalaampLeha ho le joalo, sistimi e sebetsang ea moamoheli ke MS Windows.
Setšoantšo - Kakaretso ea Mehaho Pakeng tsa MS Windows Host le Vendor Class

Ka lehlakoreng la MS Windows, sesebelisoa se buisana le sesebelisoa sa morekisi ka ho sebelisana le laeborari ea USB. Lilaebrari, joalo ka libusb, li fana ka API ho laola sesebelisoa le liphaephe tse amanang le eona, le ho buisana le sesebelisoa ka ho laola, bongata le ho sitisa li-endpoints.
Ka lehlakoreng la sesebelisoa, sehlopha sa Vendor se entsoe ka lintlha tse latelang:
Likarolo tse peli tsa taolo IN le OUT tse bitsoang "default endpoint". Likarolo tse peli tse ngata tsa IN le OUT.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

51/174

Fetileview

Likhatiso tse peli tsa IN le OUT. Lipara tsena ke tsa boikhethelo. Tafole e ka tlase e bonts'a ts'ebeliso ea liphetho tse fapaneng:
Tafole - Tšebeliso ea Lintlha tsa Sehlopha sa Barekisi

Tsela ea ho qetela

Laola IN
Taolo
TSOA
Bongata IN

Sesebelisoa-ho amohela
>Sesebediswa se amohelang
Sesebelisoa-ho amohela

Bongata TSOA
Thibela IN
Thibela
TSOA

Host-todevice
Sesebelisoa-ho amohela
Host-todevice

Tšebeliso
Likopo tse tloaelehileng tsa ho baloa le likopo tse ikhethileng tsa morekisi.
Likopo tse tloaelehileng tsa ho baloa le likopo tse ikhethileng tsa morekisi.
Puisano e tala ya data. Lintlha li ka hlophisoa ho latela proprietary protocol.
Puisano e tala ya data. Lintlha li ka hlophisoa ho latela proprietary protocol.
Khokahano e tala ea data kapa tsebiso. Lintlha li ka hlophisoa ho latela proprietary protocol. Khokahano e tala ea data kapa tsebiso. Lintlha li ka hlophisoa ho latela proprietary protocol.

Sesebelisoa se ka sebelisa li-endpoints tse ngata le ho sitisa ho romella kapa ho amohela data ho kapa ho tsoa ho moamoheli. E ka sebelisa feela sebaka sa ho qetela ho tseba likopo tse ikhethileng tsa morekisi tse rometsoeng ke moamoheli. Likopo tse tloaelehileng li laoloa ka hare ke Core layer ea Silicon Labs USB Device.
Litlhoko tsa Sehlopha sa Barekisi ba Sesebelisoa sa USB ho tsoa ho Core

Nako le nako ha u eketsa mohlala oa sehlopha sa barekisi ho tlhophiso ka ts'ebetso sl_usbd_vendor_add_to_configuration() , lisebelisoa tse latelang li tla abeloa ho tloha mantlha.

Mohlodi
Li-interfaces Mefuta e meng ea lihokelo Lihlopha tsa Endpoints Interface

Bongata
1 1 2 (4 haeba u nolofalitse ho kena-kenana le liphetho) 0

Hlokomela hore linomoro tseo ke tsa tlhophiso. Ha o theha SL_USBD_INTERFACE_QUANTITY , SL_USBD_ALT_INTERFACE_QUANTITY , SL_USBD_INTERFACE_GROUP_QUANTITY le SL_USBD_DESCRIPTOR_QUANTITY litekanyetso tsa lipeakanyo, u seke oa lebala ho ela hloko hore na ke litlhophiso tse kae tse tla eketsoa. Bakeng sa boleng ba tlhophiso ea SL_USBD_OPEN_ENDPOINTS_QUANTITY, kaha li-endpoints li buloa feela ha tlhophiso e behiloe ke moamoheli, o hloka feela ho ela hloko palo ea lintlha tse hlokahalang bakeng sa mohlala oa sehlopha.
Tlhophiso ea Sehlopha sa Barekisi ba Sesebelisoa sa USB

Lihlopha tse peli tsa li-parameter tsa tlhophiso li sebelisoa ho hlophisa sehlopha sa Vendor:
Ts'ebeliso ea Sehlopha sa Barekisi ba Sesebediswa sa USB-Litlhophiso tse Khethehileng Litlhophiso tsa Boemo ba Sesebediswa sa USB
Litlhophiso tse Ikemetseng tsa Sehlopha sa Morekisi oa Sesebelisoa sa USB
Taba ea pele, ho sebelisa module ea sehlopha sa Barekisi ba sesebelisoa sa Silicon Labs USB, fetola tlhophiso ea nako ea Vendor compile e hlalosa ho latela litlhoko tsa kopo ea hau. Li kopantsoe hape ka har'a sehlooho sa sl_usbd_core_config.h file tlas'a karolo ea Morekisi. Morero oa tlhophiso ea bongata ke ho tsebisa mojule oa sesebelisoa sa USB mabapi le hore na o ka aba lintho tse kae tsa USB Vendor.
Tafole e ka tlase e hlalosa mofuta o mong le o mong oa tlhophiso.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

52/174

Fetileview

Letlapa - Tlhophiso ea Morekisi oa Sesebelisoa sa USB E ea Hlalosa

Lebitso la Tlhophiso

Tlhaloso

Boleng ba kamehla

SL_USBD_VENDOR_CLASS_INSTANCE_QUANTITY Palo ea maemo a phaposi eo u tla e abela ka mohala ho tšebetso e 2 sl_usbd_vendor_create_instance() .

SL_USBD_VENDOR_CONFIGURATION_QUANTITY Palo ea litlhophiso. Maemo a sehlopha sa barekisi a ka eketsoa 1 ho tlhophiso e le 'ngoe kapa ho feta ka mohala ho ts'ebetso sl_usbd_vendor_add_to_configuration() .

Litlhophiso tsa Boemo ba Morekisi oa Sesebelisoa sa USB

Karolo ena e hlalosa litlhophiso tse amanang le maemo a sehlopha sa barekisi.
Class Instance Creation intr_en interval p_vendor_callbacks
Pōpo ea Boemo ba Sehlopha

Ho theha mohlala oa sehlopha sa Vendor ho etsoa ka ho bitsa mosebetsi sl_usbd_vendor_create_instance() , e nkang likhang tse tharo tsa tlhophiso tse hlalositsoeng ka tlase.

intr_en
Boolean e bonts'ang hore na li-endpoints tse peli tse sitisang li lokela ho eketsoa kapa che.

Boleng
bohata ba nnete

Tlhaloso
Likarolo tse peli tsa IN/OUT li tla eketsoa 'me li fumanehe ts'ebelisong e kentsoeng. Ha ho sebaka sa tšitiso se tla eketsoa. Ke para ea Bulk IN/OUT endpoint e tla fumaneha.

karohano
Haeba u beha intr_en hore e be 'nete , u ka hlakisa nako ea ho emisa likhetho (ka milliseconds). Haeba u beha intr_en ho false , u ka beha nako ho 0 kaha sehlopha se tla e hlokomoloha.
p_vendor_callbacks
p_vendor_callbacks ke sesupo sa sebopeho sa mesebetsi ea callback. hore o ka hlakisa ho sebetsana le likopo tse khethehileng tsa taolo ea sehlopha. Haeba u sa sebelise likopo tse khethehileng tsa sehlopha kapa litlhoko tse lumellang / tima tsebiso, u ka etsa sena ho NULL .
ExampLe ka tlase e fana ka tshaeno e lebelletsoeng ea mothusi oa likopo tse khethehileng tsa sehlopha sa hau.
Example – Signature ea Class-Specific Request Function

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 =
{
.noble = NULL, .disable = NULL, .setup_req = app_usbd_vendor_req_handle,
};

(1) Nomoro ea mohlala oa sehlopha sa barekisi.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

53/174

Fetileview

(2) Sesupa ho kopo e amohetseng ea ho seta ho tsoa ho moamoheli.
Tataiso ea Mananeo ea Sehlopha sa Barekisi ba Sesebelisoa sa USB
Karolo ena e hlalosa mokhoa oa ho sebelisa sehlopha sa barekisi. Ho Qala Sehlopha sa Barekisi ba Sesebediswa sa USB Ho Tsenya Boemo ba Barekisi ba Sesebediswa sa USB ho Sesebediswa sa hao se Buisanang o sebedisa Sehlopha sa Barekisi ba Sesebediswa sa USB
Ho qala Sehlopha sa Barekisi ba Sesebelisoa sa USB
Ho kenya tšebetsong ea Sehlopha sa Barekisi sesebelisoa sa hau, qala sehlopha pele ka ho letsetsa sesebelisoa USBD_Vendor_Init(). ExampLe ka tlase e bonts'a mokhoa oa ho letsetsa sl_usbd_vendor_init() .
Example - Ho letsetsa sl_usbd_vendor_init()

sl_status_t boemo;
boemo = sl_usbd_vendor_init(); haeba (boemo ! SL_STATUS_OK) {/* Ho hlahile phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */}
E kenyelletsa Boemo ba Barekisi ba Sesebelisoa sa USB ho Sesebelisoa sa hau
Ho kenyelletsa tšebetso ea sehlopha sa barekisi sesebelisoa sa hau, o tlameha ho qala ka ho etsa mohlala, ebe o o kenya ho litlhophiso tsa sesebelisoa sa hau.
Ho theha Boemo ba Sehlopha sa Barekisi Ho Eketsa Boemo ba Sehlopha sa Barekisi ho Litlhophiso tsa Sesebediswa sa Hao (s)
Ho theha Boemo ba Sehlopha sa Barekisi
Theha mohlala oa sehlopha sa barekisi ka ho bitsa mosebetsi sl_usbd_vendor_create_instance() . ExampLe ka tlase e bonts'a mokhoa oa ho letsetsa sl_usbd_vendor_create_instance() u sebelisa likhang tsa kamehla. Bakeng sa tlhahisoleseling e eketsehileng mabapi le likhang tsa tlhophiso tse lokelang ho fetisetsoa ho sl_usbd_vendor_create_instance() , bona Litlhophiso tsa Boemo ba Sesebediswa sa USB .
Example - Ho letsetsa sl_usbd_vendor_create_instance()

uint8_t class_nbr; sl_status_t boemo;

boemo = sl_usbd_vendor_create_instance(bohata,

(1)

0u,

(2)

app_usbd_vendor_callback_functions, (3)

&class_nbr);

haeba (boemo! SL_STATUS_OK) {

/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */

}

(1) Ha ho na likhatiso tsa ho qetela ka mohlala oa sehlopha sena. 2

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

54/174

Fetileview

(3) Mosebetsi oa ho letsetsa oo e leng karolo ea kopo ea hau e sebetsanang le likopo tsa sehlopha se ikhethileng sa barekisi. Sheba Ho Buisana u sebelisa Sehlopha sa Barekisi ba Sesebelisoa sa USB bakeng sa lintlha tse ling. Ho Eketsa Boemo ba Sehlopha sa Barekisi ho Litlhophiso tsa Sesebediswa sa Hao Kamora hore o thehe mohlala wa sehlopha sa barekisi, o ka o kenya ho tlhophiso ka ho letsetsa tshebetso USBD_Vendor_ConfigAdd(). ExampLe ka tlase e bonts'a mokhoa oa ho letsetsa sl_usbd_vendor_add_to_configuration() u sebelisa likhang tsa kamehla.
Example - Ho letsetsa sl_usbd_vendor_add_to_configuration()

sl_status_t boemo;

boemo = sl_usbd_vendor_add_to_configuration(class_nbr,

(1)

config_nbr_fs);

(2)

haeba (boemo! SL_STATUS_OK) {

/* Ho etsahetse phoso. Ho sebetsana le liphoso ho tlameha ho eketsoa mona. */

}

(1) Nomoro ea sehlopha eo u lokelang ho e kenyelletsa ho tlhophiso e khutlisitsoeng ke sl_usbd_vendor_create_instance() . (2) Nomoro ea tlhophiso (mona e e eketsa ho tlhophiso ea Full-Speed).
Ho Buisana ka ho Sebelisa Sehlopha sa Barekisi ba Sesebelisoa sa USB
Kakaretso ea Synchronous Communication Asynchronous Communication Vendor Request Kakaretso Sehlopha sa barekisi se fana ka mesebetsi e latelang ho buisana le moamoheli. Bakeng sa lintlha tse ling mabapi le liparamente tsa ts'ebetso, bona API ea Morekisi oa Sesebelisoa sa USB.
Letlapa - Kakaretso ea API ea Puisano ea Barekisi

Lebitso la tshebetso
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-
thibela.
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

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

55/174

Fetileview

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

boemo;

status = sl_usbd_vendor_read_bulk_sync(class_nbr,

(1)

(void *)&rx_buf[0],

(2)

2u,

0u,

(3)

&xfer_len);

haeba (boemo! SL_STATUS_OK) {

/* $$$$ Tšoara phoso. */

}

status = sl_usbd_vendor_write_bulk_sync( class_nbr,

(1)

(void *)&tx_buf[0],

(4)

2u,

0u,

(3)

false,

(5)

&xfer_len);

haeba (boemo! SL_STATUS_OK) {

/* $$$$ Tšoara phoso. */

}

(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) Sesebelisoa se fana ka buffer e qalileng ea ho fetisa.
(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.
Puisano e Asynchronous
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

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

56/174

Fetileview

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

boemo;

status = sl_usbd_vendor_read_bulk_async(class_nbr,

(void *)&rx_buf[0],

(2)

2u,

app_usbd_vendor_rx_completed,

NULL);

(4)

haeba (boemo! SL_STATUS_OK) {

/* $$$$ Tšoara phoso. */

}

status = sl_usbd_vendor_write_bulk_async(class_nbr,

(void *)&tx_buf[0],

(5)

2u,

app_usbd_vendor_tx_completed,

NULL,

(4)

false);

(6)

haeba (boemo! SL_STATUS_OK) {

/* $$$$ Tšoara phoso. */

}

}

(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)

{

haeba (boemo! SL_STATUS_OK) {

/* $$$$ Do some processing. */

} tse ling {

/* $$$$ Tšoara phoso. */

}

}

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)

{

haeba (boemo! SL_STATUS_OK) {

/* $$$$ Do some processing. */

} tse ling {

/* $$$$ Tšoara phoso. */

}

}

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

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

57/174

Fetileview
(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

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

58/174

Fetileview

#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 boemo;

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;

kamehla:

(6)

// Request is not supported.

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

59/174

Fetileview

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):

sebopeho sa typedef {

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

*/

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

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

60/174

Litokomane tsa API
Litokomane tsa API
Litokomane tsa API
Lethathamo la li-module
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

Tlhaloso
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

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

61/174

USB Device API
USB Device API
USB Device API
USB Device API.
Limojule
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

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

62/174

USB Device ACM API

USB Device ACM API

USB Device ACM API

USB Device CDC ACM API.
Limojule
a sl_usbd_cdc_ cm_line_coding_t sl_usbd_cdc_acm_callbacks_t
Mesebetsi

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

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

63/174

USB Device ACM API
Macros
#define SL_USBD_CDC_ACM_NBR_NONE 255u
MODULE.
#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
Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

64/174

USB Device ACM API

Mofuta
lefeela

Direction N/A

Argument Name

MACROS GLOBAL CONSTANTS FUNCTION PROTOTYPES CDC ACM FUNCTIONS

Initialize the CDC ACM serial emulation subclass.
E khutla

Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

Tlhaloso

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

Mofuta
uint16_t
uint16_t

Direction Argument Name

Tlhaloso

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.

E khutla

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

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

E khutla

Copyright © 2025 Silicon Laboratories. Litokelo tsohle li sirelelitsoe.

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

Mofuta

Tataiso

Argument Name

Tlhaloso

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

Litokomane / Lisebelisoa

SILICON LABS USB Device Stack [pdf] Buka ea Taelo
USB Device Stack, Device Stack, Stack

Litšupiso

Tlohela maikutlo

Aterese ea hau ea lengolo-tsoibila e ke ke ea phatlalatsoa. Libaka tse hlokahalang li tšoailoe *