⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manual.html

📁 这个是从国外弄到的一个红外协议栈
💻 HTML
字号:
<HTML>  <HEAD>    <TITLE>Pico-IrDA Manual</TITLE>  </HEAD>  <BODY>    <H1>Pico-IrDA Manual</H1>    <DL>      <DT>        <H3>Overview</H3>      <DD>	 Pico-IrDA is a minimalistic IrDA stack for microcontrollers.<BR>	 It supports IrOBEX in primary and secondary IrDA mode and	 IrCOMM in secondary mode only.<BR>	 Pico-IrDA works with a fixed baudrate of 9600 bps and is restricted	 to two communication peers.      <DT>        <H3>Library Initialization</H3>      <DD>        An application needs to reset the physical layer and	initialize an <B>IrLAP_Context</B>, which holds state information	about the session.	<HR>	<CODE>	  IrLAP_Context ctx;<BR>	  <BR>	  irphy_reset();<BR>	  irlap_init_context(&amp;ctx);<BR>	</CODE>	<HR>      <DT>        <H3>Physical Interface</H3>      <DD>        The library uses four functions defined in &quot;<B>irphy.h</B>&quot; to interface	with the physical IrDA transceiver.<BR>	<UL>	  <LI>	    <B>void&nbsp;irphy_reset(void);</B><BR>	    Initializes the physical interface and sets the baudrate to 9600 bps.	  <LI>	    <B>void&nbsp;irphy_send(uint8_t&nbsp;v);</B><BR>	    Sends a byte of data &quot;<B>v</B>&quot; via IrDA.	  <LI>	    <B>uint8_t&nbsp;irphy_wait(int16_t&nbsp;timeout);</B><BR>	    Returns a non-zero value if incoming data is available within a given &quot;<B>timeout</B>&quot;.<BR>	    If the &quot;<B>timeout</B>&quot; given in milliseconds expires before a byte of data is available,	    this function shall return zero.<BR>	    If the &quot;<B>timeout</B>&quot; is negative, this function should wait for incoming data indefinitely.	  <LI>	    <B>uint8_t&nbsp;irphy_receive(void);</B><BR>	    Receives an incoming byte of data and returns it.	</UL>      <DT>        <H3>IrOBEX Interface</H3>      <DD>        The simplest form of using the library is to send and/or receive data via IrOBEX.<BR>	Sending data is done by selecting the IrDA primary mode,	receiving data puts the device into IrDA secondary mode.<BR>	<UL>	  <LI>	    <B>uint8_t&nbsp;irobex_send(<BR>	       &nbsp;&nbsp;IrLAP_Context&nbsp;*context_p,<BR>	       &nbsp;&nbsp;IrLAP_Device_Addr&nbsp;addr_p,<BR>	       &nbsp;&nbsp;int16_t&nbsp;(*get_name_cb)(char&nbsp;*name,&nbsp;uint16_t&nbsp;size,&nbsp;void&nbsp;*user_data),<BR>	       &nbsp;&nbsp;int16_t&nbsp;(*get_data_cb)(uint8_t&nbsp;*data,&nbsp;uint16_t&nbsp;size,&nbsp;void&nbsp;*user_data),<BR>	       &nbsp;&nbsp;void&nbsp;*user_data);</B><BR>	    <UL>	      <LI>	        <B>context_p</B><BR>	        A previously initialized <B>IrLAP_Context</B>.	      <LI>	        <B>addr_p</B><BR>	        The device address of the intended peer or &quot;<B>0</B>&quot;		if no specific peer is known and discovery should be performed.	      <LI>	        <B>get_name_cb</B><BR>		A callback function that is used to retrieve the name of the message to be sent.<BR>		&quot;<B>name</B>&quot; points to a destination buffer to store the name, which holds		a maximum number of &quot;<B>size</B>&quot; bytes.<BR>		The number of bytes actually written to &quot;<B>name</B>&quot; should become the return value		of the callback.<BR>		If an error occurred, the callback can return a negative value and the transmission		is cancelled.<BR>		&quot;<B>user_data</B>&quot; contains the same value as the one passed to the		&quot;<B>irobex_send</B>&quot; function.<BR>		If &quot;<B>get_name_cb</B>&quot; is &quot;<B>0</B>&quot;, no name will be included in the		message.	      <LI>	        <B>get_data_cb</B><BR>		A callback function that is used to retrieve a data chunk for the message to be sent.<BR>		&quot;<B>data</B>&quot; points to a destination buffer to store the data, which holds		a maximum number of &quot;<B>size</B>&quot; bytes.<BR>		The number of bytes actually written to &quot;<B>data</B>&quot; should become the return value		of the callback.<BR>		If an error occurred, the callback can return a negative value and the transmission		is cancelled.<BR>		&quot;<B>user_data</B>&quot; contains the same value as the one passed to the		&quot;<B>irobex_send</B>&quot; function.<BR>		If &quot;<B>get_data_cb</B>&quot; is &quot;<B>0</B>&quot;, no data will be included in the		message.	      <LI>	        <B>user_data</B><BR>		An application defined pointer that is passed to the callback functions.	    </UL>	    If the transmission was successful, &quot;<B>irobex_send</B>&quot; returns a non-zero value.	    A return value of &quot;<B>0</B>&quot; indicates failure.	  <LI>	    <B>uint8_t&nbsp;irobex_receive(<BR>	       &nbsp;&nbsp;IrLAP_Context&nbsp;*context_p,<BR>	       &nbsp;&nbsp;uint8_t&nbsp;(*put_name_cb)(char&nbsp;*name,&nbsp;void&nbsp;*user_data),<BR>	       &nbsp;&nbsp;uint8_t&nbsp;(*put_data_cb)(uint8_t&nbsp;*data,&nbsp;uint16_t&nbsp;size,&nbsp;void&nbsp;*user_data),<BR>	       &nbsp;&nbsp;void&nbsp;*user_data);</B><BR>	    <UL>	      <LI>	        <B>context_p</B><BR>	        A previously initialized <B>IrLAP_Context</B>.	      <LI>	        <B>put_name_cb</B><BR>	        A callback function that is used to handle the name of a received message.<BR>		The name of the message is stored at &quot;<B>name</B>&quot; and is terminated with		a &quot;<B>0</B>&quot; character.<BR>		&quot;<B>user_data</B>&quot; contains the same value as the one passed to the		&quot;<B>irobex_receive</B>&quot; function.<BR>		If &quot;<B>put_name_cb</B>&quot; is &quot;<B>0</B>&quot;, the name part of a received		message remains unhandled.	      <LI>	        <B>put_data_cb</B><BR>	        A callback function that is used to handle a data chunk of a received message.<BR>		The data chunk is stored at &quot;<B>data</B>&quot; and contains &quot;<B>size</B>&quot; bytes.<BR>		&quot;<B>user_data</B>&quot; contains the same value as the one passed to the		&quot;<B>irobex_receive</B>&quot; function.<BR>		If &quot;<B>put_data_cb</B>&quot; is &quot;<B>0</B>&quot;, the data part of a received		message remains unhandled.	      <LI>	        <B>user_data</B><BR>		An application defined pointer that is passed to the callback functions.	    </UL>	    If the message was received successfully, &quot;<B>irobex_receive</B>&quot; returns a non-zero value.	    A return value of &quot;<B>0</B>&quot; indicates failure.	</UL>      <DT>        <H3>IrCOMM Interface</H3>      <DD>        The IrCOMM protocol is only supported in IrDA secondary mode.	<UL>	  <LI>	    <B>void&nbsp;ircomm2_serve(<BR>	       &nbsp;&nbsp;IrLAP_Context&nbsp;*context_p,<BR>	       &nbsp;&nbsp;int16_t&nbsp;(*put_data_cb)(<BR>	       &nbsp;&nbsp;&nbsp;&nbsp;uint8_t&nbsp;*data,&nbsp;uint16_t&nbsp;size,<BR>	       &nbsp;&nbsp;&nbsp;&nbsp;uint8_t&nbsp;*resp_buf,&nbsp;uint16_t&nbsp;resp_buf_size,<BR>	       &nbsp;&nbsp;&nbsp;&nbsp;uint8_t&nbsp;*terminate_p,<BR>	       &nbsp;&nbsp;&nbsp;&nbsp;void *user_data),<BR>	       &nbsp;&nbsp;void *user_data);</B><BR>	    <UL>	      <LI>	        <B>context_p</B><BR>	        A previously initialized <B>IrLAP_Context</B>.	      <LI>	        <B>put_data_cb</B><BR>	        A callback function that is used to handle an incoming data chunk.<BR>		The data chunk is stored at &quot;<B>data</B>&quot; and contains &quot;<B>size</B>&quot; bytes.<BR>		Up to &quot;<B>resp_buf_size</B>&quot; bytes can be stored into &quot;<B>resp_buf</B>&quot;		which is the data chunk that is sent back to the communication peer.<BR>		The number of bytes actually written to &quot;<B>resp_buf</B>&quot; should become the return value		of the callback.<BR>		If an error occurred, the callback can return a negative value and the transmission		is cancelled.<BR>		If a non-zero value is written to the byte pointed to by &quot;<B>terminate_p</B>&quot;		the transmission will be terminated after the response buffer is sent.	      <LI>	        <B>user_data</B><BR>		An application defined pointer that is passed to the callback function.	    </UL>        </UL>      <DT>        <H3>Selecting Protocol</H3>      <DD>        In IrDA secondary mode, it is possible to distinguish between incoming	IrOBEX and IrCOMM messages using the &quot;<B>irttp2_accept</B>&quot; function.<BR>	You need to announce the availability of the <B>IrIAS&nbsp;LsapSel</B> values	that relate to the corresponding protocols and set the proper <B>IrLMP</B> hints.<BR>	Example:	<HR>	<CODE>	  IrLAP_Context ctx;<BR>	  IrIAS_Node *ias_nodes[3];<BR>	  int16_t dlsap_sel;<BR>	  <BR>	  irphy_reset();<BR>	  irlap_init_context(&amp;ctx);<BR>	  <BR>	  /* ias_nodes contains all the IrIAS LsapSel values we support */<BR>	  ias_nodes[0]=&amp;irobex_ias_node;<BR>	  ias_nodes[1]=&amp;ircomm_ias_node;<BR>	  ias_nodes[2]=0;<BR>	  <BR>	  for(;;) {<BR>	  &nbsp;&nbsp;irphy_wait(-1);<BR>	  &nbsp;&nbsp;if((dlsap_sel=irttp2_accept(&amp;ctx, IRLMP_HINT1_OBEX | IRLMP_HINT1_COMM, ias_nodes))<0)<BR>	  &nbsp;&nbsp;&nbsp;&nbsp;continue;<BR>	  &nbsp;&nbsp;switch(dlsap_sel) {<BR>	  &nbsp;&nbsp;case IRCOMM_LSAP_SEL_VAL:<BR>	  &nbsp;&nbsp;&nbsp;&nbsp;handle_ircomm();<BR>	  &nbsp;&nbsp;&nbsp;&nbsp;break;<BR>	  &nbsp;&nbsp;case IROBEX_LSAP_SEL_VAL:<BR>	  &nbsp;&nbsp;&nbsp;&nbsp;handle_irobex();<BR>	  &nbsp;&nbsp;&nbsp;&nbsp;break;<BR>	  &nbsp;&nbsp;}<BR>	  }<BR>	</CODE>	<HR>      <DT>        <H3>Copyright Notice</H3>      <DD>        Copyright &copy; 2002-2003 Gerd Rausch, <A HREF="http://blaulogic.com">BlauLogic</A><BR>	All rights reserved.	<P>	Redistribution and use in source and binary forms, with or without	modification, are permitted provided that the following conditions are	met:	<OL>	  <LI>	    Redistributions of source code must retain the above copyright	    notice, this list of conditions and the following disclaimer.	  <LI>	    Redistributions in binary form must reproduce the above	    copyright notice, this list of conditions and the following	    disclaimer in the documentation and/or other materials provided	    with the distribution.	  <LI>	    Except as contained in this notice, neither the name of BlauLogic	    nor the name(s) of the author(s) may be used to endorse or promote	    products derived from this software without specific prior written	    permission.	</OL>	<P>	THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.	IN NO EVENT SHALL THE AUTHOR(S) OR BLAULOGIC BE LIABLE FOR ANY CLAIM,	DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR	OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR	THE USE OR OTHER DEALINGS IN THE SOFTWARE.    </DL>  </BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -