📄 usbs-start.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE>Starting up a USB Device</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="eCos USB Slave Support"HREF="io-usb-slave.html"><LINKREL="PREVIOUS"TITLE="USB Enumeration Data"HREF="usbs-enum.html"><LINKREL="NEXT"TITLE="Devtab Entries"HREF="usbs-devtab.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="usbs-enum.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="usbs-devtab.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="USBS-START">Starting up a USB Device</H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN16210"></A><H2>Name</H2><TTCLASS="FUNCTION">usbs_start</TT> -- Starting up a USB Device</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN16214"><H2>Synopsis</H2><DIVCLASS="FUNCSYNOPSIS"><ANAME="AEN16215"><P></P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="FUNCSYNOPSISINFO">#include <cyg/io/usb/usbs.h></PRE></TD></TR></TABLE><P><CODE><CODECLASS="FUNCDEF">void usbs_start</CODE>(usbs_control_endpoint* ep0);</CODE></P><P></P></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="AEN16222"></A><H2>Description</H2><P>Initializing a USB device requires some support from higher-levelcode, typically the application, in the form of enumeration data.Hence it is not possible for the low-level USB driver to activate aUSB device itself. Instead the higher-level code has to take care ofthis by invoking <TTCLASS="FUNCTION">usbs_start</TT>. This function takesa pointer to a USB control endpoint data structure. USB device driversshould provide exactly one such data structure for every USB device,so the pointer uniquely identifies the device.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">const usbs_enumeration_data usb_enum_data = { …};intmain(int argc, char** argv){ usbs_sa11x0_ep0.enumeration_data = &usb_enum_data; … usbs_start(&usbs_sa11x0_ep0); …}</PRE></TD></TR></TABLE><P>The exact behaviour of <TTCLASS="FUNCTION">usbs_start</TT> depends on theUSB hardware and the device driver. A typical implementation wouldchange the USB data pins from tristated to active. If the peripheralis already plugged into a host then the latter should detect thischange and start interacting with the peripheral, including requestingthe enumeration data. Some of this may happen before<TTCLASS="FUNCTION">usbs_start</TT> returns, but given that multipleinteractions between USB host and peripheral are required it is likelythat the function will return before the peripheral is fullyconfigured. Control endpoints provide a <AHREF="usbs-control.html#AEN16552">mechanism</A> for informinghigher-level code of USB state changes.<TTCLASS="FUNCTION">usbs_start</TT> will return even if the peripheral isnot currently connected to a host: it will not block until theconnection is established.</P><P><TTCLASS="FUNCTION">usbs_start</TT> should only be called once for a givenUSB device. There are no defined error conditions. Note that thefunction affects the entire USB device and not just the controlendpoint: there is no need to start any data endpoints as well.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="usbs-enum.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="usbs-devtab.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">USB Enumeration Data</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="io-usb-slave.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Devtab Entries</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -